-
Notifications
You must be signed in to change notification settings - Fork 4k
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.HostedZone.fromLookup returned error #5547
Comments
Hi @gsm1011 The error is pointing you in the right direction. When using: const zone = route53.HostedZone.fromLookup(this, 'Zone', { domainName: props.domainName }); The CDK uses a context provider. The providers actually use the AWS SDK to call the Route53 API in this situation. In order for the SDK calls to work there must be credentials. Due to the potential errors that can occur with default credentials in your ENV the CDK requires that you set these variables either on the stack: new MyStack(app, 'MyStackName', {
env: {
region: process.env.AWS_DEFAULT_REGION,
account: '123456789012',
},
}); or by setting the ENV variables described in the error message. If you do one of those two things the |
That's weird but I'm facing same issue even |
I had the same issue even after setting the env.
On Sun, Dec 29, 2019 at 12:00 PM solshark ***@***.***> wrote:
That's weird but I'm facing same issue even env is defined during stack
creation.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5547?email_source=notifications&email_token=AACSEFEXJEYK5N37JVLSNWDQ3D6XHA5CNFSM4J7A2IYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHZHEXA#issuecomment-569537116>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACSEFDH6IT5IWY2PPGD6PLQ3D6XHANCNFSM4J7A2IYA>
.
--
Thanks,
Shumin
|
@gsm1011 @solshark -- can you guys provide a little more detail in the reproduction? The example I showed you is coming directly from a working source code that is using this method. (cdk version is 1.19.0). So I'm hoping we are just missing something easy for both of you. It's worth noting I am not using the CDK env vars, we are setting in the CDK App directly. |
@gsm1011 @solshark - as @moofish32 mentioned, I'd also like to get a clearer idea of the repro steps to narrow this issue down. Does using env in your source work? Here's an example in the docs if you have not done it before |
I just ran into this. I had been relying on my I fixed the issue by setting the environment variables "CDK_DEFAULT_ACCOUNT" and "CDK_DEFAULT_REGION" as the error message suggested. @shivlaks - Is it expected behavior that |
@shivlaks sorry for late reply. Yep, I've tried to set env with no luck. Time was flying for that specific project so I went with:
|
The frustrating thing for me is that it works and deploys well but I can't get it to run the tests properly because of this issue. |
But why adding the region and account required only when using Cannot it be inferred like all the other commands? |
@diogoap -
@optinirr can you help me with a repro of your issue (or trace if you can run cdk commands with the Here's what I'm doing ( new r53.HostedZone(this, 'my-hosted-zone', {
zoneName: 'www.test.nala',
}); Stack 2 where I will look up the created hosted zone: const imported = r53.HostedZone.fromLookup(this, 'my-looked-up-hz', {
domainName: 'www.test.nala',
}); It's created by providing the environment. i.e. new ReferenceRoute53Stack(app, 'ReferenceRoute53Stack', {
env: {
account: '123456789012',
region: 'us-east-1',
},
}); When I run {
"hosted-zone:account=123456789012:domainName=www.test.nala:region=us-east-1": {
"Id": "/hostedzone/Z0577316FL60KM8IZ7KT",
"Name": "www.test.nala."
}
} Additionally, the context lookup is not performed if the |
Thanks for the explanation @shivlaks |
@diogoap There's a little more detail in our documentation on environments and why we require an environment to be established to use framework facilities such as context lookups. to reduce friction during development you can do something like the following
These variables are set based on the AWS profile specified using the --profile option, or the default AWS profile if you don't specify one. This way you can switch your accounts or profiles and avoid having to specify an env on every iteration. As mentioned in the documentation, this is useful during development, but probably an anti-pattern for production use. |
adding the @optinirr - can you provide a minimal example where it works and is not usable in tests? Perhaps there's something actionable that we can follow up with. |
@shivlaks it was an env issue for me as well, as my env for deploy and test are not the same and my test env did not contain an "account" or "region". |
@optinirr Can you help me wrap my head around the scope of the issue? My understanding is that If we look at the source code, we can see that aws-cdk/packages/@aws-cdk/aws-route53/lib/hosted-zone.ts Lines 122 to 125 in 4e72d1e
If the
Please lmk if I'm missing something though @shivlaks @optinirr! |
@BryanPan342 I think the primary issue is confusion on when to use which API and the pre-requisites for each (local vs. requiring environment configuration). To reduce friction and avoid this common point of confusion, we need to shore up the Additionally, there's also
finally, there's If the entry does not exist in If |
In this case, I think this is a documentation issue rather than a bug so changing the label to |
I'm having some problems related to this. When I try to use:
I got this error:
Not sure what is this Z0622398W2TQKSDOS30M since is not the same as my zone ID. To verify if my domain and id's are ok, I have used:
Everything is in the list, and is also included in cdk.context.json
|
@salsa2k If you know the zone id, I suggest using the function For example, if you had a app configuration like this: new MyDevStack(app, 'dev', {
env: {
account: process.env.CDK_DEPLOY_ACCOUNT || process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEPLOY_REGION || process.env.CDK_DEFAULT_REGION
}}); What I suspect might be happening is that CDK is looking at the wrong account and the query with that account is turning up empty responses. To get around the above, you must export From the documentation something like this should work #!/bin/bash
# cdk-deploy-to.sh
export CDK_DEPLOY_ACCOUNT=$1
shift
export CDK_DEPLOY_REGION=$1
shift
cdk deploy "$@" and then you can run Alternatively, I think you could also have your app configuration like this new MyDevStack(app, 'dev', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION
}}); and specify the profile during execution like this |
Hi, I found what is the problem: Is related to my alias creatio.
I changed it to:
And now its working o0 Thanks guys |
…ausing confusion (#8830) Wrote up some documentation stuff but happy to change it to be more clear on the differences between `HostedZone.fromLookup`, `HostedZone.fromHostedZoneAttributes`, and `HostedZone.fromHostedZoneId`. Fixes #5547 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
I think the reason synth succeeds while deploy fails when using HostedZoneFromLookup is that the cdk optimistically assumes a successful lookup. Here's the synth output for domainHostedZone.HostedZoneId() (using Golang): That looks like a placeholder value in case of unsuccessful lookups. In fact, after having fought this for a couple of hours, I think the answer to "why does the zone lookup sometimes fail" in my case is eventual consistency. After deleting and recreating the stack/zone in question a few times, I went for a walk, retried and the zone was now "found". I have not looked into the JS or Golang implementations yet, but I suspect many may be falling victims to the CDK trying to fallback to a dummy zone instead of failing outright. |
I have a hosted zone on route53, and use the following CDK code (
typescript
) to look up that zone usingdomainName
, but got error while runningcdk synth
,cdk diff
andcdk deploy
. After changing to useroute53.HostedZone.fromHostedZoneAttributes()
, it works.Reproduction Steps
Error Log
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: