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
API_PutMetricAlarm
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
CDK version used
2.116.0
Environment details (OS name and version, etc.)
macOS 14.2.1
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
API_PutMetricAlarm
Use Case
For cloudwatch alarm action support Lambda now.
Proposed Solution
Now I already used this way to setting AlarmAction to Lambda Function.
I will Create another class like
LambdaAction(alarmLambda)to support it !Other Information
No response
Acknowledgements
CDK version used
2.116.0
Environment details (OS name and version, etc.)
macOS 14.2.1