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

(@aws-cdk/aws-route53): ARecord with ApiGatewayv2DomainProperties to subdomain not working #17244

Open
janschloss opened this issue Oct 30, 2021 · 4 comments
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@janschloss
Copy link

janschloss commented Oct 30, 2021

What is the problem?

Hello,

when trying to create an ARecord with an HTTP API alias on a subdomain, the record is created with the general domain instead.

Reproduction Steps

    const apiSubDomain = `api.${this.domain}`;

    const hostedZone = HostedZone.fromLookup(this, "HostedZone", {
      domainName: this.domain,
    });

    const certificate = new Certificate(this, "Certificate", {
      domainName: this.domain,
      subjectAlternativeNames: [apiSubDomain],
      validation: CertificateValidation.fromDns(hostedZone),
    });

    const domainName = new DomainName(this, "DomainName", {
// > Note that this is using the subdomain
      domainName: apiSubDomain,
      certificate: certificate,
    });

    const httpApi = new HttpApi(this, "HttpApi", {
      disableExecuteApiEndpoint: false,
      defaultDomainMapping: {
// > Note that this is using the subdomain
        domainName,
      },
    });

    new ARecord(this, "HttpApiAliasRecord", {
      zone: hostedZone,
      target: RecordTarget.fromAlias(
        new ApiGatewayv2DomainProperties(
          domainName.regionalDomainName,
          domainName.regionalHostedZoneId
        )
      ),
    });

What did you expect to happen?

I expected an A Record like this in Route53:
api.example.com | A | Simple | - | alias.....

What actually happened?

An A Record to the general domain was created:
example.com | A | Simple | - | alias.....

CDK CLI Version

1.130.0 (build 9c094ae)

Framework Version

No response

Node.js Version

v14.18.0

OS

Windows

Language

Typescript

Language Version

No response

Other information

No response

@janschloss janschloss added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 30, 2021
@github-actions github-actions bot added the @aws-cdk/aws-route53 Related to Amazon Route 53 label Oct 30, 2021
@njlynch njlynch added effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Dec 8, 2021
@njlynch njlynch removed their assignment Dec 8, 2021
@lukewiwa
Copy link

lukewiwa commented Dec 29, 2021

Yes I think this is where the critical bug is

this.domainName = distribution.attrDomainName;

Seems that by default it takes the top level domain rather than one from the "domains" attribute

Solution

I figured out if you put the record name as the subdomain you wish to connect to it should work out ok.

    new route53.ARecord(this, "AliasRecord", {
      zone: hostedZone,
      recordName: "sub.domain.com",
      target: route53.RecordTarget.fromAlias(
        new alias.CloudFrontTarget(distribution)
      )
    });
  }

@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Dec 29, 2022
@github-actions github-actions bot closed this as completed Jan 3, 2023
@janschloss
Copy link
Author

Don't think this is fixed yet

@simonloach
Copy link

This is not fixed and very misleading.

@kaizencc kaizencc reopened this Jan 20, 2023
@kaizencc kaizencc removed the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

6 participants