CDK Construct Library for Amazon Simple Notification Service Subscriptions
This library provides constructs for adding subscriptions to an Amazon SNS topic.
Subscriptions can be added by calling the .addSubscription(...)
method on the topic.
Subscriptions
Subscriptions can be added to the following endpoints:
- HTTPS
- Amazon SQS
- AWS Lambda
- Email
Create an Amazon SNS Topic to add subscriptions.
import sns = require('@aws-cdk/aws-sns');
const myTopic = new sns.Topic(this, 'MyTopic');
HTTPS
Add an HTTPS Subscription to your topic:
import subscriptions = require('@aws-cdk/aws-sns-subscriptions');
myTopic.addSubscription(new subsscriptions.UrlSubscription('https://foobar.com/'));
Amazon SQS
Subscribe a queue to your topic:
import sqs = require('@aws-cdk/aws-sqs');
import subscriptions = require('@aws-cdk/aws-sns-subscriptions');
const myQueue = new sqs.Queue(this, 'MyQueue');
myTopic.addSubscription(new subsscriptions.SqsSubscription(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.
AWS Lambda
Subscribe an AWS Lambda function to your topic:
import lambda = require('@aws-cdk/aws-lambda');
import subscriptions = require('@aws-cdk/aws-sns-subscriptions');
const myFunction = new lambda.Function(this, 'Echo', {
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_10_X,
code: lambda.Code.fromInline(`exports.handler = ${handler.toString()}`)
});
myTopic.addSubscription(new subscriptions.LambdaSubscription(myFunction));
Email
Subscribe an email address to your topic:
import subscriptions = require('@aws-cdk/aws-sns-subscriptions');
myTopic.addSubscription(new subscriptions.EmailSubscription('foo@bar.com'));
Note that email subscriptions require confirmation by visiting the link sent to the
email address.
1.18.0 (2019-11-25)
General Availability of AWS CDK for .NET and Java!! πππ₯π₯πΎπΎ
We are excited to announce the general availability of support for the .NET family of languages (C#,
F#, ...) as well as Java!
We want to express our gratitude to all of our early customers as well as the amazing contributors
for all the help and support in making this release possible. Thank you for all the feedback
provided during the Developer Preview of .NET and Java support, without which the product would not
be what it is today.
Special thanks go out to a handful of amazing people who have provided instrumental support in
bringing .NET and Java support to this point:
Of course, we continue to be amazed and thrilled by the community contributions we received besides
language support. The passion demonstrated by the CDK community is heartwarming and largely
contributes to making maintaining the CDK an enjoyable, enriching experience!
Features
- lambda: node12.x, python3.8 and java11 runtimes (#5107) (e62f9fb)
- lambda: unlock the lambda environment variables restriction in China regions (#5122) (cc13009)
Bug Fixes
- init/chsarp: correct README for sample-app C# template (#5144) (b2031f6)
- init/sample-app: numerous fixes and additions to the sample-app init templates (#5119) (02c3b05), closes #5130 #5130
- init/java: add -e to mvn command so errors aren't hidden (#5129) (5427106), closes #5128
- init/csharp: .NET semantic fixes for init templates (#5154) (04a1b32)
Known Issues
The following known issues were identified that specifically affect .NET and Java support in the CDK,
and which will be promptly addressed in upcoming CDK releases (in no particular order). See the
GitHub issues for more information and workarounds where applicable.
- .NET and Java: [
aws/jsii#1011
] - abstract members are not marked as such on their .NET and Java representations - .NET: [
aws/jsii#1029
] - user-defined classes implementing CDK interfaces must extend Amazon.Jsii.Runtime.Deputy.DeputyBase
- .NET: [
aws/jsii#1042
] - Parameters typed object accept only primitive types, instances of CDK types, Dictionary<string,?>
- .NET: [
aws/jsii#1044
] - Unable to pass interface instance through in a Dictionary<string,object>
- Java: [
aws/jsii#1034
] - Implementing or overriding overloaded methods in Java does not work consistently - Java: [
aws/jsii#1035
] - Returning Lazy.anyValue
from an method whose return type is java.lang.Object
may result in Resolution Errors - Java: [
aws/jsii#1005
] - property getter implementations (e.g: from an interface) may be ignored