Skip to main content

topics

Creates, updates, deletes or gets a topic resource or lists topics in a region

Overview

Nametopics
TypeResource
DescriptionThe ``AWS::SNS::Topic`` resource creates a topic to which notifications can be published.
One account can create a maximum of 100,000 standard topics and 1,000 FIFO topics. For more information, see [endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/sns.html) in the *General Reference*.
The structure of ``AUTHPARAMS`` depends on the .signature of the API request. For more information, see [Examples of the complete Signature Version 4 signing process](https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html) in the *General Reference*.
Idawscc.sns.topics

Fields

NameDatatypeDescription
display_namestringThe display name to use for an SNS topic with SMS subscriptions. The display name must be maximum 100 characters long, including hyphens (-), underscores (_), spaces, and tabs.
kms_master_key_idstringThe ID of an AWS managed customer master key (CMK) for SNS or a custom CMK. For more information, see &#91;Key terms&#93;(https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html#sse-key-terms). For more examples, see &#96;&#96;KeyId&#96;&#96; in the &#42;API Reference&#42;.<br />This property applies only to &#91;server-side-encryption&#93;(https://docs.aws.amazon.com/sns/latest/dg/sns-server-side-encryption.html).
data_protection_policyobjectThe body of the policy document you want to use for this topic.<br />You can only add one policy per topic.<br />The policy must be in JSON string format.<br />Length Constraints: Maximum length of 30,720.
subscriptionarrayThe SNS subscriptions (endpoints) for this topic.<br />If you specify the &#96;&#96;Subscription&#96;&#96; property in the &#96;&#96;AWS::SNS::Topic&#96;&#96; resource and it creates an associated subscription resource, the associated subscription is not deleted when the &#96;&#96;AWS::SNS::Topic&#96;&#96; resource is deleted.
fifo_topicbooleanSet to true to create a FIFO topic.
content_based_deduplicationbooleanEnables content-based deduplication for FIFO topics.<br />+ By default, &#96;&#96;ContentBasedDeduplication&#96;&#96; is set to &#96;&#96;false&#96;&#96;. If you create a FIFO topic and this attribute is &#96;&#96;false&#96;&#96;, you must specify a value for the &#96;&#96;MessageDeduplicationId&#96;&#96; parameter for the &#91;Publish&#93;(https://docs.aws.amazon.com/sns/latest/api/API&#95;Publish.html) action. <br />+ When you set &#96;&#96;ContentBasedDeduplication&#96;&#96; to &#96;&#96;true&#96;&#96;, SNS uses a SHA-256 hash to generate the &#96;&#96;MessageDeduplicationId&#96;&#96; using the body of the message (but not the attributes of the message).<br />(Optional) To override the generated value, you can specify a value for the the &#96;&#96;MessageDeduplicationId&#96;&#96; parameter for the &#96;&#96;Publish&#96;&#96; action.
archive_policyobjectThe archive policy determines the number of days SNS retains messages. You can set a retention period from 1 to 365 days.
fifo_throughput_scopestring
tagsarrayThe list of tags to add to a new topic.<br />To be able to tag a topic on creation, you must have the &#96;&#96;sns:CreateTopic&#96;&#96; and &#96;&#96;sns:TagResource&#96;&#96; permissions.
topic_namestringThe 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 &#96;&#96;.fifo&#96;&#96;.<br />If you don't specify a name, CFN generates a unique physical ID and uses that ID for the topic name. For more information, see &#91;Name type&#93;(https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html).<br />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.
topic_arnstring
signature_versionstringThe signature version corresponds to the hashing algorithm used while creating the signature of the notifications, subscription confirmations, or unsubscribe confirmation messages sent by Amazon SNS. By default, &#96;&#96;SignatureVersion&#96;&#96; is set to &#96;&#96;1&#96;&#96;.
tracing_configstringTracing mode of an SNS topic. By default &#96;&#96;TracingConfig&#96;&#96; is set to &#96;&#96;PassThrough&#96;&#96;, and the topic passes through the tracing header it receives from an SNS publisher to its subscriptions. If set to &#96;&#96;Active&#96;&#96;, SNS will vend X-Ray segment data to topic owner account if the sampled flag in the tracing header is true.
delivery_status_loggingarrayThe &#96;&#96;DeliveryStatusLogging&#96;&#96; configuration enables you to log the delivery status of messages sent from your Amazon SNS topic to subscribed endpoints with the following supported delivery protocols:<br />+ HTTP <br />+ Amazon Kinesis Data Firehose<br />+ AWS Lambda<br />+ Platform application endpoint<br />+ Amazon Simple Queue Service<br /><br />Once configured, log entries are sent to Amazon CloudWatch Logs.
regionstringAWS region.

For more information, see AWS::SNS::Topic.

Methods

NameAccessible byRequired Params
create_resourceINSERTregion
delete_resourceDELETEdata__Identifier, region
update_resourceUPDATEdata__Identifier, data__PatchDocument, region
list_resourcesSELECTregion
get_resourceSELECTdata__Identifier, region

SELECT examples

Gets all properties from an individual topic.

SELECT
region,
display_name,
kms_master_key_id,
data_protection_policy,
subscription,
fifo_topic,
content_based_deduplication,
archive_policy,
fifo_throughput_scope,
tags,
topic_name,
topic_arn,
signature_version,
tracing_config,
delivery_status_logging
FROM awscc.sns.topics
WHERE region = 'us-east-1' AND data__Identifier = '<TopicArn>';

INSERT example

Use the following StackQL query and manifest file to create a new topic resource, using stack-deploy.

/*+ create */
INSERT INTO awscc.sns.topics (
DisplayName,
KmsMasterKeyId,
DataProtectionPolicy,
Subscription,
FifoTopic,
ContentBasedDeduplication,
ArchivePolicy,
FifoThroughputScope,
Tags,
TopicName,
SignatureVersion,
TracingConfig,
DeliveryStatusLogging,
region
)
SELECT
'{{ DisplayName }}',
'{{ KmsMasterKeyId }}',
'{{ DataProtectionPolicy }}',
'{{ Subscription }}',
'{{ FifoTopic }}',
'{{ ContentBasedDeduplication }}',
'{{ ArchivePolicy }}',
'{{ FifoThroughputScope }}',
'{{ Tags }}',
'{{ TopicName }}',
'{{ SignatureVersion }}',
'{{ TracingConfig }}',
'{{ DeliveryStatusLogging }}',
'{{ region }}';

DELETE example

/*+ delete */
DELETE FROM awscc.sns.topics
WHERE data__Identifier = '<TopicArn>'
AND region = 'us-east-1';

Permissions

To operate on the topics resource, the following permissions are required:

Create

sns:CreateTopic,
sns:TagResource,
sns:Subscribe,
sns:GetTopicAttributes,
sns:PutDataProtectionPolicy,
iam:GetRole,
iam:PassRole

Read

sns:GetTopicAttributes,
sns:ListTagsForResource,
sns:ListSubscriptionsByTopic,
sns:GetDataProtectionPolicy

Update

sns:SetTopicAttributes,
sns:TagResource,
sns:UntagResource,
sns:Subscribe,
sns:Unsubscribe,
sns:GetTopicAttributes,
sns:ListTagsForResource,
sns:ListSubscriptionsByTopic,
sns:GetDataProtectionPolicy,
sns:PutDataProtectionPolicy,
iam:GetRole,
iam:PassRole

Delete

sns:GetTopicAttributes,
sns:DeleteTopic

List

sns:ListTopics