Code Monkey home page Code Monkey logo

machadovilaca / terraform-aws-notifications Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 2.0 32 KB

Terraform AWS module to create a Lambda function that sends notifications to Slack and/or S3 bucket from subscribed SNS topics and/or Cloudwatch log groups

Home Page: https://registry.terraform.io/modules/machadovilaca/notifications/aws/latest

License: GNU General Public License v3.0

Makefile 5.04% HCL 31.09% Python 63.87%
terraform aws sns-topic cloudwatch-events notifications slack s3-bucket aws-notifications

terraform-aws-notifications's Introduction

terraform-aws-notifications

Terraform CI Terraform Version Terraform Module Registry License: GPL

Description

This Terraform module allows you to subscribe to notifications from both SNS topics and Cloudwatch log groups. For each of those, you can select where do you want to send the notifications to. You have the option to target Slack and/or and an S3 bucket.

Subscriptions can be made to any AWS service that sends information to any of the previously described sources. In the following example, you can see the subscription for SNS alerts concerning 'Bounce', 'Complaint' and 'Delivery' from an SES instance, and an alert from Cloudwatch for an SNS mobile message sent.

Message Formating

This module supports all messages sent to the subscribed systems. However, as most alerts have a different structure, if one alert message is not currently supported by this module, the notification text will fallback to the alert raw content. The supported alerts will be pretty-printed as described in the formats folder.

Currently being pretty-printed:

Example Usage

module "notifications" {
  source  = "machadovilaca/notifications/aws"
  version = "0.0.1"

  aws_region = var.aws_region

  slack_webhook_url = "https://hooks.slack.com/services/MI8EILOH9/EECHAHQUOONGAHK2FU4LAIC7IEZ6EIBA8"
  slack_channel     = "#sns-notifications"
  slack_username    = "sns-notifcations"

  s3_bucket_name = "notification-logs"
  create_bucket  = true

  sns_subscripted_topics_arns = {
    (aws_sns_topic.tst_notifications["ses_tst_bounces"].arn) = {
      targets = ["SLACK", "S3"]
    },
    (aws_sns_topic.tst_notifications["ses_tst_complaints"].arn) = {
      targets = ["SLACK", "S3"]
    },
    (aws_sns_topic.tst_notifications["ses_tst_deliveries"].arn) = {
      targets = ["S3"]
    }
  }

  cloudwatch_subscripted_log_group_names = {
    "sns/eu-west-1/12345678954328/DirectPublishToPhoneNumber" = {
      targets = ["SLACK"]
    }
  }
}

Requirements

Name Version
terraform >= 0.12.0
aws >= 3.19

Providers

Name Version
archive n/a
aws >= 3.19
random n/a

Modules

No modules.

Resources

Name Type
aws_iam_role.iam_for_lambda resource
aws_lambda_function.notifications_lambda resource
aws_s3_bucket.s3_bucket resource
random_id.generator resource
archive_file.notifications_lambda data source
aws_caller_identity.current data source

Inputs

Name Description Type Default Required
aws_region AWS region string n/a yes
cloudwatch_subscripted_log_group_names Cloudwatch log groups subscribed to lambda map {} no
create_bucket Should create bucket? bool true no
s3_bucket_name S3 bucket name string n/a yes
slack_channel Slack channel to send notifications to string n/a yes
slack_username Slack username that will publish notifications string n/a yes
slack_webhook_url Slack incoming-webhook url string n/a yes
sns_subscripted_topics_arns SNS topic arns subscribed to lambda map {} no

Outputs

Name Description
arn The ARN of the Lambda function
function_name The name of the Lambda function name
role_name The name of the IAM role attached to the Lambda Function

terraform-aws-notifications's People

Contributors

machadovilaca avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.