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

app.getAllContext() returns empty object #2239

Open
piurafunk opened this issue Apr 25, 2024 · 0 comments
Open

app.getAllContext() returns empty object #2239

piurafunk opened this issue Apr 25, 2024 · 0 comments

Comments

@piurafunk
Copy link

I am attempting to parse some context values from the CDK app. The feature was introduced by #1751

My code snippet is:

const app = new cdk.App();
console.log(app.node.getAllContext());

Which outputs:

{}

However, when I toss a console.log() in Node.getAllContext(), it prints my context variables:

console.log(this._context)

Outputs:

...
  '@aws-cdk/aws-ec2:restrictDefaultSecurityGroup': true,
  '@aws-cdk/aws-apigateway:requestValidatorUniqueId': true,
  longTermStorageBucketArn: 'backups-690e',
  'aws:cdk:enable-path-metadata': true,
  'aws:cdk:enable-asset-metadata': true,
...

Where longTermStorageBucketArn is the context I have passed on command line:

npm run cdk -- -c longTermStorageBucketArn=backups-690e synth

I also tested it in the constructor of a Stack object:

console.log('all context', this.node.getAllContext())
// as well as
console.log('all context', scope.node.getAllContext())

both of which produce:

all context {}

Is this the intended behavior? I don't seem to understand how to get all context from the app object, whereas app.node.getContext(...) works as expected.

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

No branches or pull requests

1 participant