question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot retrieve value from context provider hosted-zone since account/region are not specified at the stack leve

See original GitHub issue

🐛 Bug Report

Need more instructions in readme. First, you need to import modules via npm or yarn. Then, need to get region and account into context.

What is the problem?

cdk deploy causes errors.

Reproduction Steps

aws-cdk-examples/typescript/static-site> cdk synth -c domain=x.com -c subdomain=y l. Either configure “env” with explicit account and region when you define your stack, or use the environment variables “CDK_DEFAULT_ACCOUNT” and “CDK_DEFAULT_REGION” to inherit environment information from the CLI (not recommended for production stacks)

I’ve defined the CDK_ variables in the shell.

Verbose Log

aws-cdk-examples/typescript/static-site/node_modules/@aws-cdk/core/lib/context-provider.js:41 throw new Error(Cannot retrieve value from context provider ${options.provider} since account/region + ^

Error: Cannot retrieve value from context provider hosted-zone since account/region are not specified at the stack level. Either configure “env” with explicit account and region when you define your stack, or use the environment variables “CDK_DEFAULT_ACCOUNT” and “CDK_DEFAULT_REGION” to inherit environment information from the CLI (not recommended for production stacks) at Function.getValue (~/aws-cdk-examples/typescript/static-site/node_modules/@aws-cdk/core/lib/context-provider.js:41:19) at Function.fromLookup (~/aws-cdk-examples/typescript/static-site/node_modules/@aws-cdk/aws-route53/lib/hosted-zone.js:71:49) at new StaticSite (~/aws-cdk-examples/typescript/static-site/static-site.js:21:41) at new MyStaticSiteStack (~/aws-cdk-examples/typescript/static-site/index.js:20:9) at Object.<anonymous> (~/aws-cdk-examples/typescript/static-site/index.js:27:1) at Module._compile (internal/modules/cjs/loader.js:734:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:745:10) at Module.load (internal/modules/cjs/loader.js:626:32) at tryModuleLoad (internal/modules/cjs/loader.js:566:12) at Function.Module._load (internal/modules/cjs/loader.js:558:3) Subprocess exited with error 1

Environment

  • CDK CLI Version: 1.22.0 (build 309ac1b)
  • Example: typescript/static-site
  • Example Version: 1.0.0
  • OS: OSX Mojave
  • Language: TypeScript

Other information

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

23reactions
iamhopaul123commented, May 15, 2020

@amilnayar92 oh seems like it is a route53 problem. HostedZone.fromLookup just doesn’t work for nested stack. We probably are not able to solve it on our end but glad to be informed about the existence of this issue!

7reactions
dillonharlessCOREcommented, Aug 16, 2021

@amilnayar92 oh seems like it is a route53 problem. HostedZone.fromLookup just doesn’t work for nested stack. We probably are not able to solve it on our end but glad to be informed about the existence of this issue!

Really? I feel like this throws a pretty big wrench in the ideal that you can “keep your infrastructure and app code in the same repository”, per the AWS CDK best practices document on AWS’s website…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot retrieve value from context provider ami since account ...
If we pick apart the error, it's saying in order to locate the proper AMIs for your EC2 instances, it needs a region/account...
Read more >
awslabs/aws-cdk - Gitter
jsii.errors.JSIIError : Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level.
Read more >
class ProductStack · AWS CDK
In the form aws://account/region . Use stack.account and stack.region to obtain the specific values, no need to parse. You can use this value...
Read more >
[CDK] Vpc.fromLookup()でエラー 「Cannot retrieve value ...
... でエラー 「Cannot retrieve value from context provider vpc-provider since account/region are not specified at the stack level」が出る.
Read more >
Using AWS CDK to Deploy EventCatalog - martzcodes
... like this Error: Cannot retrieve value from context provider hosted-zone since account/region are not specified at the stack level. when ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found