Skip to content

Instantly share code, notes, and snippets.

@sihil
Forked from kenoir/sns_subscribe.json
Last active August 29, 2015 14:11
Show Gist options
  • Save sihil/4ad8a1a50e72f39e076f to your computer and use it in GitHub Desktop.
Save sihil/4ad8a1a50e72f39e076f to your computer and use it in GitHub Desktop.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Publish or be damned.",
"Parameters": {
"SubscriberPrincipals": {
"Type": "CommaDelimitedList",
"Description": "Account IDs to allow subscription from."
},
"Stage": {
"Type": "String",
"Description": "Name of stage for topics to create"
}
},
"Resources": {
"LiveSNSTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"TopicName": { "Fn::Join": [ "", ["fc-live-content-", { "Ref" : "Stage" }]]}
}
},
"DraftSNSTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"TopicName": { "Fn::Join": [ "", ["fc-draft-content-", { "Ref" : "Stage" }]]}
}
},
"SNSTopicPolicy": {
"Type": "AWS::SNS::TopicPolicy",
"Properties": {
"PolicyDocument": {
"Version": "2012-10-17",
"Id": "MyTopicSubscribePolicy",
"Statement": [
{
"Sid": "Allow-other-account-to-subscribe-to-live-topic",
"Effect": "Allow",
"Principal": {
"AWS": { "Ref" : "SubscriberPrincipals" }
},
"Action": "sns:Subscribe",
"Resource": {
"Ref": "LiveSNSTopic"
}
},
{
"Sid": "Allow-other-account-to-subscribe-to-draft-topic",
"Effect": "Allow",
"Principal": {
"AWS": { "Ref" : "SubscriberPrincipals" }
},
"Action": "sns:Subscribe",
"Resource": {
"Ref": "DraftSNSTopic"
}
}
]
},
"Topics": [
{ "Ref": "LiveSNSTopic" },
{ "Ref": "DraftSNSTopic" }
]
}
}
},
"Outputs": {
"LiveSNSTopicTopicARN": {
"Value": {
"Ref": "LiveSNSTopic"
}
},
"DraftSNSTopicTopicARN": {
"Value": {
"Ref": "DraftSNSTopic"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment