0
votes

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.

1
Do you mean from the cloudformation stack executing it?Jamie Starke

1 Answers

2
votes

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 exemple