github.com/erriapo/terraform@v0.6.12-0.20160203182612-0340ea72354f/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`,  or `application`. (`email`, `http`, `https`, `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  * `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  * `lambda` -- delivery of JSON-encoded message to a lambda function
    61  * `sqs` -- delivery of JSON-encoded message to an Amazon SQS queue
    62  * `application` -- delivery of JSON-encoded message to an EndpointArn for a mobile app and device
    63  
    64  Unsupported protocols include the following:
    65  
    66  * `email` -- delivery of message via SMTP
    67  * `email-json` -- delivery of JSON-encoded message via SMTP
    68  * `http` -- delivery via HTTP
    69  * `http(s)` -- delivery via HTTPS
    70  * `sms` -- delivery text message
    71  
    72  These are unsupported because the endpoint needs to be authorized and does not 
    73  generate an ARN until the target email address has been validated. This breaks
    74  the Terraform model and as a result are not currently supported.
    75  
    76  ### Specifying endpoints
    77  
    78  Endpoints have different format requirements according to the protocol that is chosen.
    79  
    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