-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): exportValue does not work on number attributes #19818
Conversation
Number attributes go through two levels of encoding: - L1: because of lack of type information, all attributes are assumed to be `string`s, so we do `Token.asString(new CfnReference(...))`. - L2: we recast select attributes to numbers by doing `Token.asNumber()`. The end result is a Token that looks like: ```ts asNumber(Intrinsic(asString(CfnReference({ 'Fn::GetAtt': [...] })))) ``` When we do `Tokenization.reverse()` on the number, we only reverse the *first* encoding one layer, leaving us with an `Intrinsic` instead of the original `CfnReference`. `exportValue()` then rejects the value as not being the right type of token. Solution: before encoding, try to decode the given value so we always encode the innermost token, and not any of the inbetween ones. Fixes #19537.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Number attributes go through two levels of encoding: - L1: because of lack of type information, all attributes are assumed to be `string`s, so we do `Token.asString(new CfnReference(...))`. - L2: we recast select attributes to numbers by doing `Token.asNumber()`. The end result is a Token that looks like: ```ts asNumber(Intrinsic(asString(CfnReference({ 'Fn::GetAtt': [...] })))) ``` When we do `Tokenization.reverse()` on the number, we only reverse the *first* encoding one layer, leaving us with an `Intrinsic` instead of the original `CfnReference`. `exportValue()` then rejects the value as not being the right type of token. Solution: before encoding, try to decode the given value so we always encode the innermost token, and not any of the inbetween ones. Fixes #19537. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Number attributes go through two levels of encoding: - L1: because of lack of type information, all attributes are assumed to be `string`s, so we do `Token.asString(new CfnReference(...))`. - L2: we recast select attributes to numbers by doing `Token.asNumber()`. The end result is a Token that looks like: ```ts asNumber(Intrinsic(asString(CfnReference({ 'Fn::GetAtt': [...] })))) ``` When we do `Tokenization.reverse()` on the number, we only reverse the *first* encoding one layer, leaving us with an `Intrinsic` instead of the original `CfnReference`. `exportValue()` then rejects the value as not being the right type of token. Solution: before encoding, try to decode the given value so we always encode the innermost token, and not any of the inbetween ones. Fixes aws#19537. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Number attributes go through two levels of encoding:
be
string
s, so we doToken.asString(new CfnReference(...))
.Token.asNumber()
.The end result is a Token that looks like:
When we do
Tokenization.reverse()
on the number, we only reversethe first encoding one layer, leaving us with an
Intrinsic
insteadof the original
CfnReference
.exportValue()
then rejects the valueas not being the right type of token.
Solution: before encoding, try to decode the given value so we always
encode the innermost token, and not any of the inbetween ones.
Fixes #19537.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license