-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Error: Cannot retrieve value from context provider hosted-zone since account/region are not specified at the stack leve #238
Comments
@kbroughton I think it is because you don't have the default profile in your aws config file. Can you run |
I do have ~/.aws/config and ~/.aws/credentials [default] blocks defined. e.g. for config. I use the keys regularly. I also tried explicitly setting CDK_ vars on the CLI - no luck. |
Here's the guidance that is relevant to your issue. Does this help solve your issue? |
I also experienced this issue receiving the message
I was puzzled when setting the environment variables and getting the same error. It took me a while to figure out I had to do the following new MyDevStack(app, 'dev', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION
}}); as outlined in the guidance provided by @iamhopaul123 |
Thanks @iamhopaul123 and @StraightOuttaCrompton! @kbroughton does that solve your issue? |
Closing this issue since a solution seems to have been found. Feel free to reopen. |
@iamhopaul123 I am still facing this issue even after providing the |
@amilnayar92 can you open another issue and provide more details about the issue you have? |
@iamhopaul123 Two issues open with same errors: aws/aws-cdk#5547 and aws/aws-cdk#4651 |
@amilnayar92 oh seems like it is a route53 problem. |
@iamhopaul123 You've saved me a quintillion hours of debugging. Thanks. |
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... |
🐛 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)/aws-cdk-examples/typescript/static-site/node_modules/@aws-cdk/aws-route53/lib/hosted-zone.js:71:49)at Function.fromLookup (
at new StaticSite (
/aws-cdk-examples/typescript/static-site/static-site.js:21:41)/aws-cdk-examples/typescript/static-site/index.js:20:9)at new MyStaticSiteStack (
at Object. (~/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
Other information
The text was updated successfully, but these errors were encountered: