You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use a list value mapping in a CfnOutput, you'll get an error.
# fails to deploy:
# "Template format error: The Value field of every Outputs member must
# evaluate to a String and not a List."
CfnOutput(
self,
"values",
value=mapping.find_in_map(Fn.ref("AWS::Region"), "values")
)
mapping = CfnMapping(self, "Mapping",
mapping={
"us-east-2": { "values": [ "value1", "value2" ] }
},
)
authorizer = aws_apigatewayv2_authorizers.HttpJwtAuthorizer(
"HttpJWTAuthorizer",
"auther",
authorizer_name="JWT-Authorizer",
identity_source=["$request.header.Authorization"],
#jwt_audience=["value1", "value2"], # synth works
jwt_audience=mapping.find_in_map(Fn.ref("AWS::Region"), "values"), # synth does not work
)
Failure message is:
RuntimeError: Passed to parameter props of new aws-cdk-lib.aws_apigatewayv2_authorizers.HttpJwtAuthorizer: Unable to deserialize value as aws-cdk-lib.aws_apigatewayv2_authorizers.HttpJwtAuthorizerProps
├── 🛑 Failing value is an object
│ { '$jsii.struct': [Object] }
╰── 🔍 Failure reason(s):
╰─ Key 'jwtAudience': Unable to deserialize value as array<string>
├── 🛑 Failing value is a string
│ '${Token[TOKEN.15]}'
╰── 🔍 Failure reason(s):
╰─ Value is not an array
Am I wrong in expecting this to work? Since this issue happens at synth, this seems like a CDK issue. I haven't tested it yet in pure cloudformation, but pretty confident it would work.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The documentation for the underlying Cloudformation Mapping says,
If you use a list value mapping in a CfnOutput, you'll get an error.
Clearly the Mapping value is indeed a list.
However, if I try to use it as a list in
aws_cdk.aws_apigatewayv2_authorizers.HttpJwtAuthorizer
, the stack can't even synth.Failure message is:
Am I wrong in expecting this to work? Since this issue happens at synth, this seems like a CDK issue. I haven't tested it yet in pure cloudformation, but pretty confident it would work.
Reproduction: https://github.com/farrellit/cfn-mapping-test/blob/e7815503ceb7487ad722f7ea0a3afe5ed7b03b14/cdk_mapping_test/cdk_mapping_test_stack.py
(Crossposted from https://stackoverflow.com/questions/77836011/aws-cdk-cfnmapping-value-as-list-type-in-aws-cdk-aws-apigatewayv2-authorizers)
Beta Was this translation helpful? Give feedback.
All reactions