# Route53 Alias Record Targets for the CDK Route53 Library
<!--BEGIN STABILITY BANNER-->---
![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge)
---
<!--END STABILITY BANNER-->
This library contains Route53 Alias Record targets for:
* API Gateway custom domains
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
route53.ARecord(self, "AliasRecord",
zone=zone,
target=route53.RecordTarget.from_alias(alias.ApiGateway(rest_api))
)
```
* CloudFront distributions
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
route53.ARecord(self, "AliasRecord",
zone=zone,
target=route53.RecordTarget.from_alias(alias.CloudFrontTarget(distribution))
)
```
* ELBv2 load balancers
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
route53.ARecord(self, "AliasRecord",
zone=zone,
target=route53.RecordTarget.from_alias(alias.LoadBalancerTarget(elbv2))
)
```
* Classic load balancers
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
route53.ARecord(self, "AliasRecord",
zone=zone,
target=route53.RecordTarget.from_alias(alias.ClassicLoadBalancerTarget(elb))
)
```
**Important:** Based on [AWS documentation](https://aws.amazon.com/de/premiumsupport/knowledge-center/alias-resource-record-set-route53-cli/), all alias record in Route 53 that points to a Elastic Load Balancer will always include *dualstack* for the DNSName to resolve IPv4/IPv6 addresses (without *dualstack* IPv6 will not resolve).
For example, if the Amazon-provided DNS for the load balancer is `ALB-xxxxxxx.us-west-2.elb.amazonaws.com`, CDK will create alias target in Route 53 will be `dualstack.ALB-xxxxxxx.us-west-2.elb.amazonaws.com`.
* InterfaceVpcEndpoints
**Important:** Based on the CFN docs for VPCEndpoints - [see here](attrDnsEntries) - the attributes returned for DnsEntries in CloudFormation is a combination of the hosted zone ID and the DNS name. The entries are ordered as follows: regional public DNS, zonal public DNS, private DNS, and wildcard DNS. This order is not enforced for AWS Marketplace services, and therefore this CDK construct is ONLY guaranteed to work with non-marketplace services.
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
route53.ARecord(stack, "AliasRecord",
zone=zone,
target=route53.RecordTarget.from_alias(alias.InterfaceVpcEndpointTarget(interface_vpc_endpoint))
)
```
* S3 Bucket Website:
**Important:** The Bucket name must strictly match the full DNS name.
See [the Developer Guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/getting-started.html) for more info.
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
[recordName, domainName] = ["www", "example.com"]
bucket_website = Bucket(self, "BucketWebsite",
bucket_name=[record_name, domain_name].join("."), # www.example.com
public_read_access=True,
website_index_document="index.html"
)
zone = HostedZone.from_lookup(self, "Zone", domain_name=domain_name)# example.com
route53.ARecord(self, "AliasRecord",
zone=zone,
record_name=record_name, # www
target=route53.RecordTarget.from_alias(alias.BucketWebsiteTarget(bucket))
)
```
* User pool domain
```python
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
route53.ARecord(self, "AliasRecord",
zone=zone,
target=route53.RecordTarget.from_alias(alias.UserPoolDomainTarget(domain))
)
```
See the documentation of `@aws-cdk/aws-route53` for more information.