TopicSubscription

class TopicSubscription : KotlinCustomResource

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 the aws.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, the aws.sns.TopicSubscription must use the AWS provider for the account with the SQS queue. If aws.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 every apply. 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 use email, email-json, or http/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 you destroy 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

Link copied to clipboard
val arn: Output<String>

ARN of the subscription.

Link copied to clipboard

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.

Link copied to clipboard

Whether the subscription confirmation request was authenticated.

Link copied to clipboard
val deliveryPolicy: Output<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.

Link copied to clipboard
val endpoint: Output<String>

Endpoint to send data to. The contents vary with the protocol. See details below.

Link copied to clipboard

Whether the endpoint is capable of auto confirming subscription (e.g., PagerDuty). Default is false.

Link copied to clipboard
val filterPolicy: Output<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.

Link copied to clipboard

Whether the filter_policy applies to MessageAttributes (default) or MessageBody.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val ownerId: Output<String>

AWS account ID of the subscription's owner.

Link copied to clipboard

Whether the subscription has not been confirmed.

Link copied to clipboard
val protocol: Output<String>

Protocol to use. Valid values are: sqs, sms, lambda, firehose, and application. Protocols email, email-json, http and https are also valid but partially supported. See details below.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

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.

Link copied to clipboard
val redrivePolicy: Output<String>?

JSON String with the redrive policy that will be used in the subscription. Refer to the SNS docs for more details.

Link copied to clipboard

ARN of the IAM role to publish to Kinesis Data Firehose delivery stream. Refer to SNS docs.

Link copied to clipboard
val topic: Output<String>

ARN of the SNS topic to subscribe to. The following arguments are optional:

Link copied to clipboard
val urn: Output<String>