This template creates an SNS topic and an SQS queue, and subscribes the queue to the topic using resource references.

Terraform Template

resource "aws_sns_topic" "user_updates" {
  name = "user-updates-topic"
}

resource "aws_sns_topic_subscription" "user_updates_sqs_target" {
  endpoint = aws_sqs_queue.user_updates_queue.arn
  protocol = "sqs"
  topic_arn = aws_sns_topic.user_updates.arn
}

resource "aws_sqs_queue" "user_updates_queue" {
  name = "user-updates-queue"
}