AWS CloudFormation
User Guide (Version )

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

AWS::SNS::Topic

The AWS::SNS::Topic resource creates a topic to which notifications can be published.

Note

  • One user can create a maximum of 100,000 topics.

  • This action is idempotent: If the requester already owns a topic with the specified name, that topic's ARN is returned without creating a new 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" : [ Subscription, ... ], "TopicName" : String } }

YAML

Type: AWS::SNS::Topic Properties: DisplayName: String KmsMasterKeyId: String Subscription: - Subscription TopicName: String

Properties

DisplayName

The display name to use for an Amazon SNS topic with SMS subscriptions.

Required: No

Type: String

Update requires: No interruption

KmsMasterKeyId

The ID of an AWS-managed customer master key (CMK) for Amazon SNS or a custom CMK. For more information, see Key Terms. For more examples, see KeyId in the AWS Key Management Service API Reference.

This property applies only to server-side-encryption.

Required: No

Type: String

Update requires: No interruption

Subscription

The SNS subscriptions (endpoints) for this topic.

Required: No

Type: List of Subscription

Update requires: No interruption

TopicName

The name of the topic you want to create. Topic names must include only uppercase and lowercase ASCII letters, numbers, underscores, and hyphens, and must be between 1 and 256 characters long.

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 can't 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

When you pass the logical ID of this resource to the intrinsic Ref function, Ref 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

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

TopicName

Returns the name of an Amazon SNS topic.

Examples

An Amazon SNS topic subscribed to which two Amazon SQS queues are subscribed

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