Skip to main content
AWS Messaging 1.1.0Last updated in version 1.1.0

Simple Notification Service (SNS) Topic Module

View Source Release Notes

This module makes it easy to deploy a SNS topic along with the publisher and subscriber policies for the topic.

How do I access the SNS topic?​

This module includes several Terraform outputs, including:

  1. topic_name: The Name of the created topic
  2. topic_display_name: The Display Name of the created topic
  3. topic_arn: The ARN of the created topic
  4. topic_policy: The Access policy of the created topic

Sample Usage​

main.tf

# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S SNS MODULE
# ------------------------------------------------------------------------------------------------------

module "sns" {

source = "git::git@github.com:gruntwork-io/terraform-aws-messaging.git//modules/sns?ref=v1.1.0"

# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------

# The name of the SNS topic.
name = <string>

# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------

# A list of IAM ARNs that will be given the rights to publish to the SNS
# topic.
allow_publish_accounts = []

# A list of AWS services that will be given the rights to publish to the SNS
# topic.
allow_publish_services = []

# A list of IAM ARNs that will be given the rights to subscribe to the SNS
# topic.
allow_subscribe_accounts = []

# A list of protocols that are allowed for subscription.
allow_subscribe_protocols = ["http","https","email","email-json","sms","sqs","application","lambda"]

# **Requires `enable_fifo = true`.** Flag to enable content-based
# deduplication for the SNS topic. If set to true, messages with identical
# content will be treated as duplicates and only delivered once. For more see
# the [Amazon
# Docs](https://docs.aws.amazon.com/sns/latest/dg/fifo-message-dedup.html)
content_based_deduplication = null

# Enable or disable creation of the resources of this module.
create_resources = true

# Delivery policy for sns topic.
delivery_policy = null

# The display name of the SNS topic. NOTE: Maximum length is 100 characters.
display_name = ""

# Flag to indicate if the SNS topic is FIFO. This will append `.fifo` to the
# name of the topic.
enable_fifo = false

# **Requires `enable_fifo = true`.** Specifies whether the FIFO topic
# throughput quota applies to the entire topic or per message group. Valid
# values are `Topic` and `MessageGroup`. Only used if `enable_fifo` is set to
# true.
fifo_throughput_scope = null

# ARN of the http failure feedback role - when using delivery policy for sns
# topic.
http_failure_feedback_role_arn = null

# ARN of the http success feedback role - when using delivery policy for sns
# topic.
http_success_feedback_role_arn = null

# The ID of an AWS-managed customer master key (CMK) for Amazon SNS or a
# custom CMK
kms_master_key_id = null

# **Requires `enable_fifo = true`.** The number of days (up to 365) for Amazon
# SNS to retain messages. This will be used to create the archive policy for
# the SNS topic. For more see the [Amazon
# Docs](https://docs.aws.amazon.com/sns/latest/dg/message-archiving-and-replay-topic-owner.html)
message_retention_period = null

# The 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. Valid values: `1`
# (SHA1, default), `2` (SHA256).
signature_version = null

# A map of key value pairs to apply as tags to the SNS topic.
tags = {}

# Tracing mode of an Amazon SNS topic. Valid values: `PassThrough`, `Active`.
tracing_config = null

}


Reference​

Required​

namestringrequired

The name of the SNS topic.

Optional​

allow_publish_accountslist(string)optional

A list of IAM ARNs that will be given the rights to publish to the SNS topic.

[]
allow_publish_serviceslist(string)optional

A list of AWS services that will be given the rights to publish to the SNS topic.

[]
allow_subscribe_accountslist(string)optional

A list of IAM ARNs that will be given the rights to subscribe to the SNS topic.

[]
allow_subscribe_protocolslist(string)optional

A list of protocols that are allowed for subscription.

[
"http",
"https",
"email",
"email-json",
"sms",
"sqs",
"application",
"lambda"
]

Requires enable_fifo = true. Flag to enable content-based deduplication for the SNS topic. If set to true, messages with identical content will be treated as duplicates and only delivered once. For more see the Amazon Docs

null
create_resourcesbooloptional

Enable or disable creation of the resources of this module.

true
delivery_policystringoptional

Delivery policy for sns topic.

null
display_namestringoptional

The display name of the SNS topic. NOTE: Maximum length is 100 characters.

""
enable_fifobooloptional

Flag to indicate if the SNS topic is FIFO. This will append .fifo to the name of the topic.

false
fifo_throughput_scopestringoptional

Requires enable_fifo = true. Specifies whether the FIFO topic throughput quota applies to the entire topic or per message group. Valid values are Topic and MessageGroup. Only used if enable_fifo is set to true.

null

ARN of the http failure feedback role - when using delivery policy for sns topic.

null

ARN of the http success feedback role - when using delivery policy for sns topic.

null
kms_master_key_idstringoptional

The ID of an AWS-managed customer master key (CMK) for Amazon SNS or a custom CMK

null

Requires enable_fifo = true. The number of days (up to 365) for Amazon SNS to retain messages. This will be used to create the archive policy for the SNS topic. For more see the Amazon Docs

null
signature_versionnumberoptional

The 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. Valid values: 1 (SHA1, default), 2 (SHA256).

null
tagsmap(string)optional

A map of key value pairs to apply as tags to the SNS topic.

{}
tracing_configstringoptional

Tracing mode of an Amazon SNS topic. Valid values: PassThrough, Active.

null