Skip to content
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-lib/aws-cloudwatch: Tags don't attach to CloudWatch alarms #25489

Closed
dacampos1 opened this issue May 8, 2023 · 4 comments
Closed

aws-cdk-lib/aws-cloudwatch: Tags don't attach to CloudWatch alarms #25489

dacampos1 opened this issue May 8, 2023 · 4 comments
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2

Comments

@dacampos1
Copy link

Describe the bug

I am trying to add tags to my Cloudwatch Alarm. I am using the Alarm construct from aws-cdk-lib/aws-cloudwatch. The parent stack has a set of default tags that all other resources inherit, except for Cloudwatch Alarms. I have also tried adding tags to this resource manually, but it does not work.

Expected Behavior

Tags can be added to the resource and verified on the AWS console.

Current Behavior

The tags don't attach to the resource.

Reproduction Steps

import * as cdk from 'aws-cdk-lib';
import * as sns from 'aws-cdk-lib/aws-sns';
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
import { Construct } from 'constructs';

export class MyStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    const topic = new sns.Topic(this, 'Topic', {
      displayName: 'My SNS topic',
    });
    const _alarm = new cloudwatch.Alarm(this, 'Alarm', {
      metric: topic.metricNumberOfMessagesPublished(),
      threshold: 10,
      evaluationPeriods: 1,
      alarmName: 'My SNS alarm',
      alarmDescription: 'Triggered when message count exceeds 10',
      comparisonOperator:
        cloudwatch.ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
    });
  }
}

and then

import * as cdk from 'aws-cdk-lib';

const env = {
  account: process.env.AWS_ACCOUNT_ID,
  region: process.env.AWS_REGION,
};
const app = new cdk.App();
new MyStack(app, 'stack', {
  env,
  tags: {
    testTag: 'testValue',
  },
});
cdk.Tags.of(app).add('testTag', 'testValue');

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.76.0

Framework Version

No response

Node.js Version

v16.18.1

OS

13.2.1

Language

Typescript

Language Version

4.8.4

Other information

No response

@dacampos1 dacampos1 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 8, 2023
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label May 8, 2023
@khushail khushail added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label May 8, 2023
@khushail khushail self-assigned this May 8, 2023
@khushail
Copy link
Contributor

khushail commented May 9, 2023

Hi @dacampos1 , as of now Cloudformation does not support adding tags to cloudwatch alarms. This request has been worked upon by the team here.

@khushail khushail removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label May 9, 2023
@khushail khushail removed their assignment May 9, 2023
@khushail khushail added p2 effort/large Large work item – several weeks of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. and removed needs-triage This issue or PR still needs to be triaged. effort/large Large work item – several weeks of effort labels May 9, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@rgoltz
Copy link

rgoltz commented Apr 3, 2024

@dacampos1 - If you have stack-level Tags, you should see Tags are getting propagate to AWS::CloudWatch::Alarm - Please check my test-case and comment here: aws-cloudformation/cloudformation-coverage-roadmap#64 (comment)

@tommyhegarty
Copy link

After the rollout of the tags for CloudWatch Alarms in CloudFormation, this is still bugged in CDK. Stack-level tags are not currently propagating down to Alarms when the template is generated with cdk synth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch bug This issue is a bug. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p2
Projects
None yet
Development

No branches or pull requests

4 participants