AWS Amazon SNS Topic
This page shows how to write Terraform and CloudFormation for Amazon SNS Topic and write them securely.
aws_sns_topic (Terraform)
The Topic in Amazon SNS can be configured in Terraform with the resource name aws_sns_topic. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_sns_topic" "us_east_1" {
count = contains(var.enabled_regions, "us-east-1") ? 1 : 0
name_prefix = "aws-config-notify-us_east_1"
display_name = "AWS Config US-EAST-1"
kms_master_key_id = "alias/aws/sns"
resource "aws_sns_topic" "redshift-diskspace-cloudwatch-alarms-topic-sns" {
name = "redshift-diskspace-cloudwatch-alarms-topic-sns"
}
resource "aws_sns_topic" "redshift-healthstatus-cloudwatch-alarms-topic-sns" {
name = "redshift-healthstatus-cloudwatch-alarms-topic-sns"
resource "aws_sns_topic" "player_progress_topic" {
name = "player-progress-topic"
tags = local.tags
}
resource "aws_sns_topic" "leader_board_topic" {
resource "aws_sns_topic" "test_a" {
name = "test_a"
}
# INVALID: sns topic policy extends permissions to all principals
resource "aws_sns_topic_policy" "invalid_policy_a" {
Parameters
-
application_failure_feedback_role_arnoptional - string -
application_success_feedback_role_arnoptional - string -
application_success_feedback_sample_rateoptional - number -
arnoptional computed - string -
content_based_deduplicationoptional - bool -
delivery_policyoptional - string -
display_nameoptional - string -
fifo_topicoptional - bool -
http_failure_feedback_role_arnoptional - string -
http_success_feedback_role_arnoptional - string -
http_success_feedback_sample_rateoptional - number -
idoptional computed - string -
kms_master_key_idoptional - string -
lambda_failure_feedback_role_arnoptional - string -
lambda_success_feedback_role_arnoptional - string -
lambda_success_feedback_sample_rateoptional - number -
nameoptional computed - string -
name_prefixoptional computed - string -
policyoptional computed - string -
sqs_failure_feedback_role_arnoptional - string -
sqs_success_feedback_role_arnoptional - string -
sqs_success_feedback_sample_rateoptional - number -
tagsoptional - map from string to string
Explanation in Terraform Registry
Provides an SNS topic resource
AWS::SNS::Topic (CloudFormation)
The Topic in SNS can be configured in CloudFormation with the resource name AWS::SNS::Topic. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::SNS::Topic
Properties:
TopicName: hca-text-members
MenTopic:
Type: AWS::SNS::Topic
Properties:
Type: AWS::SNS::Topic
Properties:
DisplayName: DISK_ALERT
TopicName: !Join
- '-'
- - !Ref Environment
Type: AWS::SNS::Topic
Properties:
DisplayName: DISK_ALERT
TopicName: !Join
- '-'
- - !Ref Environment
Type: AWS::SNS::Topic
Properties:
TopicName: !Sub lip-budget-sns-topic-${Env}
Subscription:
- Endpoint: toshiki.hashida@lixil.com
Protocol: email
Type: AWS::SNS::Topic
Properties:
DisplayName: CPP Stage Support
TopicName: cpp-stage-s1-support
Subscription:
- Endpoint: gdp-cpp@seekasia.com
"Type": "AWS::SNS::TopicPolicy",
"Properties": {
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Type" : "AWS::SNS::Topic",
"Properties" : {
"Subscription" : [
{ "Endpoint" : "rick@stackarmor.com", "Protocol" : "email" },
{ "Endpoint" : "terry@stackarmor.com", "Protocol" : "email" },
{ "Endpoint" : "kelley@stackarmor.com", "Protocol" : "email" },
"Type" : "AWS::SNS::Topic",
"Properties" : {
"TopicName" : "Administrators",
"DisplayName" : "Administrators"
}
},
"Type" : "AWS::SNS::Topic",
"Properties" : {
"TopicName" : "Administrators",
"DisplayName" : "Administrators"
}
},
"Type" : "AWS::SNS::Topic",
"Properties" : {
"TopicName" : "Administrators",
"DisplayName" : "Administrators"
}
},
Parameters
-
ContentBasedDeduplicationoptional - Boolean -
DisplayNameoptional - String -
FifoTopicoptional - Boolean -
KmsMasterKeyIdoptional - String -
Subscriptionoptional - List of Subscription -
Tagsoptional - List of Tag -
TopicNameoptional - String
Explanation in CloudFormation Registry
The
AWS::SNS::Topicresource 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 SNS endpoints and quotas in the AWS General Reference.
Frequently asked questions
What is AWS Amazon SNS Topic?
AWS Amazon SNS Topic is a resource for Amazon SNS of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon SNS Topic?
For Terraform, the rhythmictech/terraform-aws-config-multiregion, devopsbynaresh/datalake-alsac and richinmedia/serverless-trivia-game source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the hcamusic/message, jayesh-20/wordpress and sammnike/Test source code examples are useful. See the CloudFormation Example section for further details.