Getting empty context when using Python CDK library explicitly without CDK CLI

0

Hello,

In the documentation about Runtime Context it's clearly stated how the context is getting populated from the various sources, however it's unclear how this context is getting populated when I use a Python CDK library explicitly without the CDK CLI. It seems in this case the context is not following what was described in the documentation, that's why I am getting an empty context after tryGetContext calls (for example even ~/.cdk.json is ignored). Having this caveat in mind I'd like to understand what options I have to be able to enrich the context without the CDK CLI helpers? Is there a way to distinguish between a state when my code runs as a sub-process of the CDK CLI and I can rely lets say on existing cdk.json context, or as a standalone application and in this case I have to load it myself in the code?

  • I was able to identify only these three options:

    • to supply the context via CDK_CONTEXT_JSON env. variable (context data might be huge to accommodate everything into one env. variable)
    • to supply the context file location via CONTEXT_OVERFLOW_LOCATION_ENV (has recently been introduced and backported)
    • to supply key-value parameters by calling setContext method
sliva
asked a year ago58 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions