SnsTopic Class
Use an SNS topic as a target for Amazon EventBridge rules.
If the topic is imported the required permissions to publish to that topic need to be set manually.
Example
ts
/// fixture=withRepoAndTopic
// publish to an SNS topic every time code is committed
// to a CodeCommit repository
repository.onCommit('onCommit', { target: new targets.SnsTopic(topic) });
python
# publish to an SNS topic every time code is committed
# to a CodeCommit repository
repository.on_commit("onCommit", target=targets.SnsTopic(topic))
java
// publish to an SNS topic every time code is committed
// to a CodeCommit repository
repository.onCommit("onCommit", OnCommitOptions.builder().target(new SnsTopic(topic)).build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
// publish to an SNS topic every time code is committed
// to a CodeCommit repository
repository.OnCommit("onCommit", new OnCommitOptions { Target = new SnsTopic(topic) });
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// publish to an SNS topic every time code is committed
// to a CodeCommit repository
repository.onCommit(jsii.String("onCommit"), &OnCommitOptions{
Target: targets.NewSnsTopic(topic),
})
Initializer
ts
new SnsTopic(topic: ITopic, props?: SnsTopicProps)
python
SnsTopic(topic: ITopic, props: typing.Optional[SnsTopicProps] = None)
java
new SnsTopic(ITopic topic, SnsTopicProps props)
csharp
new SnsTopic(ITopic topic, SnsTopicProps? props = null)
go
NewSnsTopic(Topic ITopic, Props SnsTopicProps)
Properties
Methods
bind(rule: IRuleRef, _id?: string): RuleTargetConfigdef bind(self, rule: IRuleRef, _id: typing.Optional[str] = None) -> RuleTargetConfigpublic RuleTargetConfig bind(IRuleRef rule, String _id)public RuleTargetConfig Bind(IRuleRef rule, string? _id = null)func Bind(Rule IRuleRef, _id *string) RuleTargetConfig#Returns a RuleTarget that can be used to trigger this SNS topic as a result from an EventBridge event.