github.com/jmbataller/terraform@v0.6.8-0.20151125192640-b7a12e3a580c/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 * `lambda` -- delivery of JSON-encoded message to a lambda function 63 * `sms` -- delivery of message via SMS 64 * `sqs` -- delivery of JSON-encoded message to an Amazon SQS queue 65 * `application` -- delivery of JSON-encoded message to an EndpointArn for a mobile app and device 66 67 Unsupported protocols include the following: 68 69 * `email` -- delivery of message via SMTP 70 * `email-json` -- delivery of JSON-encoded message via SMTP 71 72 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 73 the Terraform model and as a result are not currently supported. 74 75 ### Specifying endpoints 76 77 Endpoints have different format requirements according to the protocol that is chosen. 78 79 * HTTP/HTTPS endpoints will require a URL to POST data to 80 * SMS endpoints are mobile numbers that are capable of receiving an SMS 81 * 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` 82 * Application endpoints are also the endpoint ARN for the mobile app and device. 83 84 85 ## Attributes Reference 86 87 The following attributes are exported: 88 89 * `id` - The ARN of the subscription 90 * `topic_arn` - The ARN of the topic the subscription belongs to 91 * `protocol` - The protocol being used 92 * `endpoint` - The full endpoint to send data to (SQS ARN, HTTP(S) URL, Application ARN, SMS number, etc.) 93 * `arn` - The ARN of the subscription stored as a more user-friendly property 94