» Resource: aws_sns_topic
Provides an SNS topic resource
» Example Usage
resource "aws_sns_topic" "user_updates" {
name = "user-updates-topic"
}
» Example with Delivery Policy
resource "aws_sns_topic" "user_updates" {
name = "user-updates-topic"
delivery_policy = <<EOF
{
"http": {
"defaultHealthyRetryPolicy": {
"minDelayTarget": 20,
"maxDelayTarget": 20,
"numRetries": 3,
"numMaxDelayRetries": 0,
"numNoDelayRetries": 0,
"numMinDelayRetries": 0,
"backoffFunction": "linear"
},
"disableSubscriptionOverrides": false,
"defaultThrottlePolicy": {
"maxReceivesPerSecond": 1
}
}
}
EOF
}
» Example with Server-side encryption (SSE)
resource "aws_sns_topic" "user_updates" {
name = "user-updates-topic"
kms_master_key_id = "alias/aws/sns"
}
» Message Delivery Status Arguments
The <endpoint>_success_feedback_role_arn
and <endpoint>_failure_feedback_role_arn
arguments are used to give Amazon SNS write access to use CloudWatch Logs on your behalf. The <endpoint>_success_feedback_sample_rate
argument is for specifying the sample rate percentage (0-100) of successfully delivered messages. After you configure the <endpoint>_failure_feedback_role_arn
argument, then all failed message deliveries generate CloudWatch Logs.
» Argument Reference
The following arguments are supported:
-
name
- (Optional) The friendly name for the SNS topic. By default generated by Terraform. -
name_prefix
- (Optional) The friendly name for the SNS topic. Conflicts withname
. -
display_name
- (Optional) The display name for the SNS topic -
policy
- (Optional) The fully-formed AWS policy as JSON. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide. -
delivery_policy
- (Optional) The SNS delivery policy. More on AWS documentation -
application_success_feedback_role_arn
- (Optional) The IAM role permitted to receive success feedback for this topic -
application_success_feedback_sample_rate
- (Optional) Percentage of success to sample -
application_failure_feedback_role_arn
- (Optional) IAM role for failure feedback -
http_success_feedback_role_arn
- (Optional) The IAM role permitted to receive success feedback for this topic -
http_success_feedback_sample_rate
- (Optional) Percentage of success to sample -
http_failure_feedback_role_arn
- (Optional) IAM role for failure feedback -
kms_master_key_id
- (Optional) The ID of an AWS-managed customer master key (CMK) for Amazon SNS or a custom CMK. For more information, see Key Terms -
lambda_success_feedback_role_arn
- (Optional) The IAM role permitted to receive success feedback for this topic -
lambda_success_feedback_sample_rate
- (Optional) Percentage of success to sample -
lambda_failure_feedback_role_arn
- (Optional) IAM role for failure feedback -
sqs_success_feedback_role_arn
- (Optional) The IAM role permitted to receive success feedback for this topic -
sqs_success_feedback_sample_rate
- (Optional) Percentage of success to sample -
sqs_failure_feedback_role_arn
- (Optional) IAM role for failure feedback
» Attributes Reference
In addition to all arguments above, the following attributes are exported:
-
id
- The ARN of the SNS topic -
arn
- The ARN of the SNS topic, as a more obvious property (clone of id)
» Import
SNS Topics can be imported using the topic arn
, e.g.
$ terraform import aws_sns_topic.user_updates arn:aws:sns:us-west-2:0123456789012:my-topic