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

Context variable is not found #1911

Closed
spg opened this issue Feb 28, 2019 · 2 comments · Fixed by #1939
Closed

Context variable is not found #1911

spg opened this issue Feb 28, 2019 · 2 comments · Fixed by #1939

Comments

@spg
Copy link
Contributor

spg commented Feb 28, 2019

I am requiring a context variable like so:

this.node.requireContext('env');
const env = this.node.getContext('env');

Using aws-cdk 0.25.0, the env context variable is not found. Using 0.24.1, this was not an issue:

» npx cdk --version
0.25.0 (build 54b5da1)
» npx cdk synth -c env=test

/Users/spgingras/myproject/node_modules/@aws-cdk/cdk/lib/core/construct.ts:243
      throw new Error(`You must supply a context value named '${key}'`);
            ^
Error: You must supply a context value named 'env'
    at ConstructNode.requireContext (/Users/spgingras/myproject/node_modules/@aws-cdk/cdk/lib/core/construct.ts:243:13)
    at new CdkAppStack (/Users/spgingras/myproject/lib/cdk-app-stack.ts:11:15)
    at Object.<anonymous> (/Users/spgingras/myproject/bin/cdk-app.ts:7:1)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:342:17)
Subprocess exited with error 1
» npm i aws-cdk@0.24.1
npm WARN dashboard@0.1.0 No repository field.
npm WARN dashboard@0.1.0 No license field.

+ aws-cdk@0.24.1
added 12 packages from 7 contributors, updated 4 packages and audited 586 packages in 9.536s
found 0 vulnerabilities

» npx cdk --version
0.24.1 (build 67fcf6d)
» npx cdk synth -c env=test
Resources:
[... redacted ...]
@Obirah
Copy link

Obirah commented Mar 1, 2019

Same for me!

@BDQ
Copy link
Contributor

BDQ commented Mar 4, 2019

Confirmed here too, passing context from the CLI is also broken.

rix0rrr added a commit that referenced this issue Mar 4, 2019
Fix issue where context passed in via command-line was ignored.

Migration behavior has been changed: context that looks like it
has been generated by context providers (keys containing ":")
will upon loading be migrated to `cdk.context.json`; other
context in `cdk.json` will be left as-is and treated as readonly.

Fixes #1911.
rix0rrr added a commit that referenced this issue Mar 4, 2019
Fix issue where context passed in via command-line was ignored.

Migration behavior has been changed: context that looks like it
has been generated by context providers (keys containing ":")
will upon loading be migrated to `cdk.context.json`; other
context in `cdk.json` will be left as-is and treated as readonly.

Fixes #1911.
sam-goodwin pushed a commit that referenced this issue Mar 4, 2019
Fix issue where context passed in via command-line was ignored.

Migration behavior has been changed: context that looks like it
has been generated by context providers (keys containing ":")
will upon loading be migrated to `cdk.context.json`; other
context in `cdk.json` will be left as-is and treated as readonly.

Fixes #1911.
sam-goodwin pushed a commit that referenced this issue Mar 4, 2019
Fix issue where context passed in via command-line was ignored.

Migration behavior has been changed: context that looks like it
has been generated by context providers (keys containing ":")
will upon loading be migrated to `cdk.context.json`; other
context in `cdk.json` will be left as-is and treated as readonly.

Fixes #1911.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants