Skip to content
v2.275.0

SnsAction Class ​

Use an SNS topic as an alarm action.

Example ​

ts
import * as cw_actions from 'aws-cdk-lib/aws-cloudwatch-actions';
declare const alarm: cloudwatch.Alarm;

const topic = new sns.Topic(this, 'Topic');
alarm.addAlarmAction(new cw_actions.SnsAction(topic));
python
import aws_cdk.aws_cloudwatch_actions as cw_actions
# alarm: cloudwatch.Alarm


topic = sns.Topic(self, "Topic")
alarm.add_alarm_action(cw_actions.SnsAction(topic))
java
import software.amazon.awscdk.services.cloudwatch.actions.*;
Alarm alarm;


Topic topic = new Topic(this, "Topic");
alarm.addAlarmAction(new SnsAction(topic));
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.CloudWatch.Actions;
Alarm alarm;


var topic = new Topic(this, "Topic");
alarm.AddAlarmAction(new SnsAction(topic));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import cw_actions "github.com/aws/aws-cdk-go/awscdk"
var alarm Alarm


topic := sns.NewTopic(this, jsii.String("Topic"))
alarm.AddAlarmAction(cw_actions.NewSnsAction(topic))

Initializer ​

ts
new SnsAction(topic: ITopic)
python
SnsAction(topic: ITopic)
java
new SnsAction(ITopic topic)
csharp
new SnsAction(ITopic topic)
go
NewSnsAction(Topic ITopic)

Methods ​

bind(_scope: Construct, _alarm: IAlarm): AlarmActionConfigdef bind(self, _scope: Construct, _alarm: IAlarm) -> AlarmActionConfigpublic AlarmActionConfig bind(Construct _scope, IAlarm _alarm)public AlarmActionConfig Bind(Construct _scope, IAlarm _alarm)func Bind(_scope Construct, _alarm IAlarm) AlarmActionConfig#
Returns an alarm action configuration to use an SNS topic as an alarm action.