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: Add support for GraphqlApiDomainTarget #26109

Closed
1 of 2 tasks
thesnups opened this issue Jun 25, 2023 · 5 comments · Fixed by #31976
Closed
1 of 2 tasks

route53-targets: Add support for GraphqlApiDomainTarget #26109

thesnups opened this issue Jun 25, 2023 · 5 comments · Fixed by #31976
Labels
@aws-cdk/aws-appsync Related to AWS AppSync @aws-cdk/aws-route53-targets effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@thesnups
Copy link

thesnups commented Jun 25, 2023

Describe the feature

Implement GraphqlApiDomainTarget in aws-cdk-lib/aws-route53-targets to facilitate easily configuring A records for AppSync APIs with custom domains.

Use Case

https://github.com/aws/aws-cdk/tree/main/packages/aws-cdk-lib/aws-route53-targets is missing an IAliasRecordTarget implementation for AWS AppSync GraphQL APIs. The AppSync docs suggest the use of a CNAME for custom domains, but that is not an option for me because I cannot create a CNAME at the apex of the hosted zone. Also, the Route 53 console UI supports AppSync domains as an alias target, and that should be reflected in CDK.

Proposed Solution

I am currently using the following workaround in my project:

import { GraphqlApi } from 'aws-cdk-lib/aws-appsync';
import {
  AliasRecordTargetConfig,
  IAliasRecordTarget,
  IHostedZone,
  IRecordSet,
} from 'aws-cdk-lib/aws-route53';
import { CloudFrontTarget } from 'aws-cdk-lib/aws-route53-targets';

class GraphqlApiDomainTarget implements IAliasRecordTarget {
  constructor(private readonly graphqlApi: GraphqlApi) {}

  public bind(_record: IRecordSet, _zone?: IHostedZone): AliasRecordTargetConfig {
    return {
      dnsName: this.graphqlApi.appSyncDomainName,
      hostedZoneId: CloudFrontTarget.getHostedZoneId(this.graphqlApi),
    };
  }
}

I based this implementation on the UserPoolDomainTarget, and it seems to work. Unsure if there is a different, preferable approach. Here it is in use:

new ARecord(this, 'GraphqlApiDomainARecord', {
  target: RecordTarget.fromAlias(new GraphqlApiDomainTarget(myGraphqlApi)),
  zone: myHostedZone,
});

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.85.0

Environment details (OS name and version, etc.)

Mac OS

@thesnups thesnups added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 25, 2023
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Jun 25, 2023
@thesnups thesnups changed the title (module name): (short issue description) (aws-cdk-lib/aws-route53-targets): Add support for GraphqlApiDomainTarget Jun 25, 2023
@thesnups thesnups changed the title (aws-cdk-lib/aws-route53-targets): Add support for GraphqlApiDomainTarget aws-cdk-lib/aws-route53-targets: Add support for GraphqlApiDomainTarget Jun 25, 2023
@pahud pahud changed the title aws-cdk-lib/aws-route53-targets: Add support for GraphqlApiDomainTarget route53-targets: Add support for GraphqlApiDomainTarget Jun 26, 2023
@pahud
Copy link
Contributor

pahud commented Jun 26, 2023

It makes sense to me. We welcome and appreciate your PR if it's ready. Thank you for your contribution.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 26, 2023
@fabio-vitali-docebo
Copy link

fabio-vitali-docebo commented Jul 12, 2023

It also makes sense for multi-region deployment, in the context of a disaster recovery implementation.

@ShivamJoker
Copy link

I also had to use the workaround provided by @thesnups.
When will we get the built in support for Appsync domains?

Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-appsync Related to AWS AppSync @aws-cdk/aws-route53-targets effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants