Terraform resource: aws sns topic subscription

From wikieduonline
(Redirected from Aws sns topic subscription)
Jump to navigation Jump to search

Official example

resource "aws_sns_topic_subscription" "user_updates_sqs_target" {
 topic_arn = "arn:aws:sns:us-west-2:432981146916:user-updates-topic"
 protocol  = "sqs"
 endpoint  = "arn:aws:sqs:us-west-2:432981146916:terraform-queue-too"
}


Grok example with redrive_policy

resource "aws_sns_topic_subscription" "example_subscription" {
 topic_arn = aws_sns_topic.example_topic.arn
 protocol  = "sqs"  # Example using an SQS queue as the subscriber
 endpoint  = aws_sqs_queue.example_queue.arn  # Subscriber queue ARN

 # Redrive policy specifying the dead-letter queue
 redrive_policy = jsonencode({
   deadLetterTargetArn = aws_sqs_queue.dead_letter_queue.arn
 })

 # Ensure the subscription depends on the DLQ policy being applied
 depends_on = [aws_sqs_queue_policy.dlq_policy]
}

Related

See also

Advertising: