See: Description
| Class | Description |
|---|---|
| ApiGateway |
Defines an API Gateway REST API as the alias target.
|
| ApiGatewayDomain |
Defines an API Gateway domain name as the alias target.
|
| ApiGatewayv2DomainProperties |
Defines an API Gateway V2 domain name as the alias target.
|
| BucketWebsiteTarget |
Use a S3 as an alias record target.
|
| ClassicLoadBalancerTarget |
Use a classic ELB as an alias record target.
|
| CloudFrontTarget |
Use a CloudFront Distribution as an alias record target.
|
| ElasticBeanstalkEnvironmentEndpointTarget |
Use an Elastic Beanstalk environment URL as an alias record target.
|
| GlobalAcceleratorDomainTarget |
Use a Global Accelerator domain name as an alias record target.
|
| GlobalAcceleratorTarget |
Use a Global Accelerator instance domain name as an alias record target.
|
| InterfaceVpcEndpointTarget |
Set an InterfaceVpcEndpoint as a target for an ARecord.
|
| LoadBalancerTarget |
Use an ELBv2 as an alias record target.
|
| Route53RecordTarget |
Use another Route 53 record as an alias record target.
|
| UserPoolDomainTarget |
Use a user pool domain as an alias record target.
|
This library contains Route53 Alias Record targets for:
import software.amazon.awscdk.services.apigateway.*;
HostedZone zone;
LambdaRestApi restApi;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new ApiGateway(restApi)))
.build();
// Example automatically generated from non-compiling source. May contain errors.
import software.amazon.awscdk.services.apigatewayv2.*;
HostedZone zone;
apigwv2.DomainName domainName;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new ApiGatewayv2DomainProperties(domainName.getRegionalDomainName(), domainName.getRegionalHostedZoneId())))
.build();
import software.amazon.awscdk.services.cloudfront.*;
HostedZone zone;
CloudFrontWebDistribution distribution;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new CloudFrontTarget(distribution)))
.build();
import software.amazon.awscdk.services.elasticloadbalancingv2.*;
HostedZone zone;
ApplicationLoadBalancer lb;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new LoadBalancerTarget(lb)))
.build();
import software.amazon.awscdk.services.elasticloadbalancing.*;
HostedZone zone;
LoadBalancer lb;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new ClassicLoadBalancerTarget(lb)))
.build();
Important: Based on AWS documentation, 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.
import software.amazon.awscdk.services.globalaccelerator.*;
HostedZone zone;
Accelerator accelerator;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new GlobalAcceleratorTarget(accelerator)))
.build();
Important: If you use GlobalAcceleratorDomainTarget, passing a string rather than an instance of IAccelerator, ensure that the string is a valid domain name of an existing Global Accelerator instance. See the documentation on DNS addressing with Global Accelerator for more info.
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.
import software.amazon.awscdk.services.ec2.*;
HostedZone zone;
InterfaceVpcEndpoint interfaceVpcEndpoint;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new InterfaceVpcEndpointTarget(interfaceVpcEndpoint)))
.build();
Important: The Bucket name must strictly match the full DNS name. See the Developer Guide for more info.
import software.amazon.awscdk.services.s3.*;
String recordName = "www";
String domainName = "example.com";
Bucket bucketWebsite = Bucket.Builder.create(this, "BucketWebsite")
.bucketName(List.of(recordName, domainName).join(".")) // www.example.com
.publicReadAccess(true)
.websiteIndexDocument("index.html")
.build();
IHostedZone zone = HostedZone.fromLookup(this, "Zone", HostedZoneProviderProps.builder().domainName(domainName).build()); // example.com
// example.com
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.recordName(recordName) // www
.target(RecordTarget.fromAlias(new BucketWebsiteTarget(bucketWebsite)))
.build();
import software.amazon.awscdk.services.cognito.*;
HostedZone zone;
UserPoolDomain domain;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new UserPoolDomainTarget(domain)))
.build();
HostedZone zone;
ARecord record;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new Route53RecordTarget(record)))
.build();
Important: Only supports Elastic Beanstalk environments created after 2016 that have a regional endpoint.
HostedZone zone;
String ebsEnvironmentUrl;
ARecord.Builder.create(this, "AliasRecord")
.zone(zone)
.target(RecordTarget.fromAlias(new ElasticBeanstalkEnvironmentEndpointTarget(ebsEnvironmentUrl)))
.build();
See the documentation of @aws-cdk/aws-route53 for more information.
Copyright © 2022. All rights reserved.