[aws-resourcegroups] aws-resourcegroups requires an array for tags property but fails CFN stack creation with internal error
See original GitHub issuedescription of the bug:
When adding tags to resource groups I am getting this error:
Error: Invalid tag input expected map of {key: value} have [{"Key":"TagKey","Value":"TagValue"}]
at MapFormatter.parseTags (/Users/amawalte/Downloads/cdk/EBS-SSMMaintenanceWindows/node_modules/@aws-cdk/core/lib/tag-manager.js:81:19)
because the error keeps saying expects map of {key: value} I passed the tags like this:
const rgTags =
{
"Key": "Key",
"Value": "Value"
}
This allowed me to get passed the CDK error, and it started creating the stack, however it failed with the internal error:
✗ sudo cdk deploy --app ssm_maintenance_windows.js EBS-resource-groups-stack
EBS-resource-groups-stack: deploying...
EBS-resource-groups-stack: creating CloudFormation changeset...
0/4 | 12:41:01 PM | CREATE_IN_PROGRESS | AWS::ResourceGroups::Group | RDS-SIT (RDSSIT)
0/4 | 12:41:01 PM | CREATE_IN_PROGRESS | AWS::CDK::Metadata | CDKMetadata
0/4 | 12:41:01 PM | CREATE_IN_PROGRESS | AWS::ResourceGroups::Group | EC2-SIT (EC2SIT)
1/4 | 12:41:02 PM | CREATE_FAILED | AWS::ResourceGroups::Group | RDS-SIT (RDSSIT) Internal Failure
ResourceGroupStack.createResourceGroup (/Users/Amanda/Downloads/cdk/EBS-SSMMaintenanceWindows/lib/resource_groups_stack.js:18:16)
\_ /Users/Amanda/Downloads/cdk/EBS-SSMMaintenanceWindows/lib/resource_groups_stack.js:14:43
\_ Array.forEach (<anonymous>)
\_ new ResourceGroupStack (/Users/Amanda/Downloads/cdk/EBS-SSMMaintenanceWindows/lib/resource_groups_stack.js:13:27)
\_ Object.<anonymous> (/Users/Amanda/Downloads/cdk/EBS-SSMMaintenanceWindows/bin/ssm_maintenance_windows.js:10:28)
\_ Module._compile (internal/modules/cjs/loader.js:1200:30)
\_ Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
\_ Module.load (internal/modules/cjs/loader.js:1049:32)
\_ Function.Module._load (internal/modules/cjs/loader.js:937:14)
\_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
\_ internal/main/run_main_module.js:17:47
2/4 | 12:41:02 PM | CREATE_FAILED | AWS::ResourceGroups::Group | EC2-SIT (EC2SIT) Internal Failure
So I opened the cloudformation stack in designer and changed from:
This:
"Tags": {
"Key": "Key",
"Value": "Value"
}
To This:
"Tags": [
{
"Key": "Key",
"Value": "Value"
}
]
And it created successfully. So, to double check, I went back to the cdk app and changed the code to match what was successful in cloudformation:
class ResourceGroupStack extends cdk.Stack {
constructor(scope, id, resourceGroupList) {
super(scope, id);
this.resourceGroups = [];
const rgTags = [
{
"Key": "TagKey",
"Value": "TagValue"
}
]
And it errored out again:
Error: Invalid tag input expected map of {key: value} have [{"Key":"TagKey","Value":"TagValue"}]
at MapFormatter.parseTags (/Users/amawalte/Downloads/cdk/EBS-SSMMaintenanceWindows/node_modules/@aws-cdk/core/lib/tag-manager.js:81:19)
Based on the above tests, CDK will not take the array, even though that is the only acceptable format for aws::resourcegroups::group . To verify, I checked the cdk code:
class MapFormatter {
parseTags(cfnPropertyTags, priority) {
const tags = [];
if (Array.isArray(cfnPropertyTags) || typeof (cfnPropertyTags) !== 'object') {
throw new Error(`Invalid tag input expected map of {key: value} have ${JSON.stringify(cfnPropertyTags)}`);
}
for (const [key, value] of Object.entries(cfnPropertyTags)) {
tags.push({
key,
value: `${value}`,
priority
});
The above seems to indicate if it it is an array to throw the above error. Ref: https://github.com/aws/aws-cdk/pull/1762/files MapFormatter is the funciton that throws the error based on the output .
Environment
- CLI Version aws --version aws-cli/1.17.10 Python/2.7.16 Darwin/18.7.0 botocore/1.14.10 :
- Framework Version: cdk --version 1.42.0 (build 3b64241)
- Node.js Version: ~ node -v v14.3.0
- OS Mojave 10.14.6 :
- Language (Version):
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Until this is resolved, you can use
addPropertyOverride
to apply the tag to the CFN resource like so:This will produce the following template:
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.