Fix(Intrinsic Resolver): should ignore CFN placeholder in parameter #3824
+176
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue where CloudFormation internal placeholders were being incorrectly resolved during SAM transformation, causing changeset creation failures when using the
--include-nested-stacks
flag.Problem
When creating changesets with
--include-nested-stacks
, CloudFormation passes internal placeholders for cross-references between nested stacks that don't exist yet. These placeholders follow the format:Previously, SAM was resolving these placeholders as regular parameter values, which caused them to be wrapped in arrays for list-type fields. This resulted in CloudFormation validation errors:
Solution
Added a wrapper function
_get_parameter_value()
that checks if a parameter value is a CloudFormation internal placeholderNone
(or a default value) if the parameter value starts with{{IntrinsicFunction:
Updated intrinsic functions to use the wrapper:
RefAction.resolve_parameter_refs()
: Returns the original{"Ref": "ParamName"}
unchanged for placeholdersSubAction.resolve_parameter_refs()
: Keeps the original${ParamName}
reference in Sub strings for placeholdersAdded comprehensive test coverage in
tests/intrinsics/test_resolver.py
to verify:Impact
Before
After
Testing
Ref
andFn::Sub
intrinsic functionsRelated Issues
Fixes the issue where
sam package
followed byaws cloudformation create-change-set --include-nested-stacks
would fail with "Usage of {{IntrinsicFunction:...}} is not allowed" error.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.