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:
- Created 4 years ago
- Reactions:2
- Comments:12 (6 by maintainers)
@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…