AWS::SNS::Topic
The AWS::SNS::Topic type creates an Amazon Simple Notification Service (Amazon SNS) topic.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::SNS::Topic", "Properties" : { "DisplayName" :String, "KmsMasterKeyId" :String, "Subscription" : [SNS Subscription, ...], "TopicName" :String} }
YAML
Type: AWS::SNS::Topic Properties: DisplayName:StringKmsMasterKeyId:StringSubscription: -SNS SubscriptionTopicName:String
Properties
DisplayName-
A developer-defined string that can be used to identify this SNS topic.
Required: No
Type: String
Update requires: No interruption
KmsMasterKeyId-
An AWS KMS key identifier. This can be a key ID, key ARN, or key alias.
Required: No
Type: String
Update requires: No interruption
Subscription-
The SNS subscriptions (endpoints) for this topic.
Required: No
Type: List of SNS Subscriptions
Update requires: No interruption
TopicName-
A name for the topic. If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the topic name. For more information, see Name Type.
Important
If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
Required: No
Type: String
Update requires: Replacement
Return Values
Ref
For the AWS::SNS::Topic resource, the Ref intrinsic
function returns the topic ARN, for example:
arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE.
For more information about using the Ref function, see Ref.
Fn::GetAtt
Fn::GetAtt returns a value for a specified attribute of this type.
The following are the available attributes and sample return values.
TopicName-
Returns the name for an Amazon SNS topic.
For more information about using Fn::GetAtt, see Fn::GetAtt.
Examples
An example of an SNS topic subscribed to by two SQS queues:
JSON
"MySNSTopic" : { "Type" : "AWS::SNS::Topic", "Properties" : { "Subscription" : [ { "Endpoint" : { "Fn::GetAtt" : [ "MyQueue1", "Arn" ] }, "Protocol" : "sqs" }, { "Endpoint" : { "Fn::GetAtt" : [ "MyQueue2", "Arn" ] }, "Protocol" : "sqs" } ], "TopicName" : "SampleTopic" } }
YAML
MySNSTopic: Type: AWS::SNS::Topic Properties: Subscription: - Endpoint: Fn::GetAtt: - "MyQueue1" - "Arn" Protocol: "sqs" - Endpoint: Fn::GetAtt: - "MyQueue2" - "Arn" Protocol: "sqs" TopicName: "SampleTopic"
See Also
-
Using an AWS CloudFormation Template to Create a Topic that Sends Messages to Amazon SQS Queues in the Amazon Simple Notification Service Developer Guide
