-
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
(@aws-cdk/core): CfnMapping overview example throws Template format error: Mappings attribute name 'us-east-1' must contain only alphanumeric characters. #16866
Comments
The CloudFormation documentation describes this behavior:
After changing the structure of the mapping, the example can be deployed: const regionTable = new cdk.CfnMapping(this, 'RegionTable', {
mapping: {
'us-east-1': {
regionName: 'US East (N. Virginia)',
// ...
},
'us-east-2': {
regionName: 'US East (Ohio)',
// ...
},
// ...
}
});
regionTable.findInMap(cdk.Aws.REGION, 'regionName') |
Thank you for the response @jumic. That fix resulted in this new local error now: "throw new Error( |
In which region are you deploying the stack? Did you maintain the mapping for your region (e.g. eu-west-1) in If I'm using my example with value
If this does not resolve your problem, could you please show me your code again? |
I was deploying in us-west-2 region and my code was as follows:
regionTable.findInMap(cdk.Aws.REGION, 'regionName') However, I have since figured out the way CDK will not make a fuss if I want to map the regions as the top key. The code that worked for me is below:
The synthesized mappings section of the template from above code is:
The brackets seem to have solved the non alphanumeric original error. |
In my example, I maintained the mapping only for regions One additional question: Does your code work without squared brackets, too? I copied into my example project and I could deploy it without squared brackets. I have created a pull request which updates the documentation. Therefore, it would be great to know if the squared brackets are mandatory in some cases. |
I had not tried without the brackets. I just deployed without them, and it worked. So it works with or without. Thanks much for the help on getting the documentation fixed. |
The CloudFormation intrinsic function `Fn::FindInMap` only supports alphanumeric characters as name. However, the `CfnMapping` examples in the README file contain hyphens in the name field. This causes an error when the code is deployed. I changed the structure of the examples to create examples that can be deployed in AWS. Fixes #16866. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
The CloudFormation intrinsic function `Fn::FindInMap` only supports alphanumeric characters as name. However, the `CfnMapping` examples in the README file contain hyphens in the name field. This causes an error when the code is deployed. I changed the structure of the examples to create examples that can be deployed in AWS. Fixes aws#16866. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
link to reference doc page
https://docs.aws.amazon.com/cdk/api/latest/docs/core-readme.html#mappings
Describe your issue?
Attempting to define a region template mapping:
However, this is not working as documented. It's throwing this error:
"Template format error: Mappings attribute name 'us-east-1' must contain only alphanumeric characters."
The text was updated successfully, but these errors were encountered: