Rakesh Ranjan
Rakesh Ranjan

Reputation: 91

CloudFormation: Publish to SNS topic

I wrote a cloudformation template with this resource to create an SNS topic.

"mySNS" : {
   "Type" : "AWS::SNS::Topic",
   "Properties" : {
      "Subscription" : [
         { "Endpoint" : { "Fn::GetAtt": [ "myLambda", "Arn" ] }, "Protocol" : "lambda" }
      ],
      "TopicName" : "mySNS"
   }
}

Is there a way to publish to this SNS topic from within the template? I can't find anything in CloudFormation template reference http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html.

Upvotes: 1

Views: 3465

Answers (1)

Laurent Jalbert Simard
Laurent Jalbert Simard

Reputation: 6329

Short Answer: no

Long Answer / Workaround: AWS CloudFormation is more about defining resources in AWS than actually using them. However, if publishing in this topic is important for your provisioning process I would suggest you create a lambda-backed custom resource. It would be quite simple for the lambda to then publish to the topic.

If you still need help to get it done I can update my answer with a short example

Upvotes: 3

Related Questions