Complete the code to create an SNS topic named 'MyTopic'.
resource "aws_sns_topic" "example" { name = "[1]" }
The name attribute sets the SNS topic's name. Here, it should be 'MyTopic'.
Complete the code to subscribe an email endpoint to the SNS topic.
resource "aws_sns_topic_subscription" "example" { topic_arn = aws_sns_topic.example.arn protocol = "[1]" endpoint = "user@example.com" }
The protocol for email subscriptions must be set to 'email'.
Fix the error in the subscription code by completing the missing attribute.
resource "aws_sns_topic_subscription" "example" { topic_arn = aws_sns_topic.example.arn protocol = "email" [1] = "user@example.com" }
The correct attribute to specify the destination for the subscription is endpoint.
Fill both blanks to create an SNS topic with display name and subscribe an SMS endpoint.
resource "aws_sns_topic" "example" { name = "[1]" display_name = "[2]" } resource "aws_sns_topic_subscription" "sms_sub" { topic_arn = aws_sns_topic.example.arn protocol = "sms" endpoint = "+1234567890" }
The name is 'AlertsTopic' and the display_name is 'Alerts'.
Fill all three blanks to create an SNS topic, subscribe an HTTP endpoint, and set the subscription's raw message delivery.
resource "aws_sns_topic" "example" { name = "[1]" } resource "aws_sns_topic_subscription" "http_sub" { topic_arn = aws_sns_topic.example.arn protocol = "[2]" endpoint = "https://example.com/notify" raw_message_delivery = [3] }
The topic name is 'WebhookTopic', protocol is 'http', and raw_message_delivery is set to true to send the message as-is.