AWS SNS Construct Library
Add an SNS Topic to your stack:
import sns = require('@aws-cdk/aws-sns');
const topic = new sns.Topic(stack, '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(stack, 'MyTopic');
myTopic.subscribeUrl('MyHttpsSubscription', 'https://foobar.com/');
Subscribe a queue to the topic:
Example of subscribing a queue to a topic
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:
Example of CloudWatch Event rules
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.
0.14.0 (2018-10-26)
IMPORTANT NOTE: when upgrading to this version of the CDK framework, you must also upgrade your installation the CDK Toolkit to the matching version:
$ npm i -g aws-cdk
$ cdk --version
0.14.0 (build ...)
Bug Fixes
Features
BREAKING CHANGES TO EXPERIMENTAL FEATURES
- DynamoDB AutoScaling: Instead of
addReadAutoScaling()
, call autoScaleReadCapacity()
, and similar for write scaling. - CloudFormation resource usage: If you use L1s, you may need to change some
XxxName
properties back into Name
. These will match the CloudFormation property names. - You must use the matching
aws-cdk
toolkit when upgrading to this version, or context providers will cease to work. All existing cached context values in cdk.json
will be invalidated and refreshed.