ApiGatewayDomain Class
Defines an API Gateway domain name as the alias target.
Use the ApiGateway class if you wish to map the alias to an REST API with a domain name defined through the RestApiProps.domainName prop.
Example
ts
declare const hostedZoneForExampleCom: any;
declare const domainName: apigateway.DomainName;
import * as route53 from 'aws-cdk-lib/aws-route53';
import * as targets from 'aws-cdk-lib/aws-route53-targets';
new route53.ARecord(this, 'CustomDomainAliasRecord', {
zone: hostedZoneForExampleCom,
target: route53.RecordTarget.fromAlias(new targets.ApiGatewayDomain(domainName))
});
python
# hosted_zone_for_example_com: Any
# domain_name: apigateway.DomainName
import aws_cdk.aws_route53 as route53
import aws_cdk.aws_route53_targets as targets
route53.ARecord(self, "CustomDomainAliasRecord",
zone=hosted_zone_for_example_com,
target=route53.RecordTarget.from_alias(targets.ApiGatewayDomain(domain_name))
)
java
Object hostedZoneForExampleCom;
DomainName domainName;
import software.amazon.awscdk.services.route53.*;
import software.amazon.awscdk.services.route53.targets.*;
ARecord.Builder.create(this, "CustomDomainAliasRecord")
.zone(hostedZoneForExampleCom)
.target(RecordTarget.fromAlias(new ApiGatewayDomain(domainName)))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var hostedZoneForExampleCom;
DomainName domainName;
using Amazon.CDK.AWS.Route53;
using Amazon.CDK.AWS.Route53.Targets;
new ARecord(this, "CustomDomainAliasRecord", new ARecordProps {
Zone = hostedZoneForExampleCom,
Target = RecordTarget.FromAlias(new ApiGatewayDomain(domainName))
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var hostedZoneForExampleCom interface{}
var domainName DomainName
import "github.com/aws/aws-cdk-go/awscdk"
import targets "github.com/aws/aws-cdk-go/awscdk"
route53.NewARecord(this, jsii.String("CustomDomainAliasRecord"), &ARecordProps{
Zone: hostedZoneForExampleCom,
Target: route53.RecordTarget_FromAlias(targets.NewApiGatewayDomain(domainName)),
})
Initializer
ts
new ApiGatewayDomain(domainName: IDomainName)
python
ApiGatewayDomain(domain_name: IDomainName)
java
new ApiGatewayDomain(IDomainName domainName)
csharp
new ApiGatewayDomain(IDomainName domainName)
go
NewApiGatewayDomain(DomainName IDomainName)
Methods
bind(_record: IRecordSet, _zone?: IHostedZone): AliasRecordTargetConfigdef bind(self, _record: IRecordSet, _zone: typing.Optional[IHostedZone] = None) -> AliasRecordTargetConfigpublic AliasRecordTargetConfig bind(IRecordSet _record, IHostedZone _zone)public AliasRecordTargetConfig Bind(IRecordSet _record, IHostedZone? _zone = null)func Bind(_record IRecordSet, _zone IHostedZone) AliasRecordTargetConfig#Return hosted zone ID and DNS name, usable for Route53 alias targets.