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)),
});
- S3 Bucket WebSite:
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)),
});
See the documentation of @aws-cdk/aws-route53
for more information.