Topic Subscription
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 for provider users will probably be SQS queues.
NOTE: If the SNS topic and SQS queue are in different AWS regions, the
aws.sns.TopicSubscription
must use an AWS provider that is in the same region as the SNS topic. If theaws.sns.TopicSubscription
uses a provider with a different region than the SNS topic, this provider will fail to create the subscription. NOTE: Setup of cross-account subscriptions from SNS topics to SQS queues requires the provider to have access to BOTH accounts. NOTE: If an SNS topic and SQS queue are in different AWS accounts but the same region, theaws.sns.TopicSubscription
must use the AWS provider for the account with the SQS queue. Ifaws.sns.TopicSubscription
uses a Provider with a different account than the SQS queue, this provider creates the subscription but does not keep state and tries to re-create the subscription at everyapply
. NOTE: If an SNS topic and SQS queue are in different AWS accounts and different AWS regions, the subscription needs to be initiated from the account with the SQS queue but in the region of the SNS topic. NOTE: You cannot unsubscribe to a subscription that is pending confirmation. If you useemail-json
, orhttp
/https
(without auto-confirmation enabled), until the subscription is confirmed (e.g., outside of this provider), AWS does not allow this provider to delete / unsubscribe the subscription. If youdestroy
an unconfirmed subscription, this provider will remove the subscription from its state but the subscription will still exist in AWS. However, if you delete an SNS topic, SNS deletes all the subscriptions associated with the topic. Also, you can import a subscription after confirmation and then have the capability to delete it.
Example Usage
You can directly supply a topic and ARN by hand in the topic_arn
property along with the queue ARN:
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.sns.TopicSubscription;
import com.pulumi.aws.sns.TopicSubscriptionArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var userUpdatesSqsTarget = new TopicSubscription("userUpdatesSqsTarget", TopicSubscriptionArgs.builder()
.endpoint("arn:aws:sqs:us-west-2:432981146916:queue-too")
.protocol("sqs")
.topic("arn:aws:sns:us-west-2:432981146916:user-updates-topic")
.build());
}
}
Import
SNS Topic Subscriptions can be imported using the subscription arn
, e.g.,
$ pulumi import aws:sns/topicSubscription:TopicSubscription user_updates_sqs_target arn:aws:sns:us-west-2:0123456789012:my-topic:8a21d249-4329-4871-acc6-7be709c6ea7f
Properties
Integer indicating number of minutes to wait in retrying mode for fetching subscription arn before marking it as failure. Only applicable for http and https protocols. Default is 1
.
Whether the subscription confirmation request was authenticated.
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.
Whether the endpoint is capable of auto confirming subscription (e.g., PagerDuty). Default is false
.
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.
Whether the filter_policy
applies to MessageAttributes
(default) or MessageBody
.
Whether the subscription has not been confirmed.
Whether 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
.
JSON String with the redrive policy that will be used in the subscription. Refer to the SNS docs for more details.
ARN of the IAM role to publish to Kinesis Data Firehose delivery stream. Refer to SNS docs.