Is it possible to create a 'Subscription' resource in a AWS CloudFormation JSON template without creating a new AWS::SNS::Topic
?
In my case, the topic is created outside of the CloudFormation script, and I would like to create some subscriptions to it, involving resources created within the script.
I.E.
"DbfExtractQueue": {
"Type": "AWS::SQS::Queue"
},
"EtlSubscription": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": { "Fn::GetAtt": ["DbfExtractQueue", "Arn"] },
"Protocol": "sqs",
"TopicArn": { "Ref": "EtlNotificationTopicARN" }
}
},
The EtlNotificationTopicARN is passed into the script and represents a SNS topic ARN.
The entities that can subscribe to your SNS topics can be: "Everyone" (anonymous access), users whose endpoint URL, protocol, email address or ARN from a "Subscribe" request match a certain value, specific AWS users or resources and the topic owner.
SNS FIFO topics can further unlock application integration use cases that require large ordered fan-out, up to 100 subscribers.
Amazon DynamoDB is not a supported Amazon SNS protocol. 2.
You specify the endpoint using its URL. To subscribe to a topic, you can use the Amazon SNS console, the sns-subscribe command, or the Subscribe API action.
It is now possible to do this directly in native CloudFormation as of November 2016:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html
Samples from the above documentation.
YAML:
MySubscription:
Type: AWS::SNS::Subscription
Properties:
Endpoint: [email protected]
Protocol: email
TopicArn: !Ref 'MySNSTopic'
JSON:
"MySubscription" : {
"Type" : "AWS::SNS::Subscription",
"Properties" : {
"Endpoint" : "[email protected]",
"Protocol" : "email",
"TopicArn" : {"Ref" : "MySNSTopic"}
}
}
It is possible now since CloudFormation supports Custom Resource Types with Lambda functions.
I've created a gist here with CloudFormation tamplate: https://gist.github.com/martinssipenko/4d7b48a3d6a6751e7464.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With