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:
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.
I am attempting to parse some context values from the CDK app. The feature was introduced by #1751
My code snippet is:
Which outputs:
However, when I toss a
console.log()inNode.getAllContext(), it prints my context variables:Outputs:
Where
longTermStorageBucketArnis the context I have passed on command line:I also tested it in the constructor of a
Stackobject:both of which produce:
Is this the intended behavior? I don't seem to understand how to get all context from the
appobject, whereasapp.node.getContext(...)works as expected.