token-aware-jsonify: Stringify resolved tokens #406
Merged
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.
token-aware-jsonify
, which is currently used toserialize CloudWatch dashboard configuration into
a JSON string is expected to return a stringified JSON object.
This means that any string within the object must be escaped (e.g. not
include "\n" or quotes).
The function currently stringifies the primary string but this still
leaves room for non-allowed characters in the resolved tokens. For example,
if a token resolves to
{ "Fn::Join": [ "", [ "Hello,\nWorld!" ] ] }
thenthe deploy-time value will be "Hello,\nWorld!" which must be represented
in JSON as "Hello,\nWorld!".
This change eagerly stringifies all string values in the resolved tokens.
Theoretically this might cause trouble in the case where token strings
have special characters AND not emitted, but this seems like a long shot
and we optimize for the common case.