Aws-cdk: [route53-targets] support APIGatewayV2 as a domain target

Created on 8 Jul 2020  路  4Comments  路  Source: aws/aws-cdk

(forked off https://github.com/aws/aws-cdk/issues/8908)

Something like this already exists for RestApi - https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-route53-targets.ApiGatewayDomain.html

Need similar support for APIGatewayV2.


This is a :rocket: Feature Request

@aws-cdaws-route53-targets efformedium feature-request in-progress p1

Most helpful comment

I have the same need. While waiting for official support, I used my own function to bind to DomainName:

target: RecordTarget.fromAlias({
  bind: (_record: IRecordSet) => ({
    dnsName: httpDomainName.regionalDomainName,
    hostedZoneId: httpDomainName.regionalHostedZoneId,
  })
})

All 4 comments

I have the same need. While waiting for official support, I used my own function to bind to DomainName:

target: RecordTarget.fromAlias({
  bind: (_record: IRecordSet) => ({
    dnsName: httpDomainName.regionalDomainName,
    hostedZoneId: httpDomainName.regionalHostedZoneId,
  })
})

I just copied the ApiGatewayDomain class from aws-apigateway:

class ApiGatewayDomain implements route53.IAliasRecordTarget {
  constructor(private readonly domainName: apigwv2.IDomainName) { }

  public bind(_record: route53.IRecordSet): route53.AliasRecordTargetConfig {
    return {
      dnsName: this.domainName.regionalDomainName,
      hostedZoneId: this.domainName.regionalHostedZoneId,
    };
  }
}

new route53.ARecord(this, 'AliasRecord', {
  zone: hostedZone,
  recordName: 'api',
  target: route53.RecordTarget.fromAlias(new ApiGatewayDomain(domainName)),
});

This is easy to do in v1 apigateway
const domain = new apigateway.DomainName(this, "myApiDomain", {
domainName: restAPIDomain,
certificate: certificate,
endpointType: apigateway.EndpointType.REGIONAL,
});
const api = new apigateway.RestApi( "RestAPI", {
restApiName: "API",
description: "REST API",
});

domain.addBasePathMapping(api);

Want an equally straight forward way of doing it for v2. Can't find how to easily specify Endpoint REGIONAL for v2 either.

鈿狅笍COMMENT VISIBILITY WARNING鈿狅笍

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Was this page helpful?
0 / 5 - 0 ratings