adding sns-email-topic module

ctalarms-whitelist
lalanza808 4 years ago
parent f2b87eb44d
commit aeb0c5c5f7

@ -0,0 +1,20 @@
# SNS Email Topic
Create an SNS topic that uses Email based notifications.
## Usage
```
module "sns_email_topic" {
source = "github.com/lalanza808/tf-modules.git/monitoring/sns-email-topic"
sns_emails = ["email1@asd.com", "email2@asd.com"]
}
```
## Inputs
You don't need to provide any inputs, but you can override all of the defaults. See the full list of inputs here: [variables.tf](./variables.tf)
## Outputs
[output.tf](./output.tf)

@ -0,0 +1,4 @@
{
"Endpoint" : "${email_address}",
"Protocol" : "email"
}

@ -0,0 +1,21 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources" : {
"EmailSNSTopic": {
"Type" : "AWS::SNS::Topic",
"Properties" : {
"DisplayName" : "${display_name}",
"Subscription": [
${endpoints}
]
}
}
},
"Outputs" : {
"TopicARN" : {
"Description" : "Email SNS Topic ARN",
"Value" : { "Ref" : "EmailSNSTopic" }
}
}
}

@ -0,0 +1,23 @@
data "template_file" "endpoints" {
template = "${file("${path.module}/files/email-endpoint-list.json.tpl")}"
count = "${length(var.sns_emails)}"
vars = {
email_address = "${element(var.sns_emails, count.index)}"
}
}
data "template_file" "sns_stack" {
template = "${file("${path.module}/files/email-sns-stack.json.tpl")}"
vars = {
endpoints = "${join(",", data.template_file.endpoints.*.rendered)}"
display_name = "${var.prefix}-sns-email"
}
}
resource "aws_cloudformation_stack" "sns_stack" {
name = "${var.prefix}-sns-email"
template_body = "${data.template_file.sns_stack.rendered}"
tags = var.tags
}

@ -0,0 +1,3 @@
output "topic_arn" {
value = aws_cloudformation_stack.sns_stack.outputs["TopicARN"]
}

@ -0,0 +1,13 @@
variable "sns_emails" {
type = list
default = []
}
variable "tags" {
default = {}
type = map
description = "Optional tag mapping to apply to the infrastructure"
}
variable "prefix" {
default = "monitoring"
description = "String to prefix to all resources"
}
Loading…
Cancel
Save