Skip to content

Latest commit

 

History

History
91 lines (77 loc) · 3.69 KB

README.md

File metadata and controls

91 lines (77 loc) · 3.69 KB

AWS SNS Topic Module

This module creates AWS SNS Topic.

Example

# main.tf
module "sns_topic" {
  source = "git::https://github.com/lpavliuk/Terraform-Modules.git//aws_sns_topic"

  name              = "slack-channel"
  subscriptions     = [
    { # Slack channel : "infra-alerts"
      protocol = "email"
      endpoint = "example@slack.com"
    }
  ]

  policy_statements = [
    {
      sid     = "AllowManageSNS"
      effect  = "Allow"
      actions = [
        "SNS:Subscribe",
        "SNS:Publish",
        "SNS:ListSubscriptionsByTopic",
        "SNS:GetTopicAttributes"
      ]
      principals = {
        type        = "AWS"
        identifiers = ["*"]
      }
      condition  = {
        test     = "StringEquals"
        variable = "AWS:SourceOwner"
        values   = ["<AWS_ACCOUNT_ID>"]
      }
    },
    {
      sid     = "AllowBackupSNS"
      effect  = "Allow"
      actions = [
        "SNS:Publish",
      ]
      principals = {
        type        = "Service"
        identifiers = ["backup.amazonaws.com"]
      }
    }
  ]
}

Requirements

Name Version
terraform < 2.0.0, >= 1.6.6
aws < 6.0, >= 5.22

Inputs

Name Description Type Default Required
name Topic Name string n/a yes
policy_statements Policy Statements of the SNS Topic
list(object({
sid = string
actions = list(string)
effect = string
principals = optional(object({
type = string
identifiers = list(string)
}))
condition = optional(object({
test = string
variable = string
values = list(string)
}))
}))
n/a yes
subscriptions Subscriptions for the SNS Topic. Available protocol values:
- sqs
- sms
- lambda
- firehose
- application
- email
- email-json
- http
- https

More details...
list(object({
protocol = string
endpoint = string
}))
[] no

Outputs

Name Description
id Topic ID
arn Topic ARN
name Topic Name
subscriptions Topic Subscriptions

Resources

Name Type
aws_sns_topic.this resource
aws_sns_topic_policy.this resource
aws_sns_topic_subscription.this resource
aws_caller_identity.current data source
aws_iam_policy_document.sns_topic_policy data source