Fix: Cfn: non-string parameter values
Motivation
A customer had an issue when they used a non-string Parameter value, e.g.:
Parameters:
MyValue:
Type: Number
Default: 5
When this parameter is used within a Fn::Sub expression:
Value:
Fn::Sub: "my value is ${MyValue}"
it causes an error: Could not resolve {'Ref': 'MyValue'} to terminal value type. This is because we raise an error if any Ref type that we resolve does not eventually resolve to a string. This is limited however, as the parameter value is a number, but really the error should be related to if the ref cannot be resolved beyond a structured type, e.g. dict, list or tuple.
[!WARNING]
The true fix probably involves casting all parameters to strings, but using theTypefor something... Not quite sure yet at this stage. This PR however applies a bandage over the problem so at least this error does not continue to happen. In the future, we should look into proper parameter/ref handling.
Changes
- Only raise the existing exception if we resolve a ref to a structured type.
- Add minimal test that asserts the value is propagaed through the parameter and
Fn::Subinvocation.
LocalStack Community integration with Pro
ββββ2 filesβ Β±0ββββββ2 suitesβ Β±0βββ1h 46m 6s β±οΈ + 3m 1s 3β510 tests +1ββ3β097 β +1ββ413 π€ Β±0ββ0 β Β±0β 3β512 runsβ +1ββ3β097 β +1ββ415 π€ Β±0ββ0 β Β±0β
Results for commit c56aff20.βΒ± Comparison against base commit 62a302ca.
:recycle: This comment has been updated with latest results.