CDK Constructs for AWS SNS
Project description
AWS SNS Construct Library
Add an SNS Topic to your stack:
import sns = require('@aws-cdk/aws-sns');
const topic = new sns.Topic(this, 'Topic', {
displayName: 'Customer subscription topic'
});
Subscriptions
Various subscriptions can be added to the topic by calling the .subscribeXxx()
methods on the
topic.
Add an HTTPS Subscription to your topic:
const myTopic = new sns.Topic(this, 'MyTopic');
myTopic.subscribeUrl('MyHttpsSubscription', 'https://foobar.com/');
Subscribe a queue to the topic:
const topic = new sns.Topic(this, 'MyTopic');
const queue = new sqs.Queue(this, 'MyQueue');
topic.subscribeQueue(queue);
Note that subscriptions of queues in different accounts need to be manually confirmed by reading the initial message from the queue and visiting the link found in it.
CloudWatch Event Rule Target
SNS topics can be used as targets for CloudWatch event rules.
Use the @aws-cdk/aws-events-targets.SnsTopicTarget
:
import targets = require('@aws-cdk/aws-events-targets');
codeCommitRepository.onCommit(new targets.SnsTopicTarget(myTopic));
This will result in adding a target to the event rule and will also modify the topic resource policy to allow CloudWatch events to publish to the topic.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws_cdk.aws_sns-0.30.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bedfff7db6d4b43d61d46afa4a50e92956aa49a286231381a31f39d3f598dd98 |
|
MD5 | 879dd171a282c54970390cbaea81e1c9 |
|
BLAKE2b-256 | 69124416ca1bb13e076a466e1cc8a90dcb0ac9b3ff9f313c43fe355036cd9984 |