github.com/armen/terraform@v0.5.2-0.20150529052519-caa8117a08f1/website/source/docs/providers/aws/r/sns_topic_subscription.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: sns_topic_subscription" 4 sidebar_current: "docs-aws-resource-sns-topic-subscription" 5 description: |- 6 Provides a resource for subscribing to SNS topics. 7 --- 8 9 # aws\_sns\_topic\_subscription 10 11 Provides a resource for subscribing to SNS topics. Requires that an SNS topic exist for the subscription to attach to. 12 This resource allows you to automatically place messages sent to SNS topics in SQS queues, send them as HTTP(S) POST requests 13 to a given endpoint, send SMS messages, or notify devices / applications. The most likely use case for Terraform users will 14 probably be SQS queues. 15 16 ## Example Usage 17 18 You can directly supply a topic and ARN by hand in the `topic_arn` property along with the queue ARN: 19 20 ``` 21 resource "aws_sns_topic_subscription" "user_updates_sqs_target" { 22 topic_arn = "arn:aws:sns:us-west-2:432981146916:user-updates-topic" 23 protocol = "sqs" 24 endpoint = "arn:aws:sqs:us-west-2:432981146916:terraform-queue-too" 25 } 26 ``` 27 28 Alternatively you can use the ARN properties of a managed SNS topic and SQS queue: 29 30 ``` 31 resource "aws_sns_topic" "user_updates" { 32 name = "user-updates-topic" 33 } 34 35 resource "aws_sqs_queue" "user_updates_queue" { 36 name = "user-updates-queue" 37 } 38 39 resource "aws_sns_topic_subscription" "user_updates_sqs_target" { 40 topic_arn = "${aws_sns_topic.user_updates.arn}" 41 protocol = "sqs" 42 endpoint = "${aws_sqs_queue.user_updates_queue.arn}" 43 } 44 ``` 45 46 47 ## Argument Reference 48 49 The following arguments are supported: 50 51 * `topic_arn` - (Required) The ARN of the SNS topic to subscribe to 52 * `protocol` - (Required) The protocol to use. The possible values for this are: `sqs`, `http`, `https`, `sms`, or `application`. (`email` is an option but unsupported, see below) 53 * `endpoint` - (Required) The endpoint to send data to, the contents will vary with the protocol. (see below for more information) 54 * `raw_message_delivery` - (Optional) Boolean indicating whether or not to enable raw message delivery (the original message is directly passed, not wrapped in JSON with the original message in the message property). 55 56 ### Protocols supported 57 58 Supported SNS protocols include: 59 60 * `http` -- delivery of JSON-encoded message via HTTP POST 61 * `https` -- delivery of JSON-encoded message via HTTPS POST 62 * `sms` -- delivery of message via SMS 63 * `sqs` -- delivery of JSON-encoded message to an Amazon SQS queue 64 * `application` -- delivery of JSON-encoded message to an EndpointArn for a mobile app and device 65 66 Unsupported protocols include the following: 67 68 * `email` -- delivery of message via SMTP 69 * `email-json` -- delivery of JSON-encoded message via SMTP 70 71 These are unsupported because the email address needs to be authorized and does not generate an ARN until the target email address has been validated. This breaks 72 the Terraform model and as a result are not currently supported. 73 74 ### Specifying endpoints 75 76 Endpoints have different format requirements according to the protocol that is chosen. 77 78 * HTTP/HTTPS endpoints will require a URL to POST data to 79 * SMS endpoints are mobile numbers that are capable of receiving an SMS 80 * SQS endpoints come in the form of the SQS queue's ARN (not the URL of the queue) e.g: `arn:aws:sqs:us-west-2:432981146916:terraform-queue-too` 81 * Application endpoints are also the endpoint ARN for the mobile app and device. 82 83 84 ## Attributes Reference 85 86 The following attributes are exported: 87 88 * `id` - The ARN of the subscription 89 * `topic_arn` - The ARN of the topic the subscription belongs to 90 * `protocol` - The protocol being used 91 * `endpoint` - The full endpoint to send data to (SQS ARN, HTTP(S) URL, Application ARN, SMS number, etc.) 92 * `arn` - The ARN of the subscription stored as a more user-friendly property 93