ApiGateway Class
Defines an API Gateway REST API as the alias target. Requires that the domain name will be defined through RestApiProps.domainName.
You can direct the alias to any apigateway.DomainName resource through the ApiGatewayDomain class.
Example
ts
import * as route53 from 'aws-cdk-lib/aws-route53';
import * as targets from 'aws-cdk-lib/aws-route53-targets';
declare const api: apigateway.RestApi;
declare const hostedZoneForExampleCom: any;
new route53.ARecord(this, 'CustomDomainAliasRecord', {
zone: hostedZoneForExampleCom,
target: route53.RecordTarget.fromAlias(new targets.ApiGateway(api))
});
python
import aws_cdk.aws_route53 as route53
import aws_cdk.aws_route53_targets as targets
# api: apigateway.RestApi
# hosted_zone_for_example_com: Any
route53.ARecord(self, "CustomDomainAliasRecord",
zone=hosted_zone_for_example_com,
target=route53.RecordTarget.from_alias(targets.ApiGateway(api))
)
java
import software.amazon.awscdk.services.route53.*;
import software.amazon.awscdk.services.route53.targets.*;
RestApi api;
Object hostedZoneForExampleCom;
ARecord.Builder.create(this, "CustomDomainAliasRecord")
.zone(hostedZoneForExampleCom)
.target(RecordTarget.fromAlias(new ApiGateway(api)))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Route53;
using Amazon.CDK.AWS.Route53.Targets;
RestApi api;
var hostedZoneForExampleCom;
new ARecord(this, "CustomDomainAliasRecord", new ARecordProps {
Zone = hostedZoneForExampleCom,
Target = RecordTarget.FromAlias(new ApiGateway(api))
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
import targets "github.com/aws/aws-cdk-go/awscdk"
var api RestApi
var hostedZoneForExampleCom interface{}
route53.NewARecord(this, jsii.String("CustomDomainAliasRecord"), &ARecordProps{
Zone: hostedZoneForExampleCom,
Target: route53.RecordTarget_FromAlias(targets.NewApiGateway(api)),
})
Initializer
ts
new ApiGateway(api: RestApiBase)
python
ApiGateway(api: RestApiBase)
java
new ApiGateway(RestApiBase api)
csharp
new ApiGateway(RestApiBase api)
go
NewApiGateway(Api RestApiBase)
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.