-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
@aws-cdk/aws-cloudwatch-actionseffort/mediumMedium work item – several days of effortMedium work item – several days of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p2
Description
Describe the feature
Cloudwatch alarm action support Lambda now.
Let's add new alarm action for lambda
https://aws.amazon.com/tw/about-aws/whats-new/2023/12/amazon-cloudwatch-alarms-lambda-change-action/
cfn-cloudwatch-alarm-alarmactions

Use Case
For cloudwatch alarm action support Lambda now.
Proposed Solution
Now I already used this way to setting AlarmAction to Lambda Function.
const alarm = new cdk.aws_cloudwatch.Alarm(this, 'Errors', {
comparisonOperator: cdk.aws_cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD,
threshold: 1,
evaluationPeriods: 1,
metric: alias.metricErrors({period: cdk.Duration.minutes(1)}),
actionsEnabled: true,
treatMissingData: cdk.aws_cloudwatch.TreatMissingData.NOT_BREACHING
});
const sns = new cdk.aws_sns.Topic(this, 'Topic', {
displayName: 'alarmTopic',
});
alarmLambda.addPermission('addCloudWatch', {
principal: new cdk.aws_iam.ServicePrincipal('lambda.alarms.cloudwatch.amazonaws.com'),
sourceAccount: this.account,
sourceArn: alarm.alarmArn,
action: 'lambda:InvokeFunction',
});
alarm.addAlarmAction(new cdk.aws_cloudwatch_actions.SnsAction(sns));
this.node.tryRemoveChild(sns.node.id);
(alarm.node.defaultChild as cdk.aws_cloudwatch.CfnAlarm).addPropertyOverride(
'AlarmActions', [alarmLambda.functionArn]
)
I will Create another class like LambdaAction(alarmLambda)
to support it !
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
2.116.0
Environment details (OS name and version, etc.)
macOS 14.2.1
CaptainDriftwood and tmokmss
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-cloudwatch-actionseffort/mediumMedium work item – several days of effortMedium work item – several days of effortfeature-requestA feature should be added or improved.A feature should be added or improved.p2