Skip to content

Terraform module to create SNS topics.

License

Notifications You must be signed in to change notification settings

virsas/terraform_sns_topic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform_sns_topic

Terraform module to create SNS topics.

Dependencies

Terraform example

##################
# SNS topic
##################
module "sns_topic_alarms" {
  source = "git::https://github.com/virsas/terraform_sns_topic.git?ref=v1.0.0"
  name = "alarms"
  kms = module.kms-sns.arn
}

Policies

You require to create two polices located in ./json/sns directory

Access policy

# Path 
./json/sns_access/NAME.json

Name is the same as the name of the SNS topic

{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "AWS": "*" },
      "Action": [
        "SNS:GetTopicAttributes",
        "SNS:SetTopicAttributes",
        "SNS:AddPermission",
        "SNS:RemovePermission",
        "SNS:DeleteTopic",
        "SNS:Subscribe",
        "SNS:ListSubscriptionsByTopic",
        "SNS:Publish"
      ],
      "Resource": "arn:aws:sns:eu-west-1:123456789012:alarms",
      "Condition": { "StringEquals": { "AWS:SourceOwner": "123456789012" } }
    }
  ]
}

123456789012 is the ID of your account.

Delivery policy

# Path 
./json/sns_delivery/NAME.json

Name is the same as the name of the SNS topic

{
  "http": {
    "defaultHealthyRetryPolicy": {
      "minDelayTarget": 20,
      "maxDelayTarget": 20,
      "numRetries": 3,
      "numMaxDelayRetries": 0,
      "numNoDelayRetries": 0,
      "numMinDelayRetries": 0,
      "backoffFunction": "linear"
    },
    "disableSubscriptionOverrides": false
  }
}

You can play with the configuration as per your needs.