Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[route53-targets] support APIGatewayV2 as a domain target #8941

Closed
nija-at opened this issue Jul 8, 2020 · 5 comments · Fixed by #10191
Closed

[route53-targets] support APIGatewayV2 as a domain target #8941

nija-at opened this issue Jul 8, 2020 · 5 comments · Fixed by #10191
Assignees
Labels
@aws-cdk/aws-route53-targets effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1

Comments

@nija-at
Copy link
Contributor

nija-at commented Jul 8, 2020

(forked off #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 🚀 Feature Request

@nija-at nija-at added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 8, 2020
@kennu
Copy link

kennu commented Jul 8, 2020

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,
  })
})

@shivlaks shivlaks added the effort/medium Medium work item – several days of effort label Jul 14, 2020
@christophgysin
Copy link
Contributor

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)),
});

@shivlaks shivlaks added the p1 label Aug 6, 2020
@davidsteed
Copy link

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.

@SomayaB SomayaB added in-progress This issue is being actively worked on. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 8, 2020
@mergify mergify bot closed this as completed in #10191 Nov 6, 2020
mergify bot pushed a commit that referenced this issue Nov 6, 2020
Add support for [aws-apigatewayv2](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigatewayv2-readme.html#custom-domain) `DomainName` as target.

Closes #8941

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Nov 6, 2020

⚠️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.

@sladg
Copy link

sladg commented Jan 31, 2023

Solved by following code:

// Manual type overwrite to allow for alias target for newer HTTP API.
;(apiGwDomain as any).domainName = apiGwDomain.name
;(apiGwDomain as any).domainNameAliasDomainName = apiGwDomain.regionalDomainName
;(apiGwDomain as any).domainNameAliasHostedZoneId = apiGwDomain.regionalHostedZoneId

const apiGwTarget = RecordTarget.fromAlias(new ApiGatewayDomain(apiGwDomain as any))

Basically, remapped V2 regional props to V1.

CC: #17244

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-route53-targets effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants