Giter Site home page Giter Site logo

alula-net / terraform-aws-notify-slack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pherris/terraform-aws-notify-slack

0.0 1.0 0.0 100 KB

Terraform module which creates SNS topic and Lambda function which sends notifications to Slack

Home Page: https://registry.terraform.io/modules/terraform-aws-modules/notify-slack/aws

License: Other

Python 57.21% HCL 42.01% Makefile 0.78%

terraform-aws-notify-slack's Introduction

AWS Notify Slack Terraform module

This module creates an SNS topic (or uses an existing one) and an AWS Lambda function that sends notifications to Slack using the incoming webhooks API.

Start by setting up an incoming webhook integration in your Slack workspace.

Terraform versions

Terraform 0.12. Pin module version to ~> v2.0. Submit pull-requests to master branch.

Terraform 0.11. Pin module version to ~> v1.0. Submit pull-requests to terraform011 branch.

Features

  • AWS Lambda runtime Python 3.6
  • Create new SNS topic or use existing one
  • Support plaintext and encrypted version of Slack webhook URL
  • Most of Slack message options are customizable
  • Support different types of SNS messages:
  • Local pytest driven testing of the lambda to a Slack sandbox channel

Usage

module "notify_slack" {
  source  = "terraform-aws-modules/notify-slack/aws"
  version = "~> 2.0"

  sns_topic_name = "slack-topic"

  slack_webhook_url = "https://hooks.slack.com/services/AAA/BBB/CCC"
  slack_channel     = "aws-notification"
  slack_username    = "reporter"
}

Use existing SNS topic or create new

If you want to subscribe the AWS Lambda Function created by this module to an existing SNS topic you should specify create_sns_topic = false as an argument and specify the name of existing SNS topic name in sns_topic_name.

Examples

  • notify-slack-simple - Creates SNS topic which sends messages to Slack channel.
  • cloudwatch-alerts-to-slack - End to end example which shows how to send AWS Cloudwatch alerts to Slack channel and use KMS to encrypt webhook URL.

Testing with pytest

To run the tests:

  1. Set up a dedicated slack channel as a test sandbox with it's own webhook. See Slack Incoming Webhooks docs for details.

  2. Make a copy of the sample pytest configuration and edit as needed.

     cp functions/pytest.ini.sample functions/pytest.ini
    
  3. Run the tests:

     pytest functions/notify_slack_test.py
    

Providers

Name Version
archive n/a
aws n/a
null n/a

Inputs

Name Description Type Default Required
cloudwatch_log_group_kms_key_id The ARN of the KMS Key to use when encrypting log data for Lambda string n/a yes
cloudwatch_log_group_retention_in_days Specifies the number of days you want to retain log events in log group for Lambda. number 0 no
cloudwatch_log_group_tags Additional tags for the Cloudwatch log group map(string) {} no
create Whether to create all resources bool true no
create_sns_topic Whether to create new SNS topic bool true no
iam_role_tags Additional tags for the IAM role map(string) {} no
kms_key_arn ARN of the KMS key used for decrypting slack webhook url string "" no
lambda_description The description of the Lambda function string n/a yes
lambda_function_name The name of the Lambda function to create string "notify_slack" no
lambda_function_tags Additional tags for the Lambda function map(string) {} no
log_events Boolean flag to enabled/disable logging of incoming events bool false no
reserved_concurrent_executions The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations number -1 no
slack_channel The name of the channel in Slack for notifications string n/a yes
slack_emoji A custom emoji that will appear on Slack messages string ":aws:" no
slack_username The username that will appear on Slack messages string n/a yes
slack_webhook_url The URL of Slack webhook string n/a yes
sns_topic_name The name of the SNS topic to create string n/a yes
sns_topic_tags Additional tags for the SNS topic map(string) {} no
subsription_filter_policy A valid filter policy that will be used in the subscription to filter messages seen by the target resource string n/a no
tags A map of tags to add to all resources map(string) {} no

Outputs

Name Description
lambda_cloudwatch_log_group_arn The Amazon Resource Name (ARN) specifying the log group
lambda_iam_role_arn The ARN of the IAM role used by Lambda function
lambda_iam_role_name The name of the IAM role used by Lambda function
notify_slack_lambda_function_arn The ARN of the Lambda function
notify_slack_lambda_function_invoke_arn The ARN to be used for invoking Lambda function from API Gateway
notify_slack_lambda_function_last_modified The date Lambda function was last modified
notify_slack_lambda_function_name The name of the Lambda function
notify_slack_lambda_function_version Latest published version of your Lambda function
this_slack_topic_arn The ARN of the SNS topic from which messages will be sent to Slack

Authors

Module managed by Anton Babenko.

License

Apache 2 Licensed. See LICENSE for full details.

terraform-aws-notify-slack's People

Contributors

antonbabenko avatar betajobot avatar nazartm avatar sprutner avatar jonjaques avatar brainsik avatar samjgalbraith avatar ryron01 avatar richardjq avatar doodlemoonch avatar laur1s avatar lalanza808 avatar thejchap avatar jinnko avatar jtribble avatar ilyakochnev avatar fotos avatar arnaldotema avatar alexgottscha avatar

Watchers

James Cloos 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.