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
已提問 1 年前檢視次數 58 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南