Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

aws-cdk-core: Tags.of().add fails with INVALID TAG error for CfnInsightRule resource #20103

Closed
prabhaganesh opened this issue Apr 27, 2022 · 4 comments
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1

Comments

@prabhaganesh
Copy link

Describe the bug

I'm adding Tags to all taggable resources in my stack via

Tags.of(stack).add(name, value)

However this fails when I define CfnInsightRule resource in the stack.

Failure in Cloudformation deployment

PutInsightRule for <insight-rule-name> failed; INVALID_TAGS: Tags are invalid. (Service: AmazonCloudWatch; Status Code: 400; Error Code: InvalidParameterValue; Request ID: <request-id>; Proxy: null)

while the Tags were added successfully to all other resources.

The generated Cloudformation template has Insights Rule with tags (they look right and similar to the official documentation)

"Tags": [
          {
            "Key": "TagName",
            "Value": "TagValue"
          }
        ]

I tried adding the Tags manually on a InsightRule in the Console and that works.

Expected Behavior

Tags.of(stack).add(name, value) adds the tag to all resources in the stack including CfnInsightRule

Current Behavior

Tags.of(stack).add(name, value) fails Cloudformation deployment on CfnInsightRule resource

PutInsightRule for <insight-rule-name> failed; INVALID_TAGS: Tags are invalid. (Service: AmazonCloudWatch; Status Code: 400; Error Code: InvalidParameterValue; Request ID: <request-id>; Proxy: null)

Reproduction Steps

Tags.of(stack).add(name, value)
where stack is App containing at least one resource of type CfnInsightRule

Possible Solution

I suspect Tags.of(stack).add(name, value) is adding the tags to CfnInsightRule in the wrong format?

As a workaround I'm excluding InsightRule resources from being tagged

Tags.of(scope).add(
            name,
            value,
            TagProps.builder().excludeResourceTypes(listOf("AWS::CloudWatch::InsightRule")).build()
        )

Additional Information/Context

No response

CDK CLI Version

1.150.0 (build 7ca8212)

Framework Version

No response

Node.js Version

14.x

OS

Amazon Linux 2

Language

Java

Language Version

Java 11

Other information

No response

@prabhaganesh prabhaganesh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 27, 2022
@github-actions github-actions bot added the @aws-cdk/aws-cloudformation Related to AWS CloudFormation label Apr 27, 2022
@ryparker ryparker added p1 effort/small Small work item – less than a day of effort labels Apr 27, 2022
@peterwoodworth peterwoodworth removed the needs-triage This issue or PR still needs to be triaged. label Apr 27, 2022
@rix0rrr
Copy link
Contributor

rix0rrr commented May 23, 2022

The documentation doesn't say what format the tags need to be in (only says "key/value pairs"): https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-insightrule-tags.html

@rix0rrr rix0rrr removed their assignment May 23, 2022
@Jacco
Copy link
Contributor

Jacco commented May 25, 2022

It is strange how different the Tags property is described here:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html

I'm guessing it expects key/value pairs like SAM resources. So in yaml:

  Tags:
    TagKey: TagValue

Are there any other CloudFormation resources that have Tags specified this way?

@github-actions
Copy link

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.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels May 25, 2023
@miloszwatroba
Copy link

This issue is still relevant. It's not possible to use Tags.of() with CfnInsightRule.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

No branches or pull requests

6 participants