TopicSubscription

Provides a resource for subscribing to SNS topics. Requires that an SNS topic exist for the subscription to attach to. This resource allows you to automatically place messages sent to SNS topics in SQS queues, send them as HTTP(S) POST requests to a given endpoint, send SMS messages, or notify devices / applications. The most likely use case will probably be SQS queues.

NOTE: If the SNS topic and SQS queue are in different AWS regions, it is important for the “aws.sns.TopicSubscription” to use an AWS provider that is in the same region of the SNS topic. If the “aws.sns.TopicSubscription” is using a provider with a different region than the SNS topic, the subscription will fail to create.

NOTE: Setup of cross-account subscriptions from SNS topics to SQS queues requires the provider to have access to BOTH accounts.

NOTE: If SNS topic and SQS queue are in different AWS accounts but the same region it is important for the “aws.sns.TopicSubscription” to use the AWS provider of the account with the SQS queue. If “aws.sns.TopicSubscription” is using a Provider with a different account than the SQS queue, the provider creates the subscriptions but does not keep state and tries to re-create the subscription at every apply.

NOTE: If SNS topic and SQS queue are in different AWS accounts and different AWS regions it is important to recognize that the subscription needs to be initiated from the account with the SQS queue but in the region of the SNS topic.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var userUpdatesSqsTarget = new Aws.Sns.TopicSubscription("userUpdatesSqsTarget", new Aws.Sns.TopicSubscriptionArgs
        {
            Endpoint = "arn:aws:sqs:us-west-2:432981146916:queue-too",
            Protocol = "sqs",
            Topic = "arn:aws:sns:us-west-2:432981146916:user-updates-topic",
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/sns"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        _, err := sns.NewTopicSubscription(ctx, "userUpdatesSqsTarget", &sns.TopicSubscriptionArgs{
            Endpoint: pulumi.String("arn:aws:sqs:us-west-2:432981146916:queue-too"),
            Protocol: pulumi.String("sqs"),
            Topic:    pulumi.String("arn:aws:sns:us-west-2:432981146916:user-updates-topic"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

user_updates_sqs_target = aws.sns.TopicSubscription("userUpdatesSqsTarget",
    endpoint="arn:aws:sqs:us-west-2:432981146916:queue-too",
    protocol="sqs",
    topic="arn:aws:sns:us-west-2:432981146916:user-updates-topic")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const userUpdatesSqsTarget = new aws.sns.TopicSubscription("user_updates_sqs_target", {
    endpoint: "arn:aws:sqs:us-west-2:432981146916:queue-too",
    protocol: "sqs",
    topic: "arn:aws:sns:us-west-2:432981146916:user-updates-topic",
});

Create a TopicSubscription Resource

def TopicSubscription(resource_name, opts=None, confirmation_timeout_in_minutes=None, delivery_policy=None, endpoint=None, endpoint_auto_confirms=None, filter_policy=None, protocol=None, raw_message_delivery=None, topic=None, __props__=None);
name string
The unique name of the resource.
args TopicSubscriptionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args TopicSubscriptionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args TopicSubscriptionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

TopicSubscription Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The TopicSubscription resource accepts the following input properties:

Endpoint string

The endpoint to send data to, the contents will vary with the protocol. (see below for more information)

Protocol string

The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).

Topic string

The ARN of the SNS topic to subscribe to

ConfirmationTimeoutInMinutes int

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).

DeliveryPolicy string

JSON String with the delivery policy (retries, backoff, etc.) that will be used in the subscription - this only applies to HTTP/S subscriptions. Refer to the SNS docs for more details.

EndpointAutoConfirms bool

Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)

FilterPolicy string

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.

RawMessageDelivery bool

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) (default is false).

Endpoint string

The endpoint to send data to, the contents will vary with the protocol. (see below for more information)

Protocol string

The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).

Topic interface{}

The ARN of the SNS topic to subscribe to

ConfirmationTimeoutInMinutes int

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).

DeliveryPolicy string

JSON String with the delivery policy (retries, backoff, etc.) that will be used in the subscription - this only applies to HTTP/S subscriptions. Refer to the SNS docs for more details.

EndpointAutoConfirms bool

Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)

FilterPolicy string

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.

RawMessageDelivery bool

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) (default is false).

endpoint string

The endpoint to send data to, the contents will vary with the protocol. (see below for more information)

protocol string

The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).

topic string | Topic

The ARN of the SNS topic to subscribe to

confirmationTimeoutInMinutes number

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).

deliveryPolicy string

JSON String with the delivery policy (retries, backoff, etc.) that will be used in the subscription - this only applies to HTTP/S subscriptions. Refer to the SNS docs for more details.

endpointAutoConfirms boolean

Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)

filterPolicy string

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.

rawMessageDelivery boolean

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) (default is false).

endpoint str

The endpoint to send data to, the contents will vary with the protocol. (see below for more information)

protocol str

The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).

topic string | str

The ARN of the SNS topic to subscribe to

confirmation_timeout_in_minutes float

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).

delivery_policy str

JSON String with the delivery policy (retries, backoff, etc.) that will be used in the subscription - this only applies to HTTP/S subscriptions. Refer to the SNS docs for more details.

endpoint_auto_confirms bool

Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)

filter_policy str

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.

raw_message_delivery bool

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) (default is false).

Outputs

All input properties are implicitly available as output properties. Additionally, the TopicSubscription resource produces the following output properties:

Arn string

The ARN of the subscription stored as a more user-friendly property

Id string
The provider-assigned unique ID for this managed resource.
Arn string

The ARN of the subscription stored as a more user-friendly property

Id string
The provider-assigned unique ID for this managed resource.
arn string

The ARN of the subscription stored as a more user-friendly property

id string
The provider-assigned unique ID for this managed resource.
arn str

The ARN of the subscription stored as a more user-friendly property

id str
The provider-assigned unique ID for this managed resource.

Look up an Existing TopicSubscription Resource

Get an existing TopicSubscription resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: TopicSubscriptionState, opts?: CustomResourceOptions): TopicSubscription
static get(resource_name, id, opts=None, arn=None, confirmation_timeout_in_minutes=None, delivery_policy=None, endpoint=None, endpoint_auto_confirms=None, filter_policy=None, protocol=None, raw_message_delivery=None, topic=None, __props__=None);
func GetTopicSubscription(ctx *Context, name string, id IDInput, state *TopicSubscriptionState, opts ...ResourceOption) (*TopicSubscription, error)
public static TopicSubscription Get(string name, Input<string> id, TopicSubscriptionState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Arn string

The ARN of the subscription stored as a more user-friendly property

ConfirmationTimeoutInMinutes int

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).

DeliveryPolicy string

JSON String with the delivery policy (retries, backoff, etc.) that will be used in the subscription - this only applies to HTTP/S subscriptions. Refer to the SNS docs for more details.

Endpoint string

The endpoint to send data to, the contents will vary with the protocol. (see below for more information)

EndpointAutoConfirms bool

Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)

FilterPolicy string

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.

Protocol string

The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).

RawMessageDelivery bool

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) (default is false).

Topic string

The ARN of the SNS topic to subscribe to

Arn string

The ARN of the subscription stored as a more user-friendly property

ConfirmationTimeoutInMinutes int

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).

DeliveryPolicy string

JSON String with the delivery policy (retries, backoff, etc.) that will be used in the subscription - this only applies to HTTP/S subscriptions. Refer to the SNS docs for more details.

Endpoint string

The endpoint to send data to, the contents will vary with the protocol. (see below for more information)

EndpointAutoConfirms bool

Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)

FilterPolicy string

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.

Protocol string

The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).

RawMessageDelivery bool

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) (default is false).

Topic interface{}

The ARN of the SNS topic to subscribe to

arn string

The ARN of the subscription stored as a more user-friendly property

confirmationTimeoutInMinutes number

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).

deliveryPolicy string

JSON String with the delivery policy (retries, backoff, etc.) that will be used in the subscription - this only applies to HTTP/S subscriptions. Refer to the SNS docs for more details.

endpoint string

The endpoint to send data to, the contents will vary with the protocol. (see below for more information)

endpointAutoConfirms boolean

Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)

filterPolicy string

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.

protocol string

The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).

rawMessageDelivery boolean

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) (default is false).

topic string | Topic

The ARN of the SNS topic to subscribe to

arn str

The ARN of the subscription stored as a more user-friendly property

confirmation_timeout_in_minutes float

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).

delivery_policy str

JSON String with the delivery policy (retries, backoff, etc.) that will be used in the subscription - this only applies to HTTP/S subscriptions. Refer to the SNS docs for more details.

endpoint str

The endpoint to send data to, the contents will vary with the protocol. (see below for more information)

endpoint_auto_confirms bool

Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)

filter_policy str

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.

protocol str

The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).

raw_message_delivery bool

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) (default is false).

topic string | str

The ARN of the SNS topic to subscribe to

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.