Why isn't Fn::ImportValue allowed in substitutions for DeployTimeSubstitutedFile #29143
Unanswered
amalik01suncor
asked this question in
Q&A
Replies: 1 comment
-
The workaround I have right now is to use this hacky solution for building the substitutions map:
which is really not ideal |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context:
I have two stacks:
Stack A: Creates the Lambda functions and exports the ARNs of the Lambda functions created as part of this stack.
Stack B: Creates a an API Gateway that uses the DeployTimeSubstitutedFile to replace placeholder values for the lambda functions in a Swagger file. For the substitutions I am passing in a dict where each variableName's value is set to the
Fn::ImportValue
that imports the ARNs from the Stack A but I get this error:RuntimeError: Invalid CloudFormation reference. Key must start with any of "Ref" or "Fn::GetAtt" or "Fn::Select". Got {"Fn::ImportValue":"SamLoyaltyPartnerLinksLambdaArn"}
So I looked at the code: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-s3-deployment/lib/render-data.ts#L63
and it only allows:
['Ref', 'Fn::GetAtt', 'Fn::Select']
So i took the synthesized CFN template generated by the CDK and saw that it had the following configuration for the replacements:
That begs the question if Fn::ImportValue is okay as a nested value why isn't it acceptable at the topmost level.
I replaced that with this in the generated template and it worked fine:
Beta Was this translation helpful? Give feedback.
All reactions