AWS::SNS::Topic - AWS CloudFormation

AWS::SNS::Topic

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

Note

One account can create a maximum of 100,000 standard topics and 1,000 FIFO topics. For more information, see Amazon Simple Notification Service endpoints and quotas in the AWS General Reference.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::SNS::Topic", "Properties" : { "ContentBasedDeduplication" : Boolean, "DisplayName" : String, "FifoTopic" : Boolean, "KmsMasterKeyId" : String, "Subscription" : [ Subscription, ... ], "Tags" : [ Tag, ... ], "TopicName" : String } }

YAML

Type: AWS::SNS::Topic Properties: ContentBasedDeduplication: Boolean DisplayName: String FifoTopic: Boolean KmsMasterKeyId: String Subscription: - Subscription Tags: - Tag TopicName: String

Properties

ContentBasedDeduplication

Enables content-based deduplication for FIFO topics.

  • By default, ContentBasedDeduplication is set to false. If you create a FIFO topic and this attribute is false, you must specify a value for the MessageDeduplicationId parameter for the Publish action.

  • When you set ContentBasedDeduplication to true, Amazon SNS uses a SHA-256 hash to generate the MessageDeduplicationId using the body of the message (but not the attributes of the message).

    (Optional) To override the generated value, you can specify a value for the the MessageDeduplicationId parameter for the Publish action.

Required: No

Type: Boolean

Update requires: No interruption

DisplayName

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

Required: No

Type: String

Update requires: No interruption

FifoTopic

Set to true to create a FIFO topic.

Required: No

Type: Boolean

Update requires: Replacement

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

Tags

The list of tags to add to a new topic.

Note

To be able to tag a topic on creation, you must have the sns:CreateTopic and sns:TagResource permissions.

Required: No

Type: List of Tag

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. FIFO topic names must end with .fifo.

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 with two Amazon SQS queue subscriptions

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