github.com/jrasell/terraform@v0.6.17-0.20160523115548-2652f5232949/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`, `lambda`, `application`. (`http` or `https` are partially supported, see below) (`email`, `sms`, are options 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 * `endpoint_auto_confirms` - (Optional) Boolean indicating whether the end point is capable of [auto confirming subscription](http://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html#SendMessageToHttp.prepare) e.g., PagerDuty (default is false) 55 * `confirmation_timeout_in_minutes` - (Optional) Integer indicating number of minutes to wait in retying mode for fetching subscription arn before marking it as failure. Only applicable for http and https protocols (default is 1 minute). 56 * `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). 57 58 ### Protocols supported 59 60 Supported SNS protocols include: 61 62 * `lambda` -- delivery of JSON-encoded message to a lambda function 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 Partially supported SNS protocols include: 67 68 * `http` -- delivery of JSON-encoded messages via HTTP. Supported only for the end points that auto confirms the subscription. 69 * `https` -- delivery of JSON-encoded messages via HTTPS. Supported only for the end points that auto confirms the subscription. 70 71 Unsupported protocols include the following: 72 73 * `email` -- delivery of message via SMTP 74 * `email-json` -- delivery of JSON-encoded message via SMTP 75 * `sms` -- delivery text message 76 77 These are unsupported because the endpoint needs to be authorized and does not 78 generate an ARN until the target email address has been validated. This breaks 79 the Terraform model and as a result are not currently supported. 80 81 ### Specifying endpoints 82 83 Endpoints have different format requirements according to the protocol that is chosen. 84 85 * 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` 86 * Application endpoints are also the endpoint ARN for the mobile app and device. 87 88 89 ## Attributes Reference 90 91 The following attributes are exported: 92 93 * `id` - The ARN of the subscription 94 * `topic_arn` - The ARN of the topic the subscription belongs to 95 * `protocol` - The protocol being used 96 * `endpoint` - The full endpoint to send data to (SQS ARN, HTTP(S) URL, Application ARN, SMS number, etc.) 97 * `arn` - The ARN of the subscription stored as a more user-friendly property 98