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

HostedZone.fromlookup not working in nested stacks #4651

Closed
AlexRex opened this issue Oct 23, 2019 · 7 comments
Closed

HostedZone.fromlookup not working in nested stacks #4651

AlexRex opened this issue Oct 23, 2019 · 7 comments
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort needs-reproduction This issue needs reproduction. p1 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@AlexRex
Copy link

AlexRex commented Oct 23, 2019

When using HostedZone.fromLookUp in a nested stack is not able to find out the hostedzone and keeps the DUMMY id value. Also it does not creates the entry in the context file.

Reproduction Steps

Create a hosted zone in route 53. Then create a stack, inside this stack create a nested stack that just gets a zone based in a domain name:

const zone = HostedZone.fromLookup(this, `zoneId`, {
      domainName: domain
    });

Error Log

No hosted zone found with ID: DUMMY (Service: AmazonRoute53; Status Code: 404; Error Code: NoSuchHostedZone; Request ID: 9868b6a0-6109-48e6-b475-c31c6041778f)

Environment

  • CLI Version : v.1.12.0
  • Framework Version: v.1.12.0
  • OS : mac
  • Language : Typescript

Other


This is 🐛 Bug Report

@AlexRex AlexRex added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 23, 2019
@SomayaB SomayaB added the @aws-cdk/aws-route53 Related to Amazon Route 53 label Oct 23, 2019
@SomayaB SomayaB added needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 23, 2019
@shivlaks shivlaks added the p1 label Oct 31, 2019
@shivlaks shivlaks added the effort/medium Medium work item – several days of effort label Aug 21, 2020
@flashflexpro
Copy link

For me, the same error is from
new r53.ARecord(this, id + 'phpadminARecord', { recordName: 'phpadmin', zone: phpadminHostzone, target: r53.RecordTarget.fromAlias(new r53Targets.LoadBalancerTarget(loadBalancerFromOtherStack)) });
Template is

{ "Resources": { "??????????ARecordE5EA89BC": { "Type": "AWS::Route53::RecordSet", "Properties": { "Name": "recordName.hostzonename", "Type": "A", "AliasTarget": { "DNSName": { "Fn::Join": [ "", [ "dualstack.", { "Fn::ImportValue": "phpAdmin-FargateAlb:ExportsOutputFnGetAttphpadminfargateserviceLB1A2C75E2DNSNameA1C77413" } ] ] }, "HostedZoneId": { "Fn::ImportValue": "phpAdmin-FargateAlb:ExportsOutputFnGetAttphpadminfargateserviceLB1A2C75E2CanonicalHostedZoneID5377D125" } }, "HostedZoneId": "PHYSICAL-HOSTEDZONEID" }, "Metadata": { "aws:cdk:path": "phpAdmin-FargateAlbDNS/phpAdmin-FargateAlbDNSphpadminARecord/Resource" } } } }

It seems to be the "HostedZoneId": "PHYSICAL-HOSTEDZONEID" is causing the problem, but only when running inside codepipeline.

@gyang-vonage
Copy link

gyang-vonage commented Oct 21, 2020

Still happening, can be avoided with command "cdk deploy", only happens when using CloudFormationCreateUpdateStackAction.

@ilia-luk
Copy link

ilia-luk commented Oct 30, 2020

experiencing the same behavior

CLI Version : v.1.69.0
Language : Typescript

@flashflexpro
Copy link

flashflexpro commented Nov 2, 2020 via email

@NGL321 NGL321 assigned njlynch and unassigned shivlaks Jan 25, 2021
@abend-arg
Copy link

I am expecting the very same issue. I have a stage which is created within a CodePipeline stack. This stage have a stack which uses fromLookup method but it is unable to find the hostedZone even when the env is properly set.

@corymhall
Copy link
Contributor

@AlexRex is this still an issue for you? I tried reproducing this issue on a recent version of the CDK and the fromLookup method was able to correctly populate the hosted zone id in a nested stack.

@AbendGithub it should work as long as you have AWS credentials with access to perform the lookup during synth. So in your case if you are performing synth as part of a CodeBuild action, the CodeBuild role must have access to perform the lookup.

Alternatively, the recommended approach to handling lookups is to perform synth locally with credentials which will populate the cdk.context.json which should then be commited. Then during the pipeline execution, the synth CodeBuild action will use the value in cdk.context.json instead of performing a lookup. See the section on committing cdk.context.json in the developer guide

@corymhall corymhall added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 4, 2021
@github-actions
Copy link

github-actions bot commented Nov 6, 2021

This issue has not received a response in a while. 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 Nov 6, 2021
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. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort needs-reproduction This issue needs reproduction. p1 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

9 participants