Skip to content

feat(cloudwatch): support alarm mute rules#37504

Open
Tietew wants to merge 5 commits intoaws:mainfrom
Tietew:cloudwatch-alarm-mute-rule
Open

feat(cloudwatch): support alarm mute rules#37504
Tietew wants to merge 5 commits intoaws:mainfrom
Tietew:cloudwatch-alarm-mute-rule

Conversation

@Tietew
Copy link
Copy Markdown
Contributor

@Tietew Tietew commented Apr 2, 2026

Issue # (if applicable)

Closes #37502.

Reason for this change

CloudWatch introduced Alarm Mute Rules, enabling us to temporarily mute alarm notifications during planned maintenance downtime, etc.
https://aws.amazon.com/about-aws/whats-new/2026/02/amazon-cloudwatch-alarm-muting-rules/

For details
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/alarm-mute-rules.html

Description of changes

This PR includes:

  • A L2 construct cloudwatch.AlarmMuteRule and prop interface.
  • A convenient class cloudwatch.ScheduleExpression to generate alarm mute rule's schedule expression, inspired by scheduler.ScheduleExpression.
  • A convernient method cloudwatch.Alarm.addAlarmMuteRule().

Basic Usage

declare const alarm1: cloudwatch.IAlarm;
declare const alarm2: cloudwatch.IAlarm;

const alarmMuteRule = new cloudwatch.AlarmMuteRule(this, 'AlarmMuteRule', {
  // target alarms - optional
  alarms: [alarm1],
  // cron-style expression with optional time zone
  schedule: cloudwatch.ScheduleExpression.cron({ minute: '0', hour: '0', timeZone: cdk.TimeZone.ASIA_TOKYO }),
  // one-time schedule with optional time zone
  schedule: cloudwatch.ScheduleExpression.at(new Date(...), cdk.TimeZone.ASIA_TOKYO),
  // duration of mute period
  duration: cdk.Duration.minutes(30),
});

// Alarms can be added after construction
alarmMuteRule.addAlarm(alarm2);

Describe any new or updated permissions being added

No permissions.

Description of how you validated changes

Added unit tests and an integ test.
The integ test has no assertions because assertion cannot verify that nothing happens.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added feature-request A feature should be added or improved. p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Apr 2, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team April 2, 2026 10:34
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
This security report is NOT a review blocker. Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results48 ran48 passed
TestResult
No test annotations available

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
This security report is NOT a review blocker. Please try merge from main to avoid findings unrelated to the PR.


TestsPassed ✅SkippedFailed
Security Guardian Results with resolved templates48 ran48 passed
TestResult
No test annotations available

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 3, 2026
Copy link
Copy Markdown
Contributor

@badmintoncryer badmintoncryer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your nice contribution! I've added two minor comments.

private renderMuteTargets(): CfnAlarmMuteRule.MuteTargetsProperty | undefined {
if (this.alarms.length === 0) {
return undefined;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a validation that verifies the maximum length of the alarms?

https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-cloudwatch-alarmmuterule-mutetargets.html

https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MuteTargets.html

I noticed that there is a difference between these two documents. I think AWS API restriction (100 APIs) is correct but I want you to confirm actual behavior.

}

this.alarmMuteRule = new CfnAlarmMuteRule(this, 'Resource', {
name: props.alarmMuteRuleName,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

distinguished-contributor [Pilot] contributed 50+ PRs to the CDK feature-request A feature should be added or improved. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cloudwatch: Alarm Mute Rules

3 participants