Route53 Alias Record Targets for the CDK Route53 Library
This library contains Route53 Alias Record targets for:
- API Gateway custom domains
new route53.ARecord(this, 'AliasRecord', {
zone,
target: route53.RecordTarget.fromAlias(new alias.ApiGateway(restApi)),
});
- CloudFront distributions
new route53.ARecord(this, 'AliasRecord', {
zone,
target: route53.RecordTarget.fromAlias(new alias.CloudFrontTarget(distribution)),
});
- ELBv2 load balancers
new route53.ARecord(this, 'AliasRecord', {
zone,
target: route53.RecordTarget.fromAlias(new alias.LoadBalancerTarget(elbv2)),
});
- Classic load balancers
new route53.ARecord(this, 'AliasRecord', {
zone,
target: route53.RecordTarget.fromAlias(new alias.ClassicLoadBalancerTarget(elb)),
});
- InterfaceVpcEndpoints
Important: Based on the CFN docs for VPCEndpoints - see here - 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.
new route53.ARecord(stack, "AliasRecord", {
zone,
target: route53.RecordTarget.fromAlias(new alias.InterfaceVpcEndpointTarget(interfaceVpcEndpoint))
});
Important: The Bucket name must strictly match the full DNS name.
See the Developer Guide for more info.
const [recordName, domainName] = ['www', 'example.com'];
const bucketWebsite = new Bucket(this, 'BucketWebsite', {
bucketName: [recordName, domainName].join('.'),
publicReadAccess: true,
websiteIndexDocument: 'index.html',
});
const zone = HostedZone.fromLookup(this, 'Zone', {domainName});
new route53.ARecord(this, 'AliasRecord', {
zone,
recordName,
target: route53.RecordTarget.fromAlias(new alias.BucketWebsiteTarget(bucket)),
});
- User pool domain
new route53.ARecord(this, 'AliasRecord', {
zone,
target: route53.RecordTarget.fromAlias(new alias.UserPoolDomainTarget(domain)),
});
See the documentation of @aws-cdk/aws-route53
for more information.