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 #29759

Closed
BerradaYassine opened this issue Apr 8, 2024 · 9 comments
Closed
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch @aws-cdk/aws-sns Related to Amazon Simple Notification Service bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@BerradaYassine
Copy link

Describe the bug

#25489 (comment)

Similarly to the closed issue above, I would like to add tags to Cloudwatch alarm through CDK. Recently AWS added support for cloud formation to add tags to Cloudwatch alarm

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.136.0

Framework Version

No response

Node.js Version

v16.18.1

OS

14.4.1

Language

TypeScript

Language Version

4.8.4

Other information

No response

@BerradaYassine BerradaYassine added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 8, 2024
@github-actions github-actions bot added the @aws-cdk/aws-sns Related to Amazon Simple Notification Service label Apr 8, 2024
@BerradaYassine BerradaYassine changed the title (module name): (short issue description) aws-cdk-lib/aws-cloudwatch: Tags don't attach to CloudWatch alarms Apr 8, 2024
@github-actions github-actions bot added the @aws-cdk/aws-cloudwatch Related to Amazon CloudWatch label Apr 8, 2024
@bdoyle0182
Copy link

bdoyle0182 commented Apr 8, 2024

It's officially in the cloud formation release notes now as well

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/ReleaseHistory.html

@khushail
Copy link
Contributor

khushail commented Apr 8, 2024

Thanks @BerradaYassine for requesting this. Thanks @bdoyle0182 for sharing the link.
I could see that cloudformation provides needed support for L1 construct for the 'tags' props.
Contributions from community are welcome !

@khushail khushail added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Apr 8, 2024
@Konosh93
Copy link
Contributor

@khushail
Looks like this will be fixed automatically next Monday., when the following version is deployed.

"@aws-cdk/aws-service-spec": "^0.0.63",

@bdoyle0182
Copy link

Wonderful, thanks for the quick turnaround

@rgoltz
Copy link

rgoltz commented Apr 16, 2024

Great hint, @Konosh93 / @bdoyle0182 - Now, it becomes less magic ;)
I ready see the PR #29798 for updating the L1 CloudFormation resource definitions, which also include:

├[~] service aws-cloudwatch
│ └ resources
│    ├[~] resource AWS::CloudWatch::Alarm
│    │ ├  - tagInformation: undefined
│    │ │  + tagInformation: {"tagPropertyName":"Tags","variant":"standard"}
│    │ └ properties
│    │    └[+] Tags: Array<tag>

Now, we just need to wait for the next CDK release, which cover/include this PR. :)

@jwilson-anonyome
Copy link

@GavinZZ
Copy link
Contributor

GavinZZ commented May 6, 2024

Closing this issue as the feature request for tags now exist in L1 Construct for Cloudwatch alarms.

@GavinZZ GavinZZ closed this as completed May 6, 2024
Copy link

github-actions bot commented May 6, 2024

⚠️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.

@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-cloudwatch Related to Amazon CloudWatch @aws-cdk/aws-sns Related to Amazon Simple Notification Service bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

8 participants