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
gefragt vor einem Jahr58 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen