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

Simple Notification Service (SNS) Topic to Simple Queuing Service (SQS) Connection Module

View Source Release Notes

This module makes it easy to subscribe a SQS to a SNS topic after both have been successfully created.

Managing Queue Policy Separately​

By default, this module creates an SQS queue policy allowing the SNS topic to send messages. Set create_queue_policy = false if you manage the policy elsewhere (e.g., via the sqs module's queue_policy variable).

Sample Usage​

main.tf

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

module "sns_sqs_connection" {

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

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

# The arn of the topic to subscribe to.
sns_topic_arn = <string>

# The queue arn for the Simple Queue Service (SQS).
sqs_arn = <string>

# The queue URL for the Simple Queue Service (SQS).
sqs_queue_url = <string>

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

# Whether to create an SQS queue policy that allows the SNS topic to send
# messages to the SQS queue. Set to false if you are managing the queue policy
# separately (e.g., in the SQS module).
create_queue_policy = true

# (Optional) JSON String with the filter policy that will be used in the
# subscription to filter messages seen by the target resource. Refer to the
# SNS docs for more details
# https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html.
filter_policy = null

# (Optional) Whether the filter_policy applies to MessageAttributes (default)
# or MessageBody.
filter_policy_scope = null

# Whether to enable raw message delivery (the original message is directly
# passed, not wrapped in JSON with the original message in the message
# property)
raw_message_delivery = false

}


Reference​

Required​

sns_topic_arnstringrequired

The arn of the topic to subscribe to.

sqs_arnstringrequired

The queue arn for the Simple Queue Service (SQS).

sqs_queue_urlstringrequired

The queue URL for the Simple Queue Service (SQS).

Optional​

Whether to create an SQS queue policy that allows the SNS topic to send messages to the SQS queue. Set to false if you are managing the queue policy separately (e.g., in the SQS module).

true
filter_policystringoptional

(Optional) JSON String with the filter policy that will be used in the subscription to filter messages seen by the target resource. Refer to the SNS docs for more details https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html.

null
filter_policy_scopestringoptional

(Optional) Whether the filter_policy applies to MessageAttributes (default) or MessageBody.

null

Whether to enable raw message delivery (the original message is directly passed, not wrapped in JSON with the original message in the message property)

false