(cli): synthesis fails when new context values are parsed #23521
Labels
effort/small
Small work item – less than a day of effort
feature-request
A feature should be added or improved.
p1
package/tools
Related to AWS CDK Tools or CLI
Describe the bug
My cdk app loads values from a SSM parameter using
StringParameter.valueFromLookup()
and uses them as follows. The SSM parameter is created and populated by another team.When the app is synthesized for the first time, it fails with the error
However, this works if I add a
return
statement as below, which allowscdk
to populatecdk.context.json
from SSMOnce
cdk.context.json
is populated, I can remove thereturn
statement and the app works as expected (e.g. it looks up the correctVpc
based on thevpcId
parsed from the SSM parameter value)Expected Behavior
I would expect
cdk
to load the context prior to synthesis so that at synthesis time context is available and can be used for subsequent steps (e.g. like looking up another resource from the context value as in my example).If this is not possible,
valueFromLookup()
can take an optional parameter so that users can pass an arbitrary value to be returned instead of hard-codeddummy-value-...
e.g. if the SSM value contains JSON users would use it as
StringParameter.valueFromLookup(this, /path/to/key, '{}')
or if it's an ARN like in this issue it could be
StringParameter.valueFromLookup(this, /path/to/key, 'arn:aws:iam::111111111:user/xxxx')
Current Behavior
Please see above
Reproduction Steps
Copy the code above and and run
cdk synth
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.5.0 (build 0951122)
Framework Version
No response
Node.js Version
v18.7.0
OS
Mac
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: