Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/machadovilaca/terraform-aws-notifications
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
https://github.com/machadovilaca/terraform-aws-notifications
aws aws-notifications cloudwatch-events notifications s3-bucket slack sns-topic terraform
Last synced: 24 days ago
JSON representation
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
- Host: GitHub
- URL: https://github.com/machadovilaca/terraform-aws-notifications
- Owner: machadovilaca
- License: gpl-3.0
- Created: 2021-03-22T14:16:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-03-28T22:48:23.000Z (over 3 years ago)
- Last Synced: 2024-05-02T06:05:31.285Z (6 months ago)
- Topics: aws, aws-notifications, cloudwatch-events, notifications, s3-bucket, slack, sns-topic, terraform
- Language: Python
- Homepage: https://registry.terraform.io/modules/machadovilaca/notifications/aws/latest
- Size: 31.3 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-aws-notifications
[![Terraform CI](https://github.com/mvg-org/terraform-aws-notifications/actions/workflows/workflow.yaml/badge.svg)](https://github.com/mvg-org/terraform-aws-notifications/actions/workflows/workflow.yaml)
![Terraform Version](https://img.shields.io/badge/Terraform-0.12+-green.svg)
[![Terraform Module Registry](https://img.shields.io/badge/Terraform%20Module%20Registry-latest-blue.svg)](https://registry.terraform.io/modules/machadovilaca/notifications/aws/latest)
[![License: GPL](https://img.shields.io/badge/License-GPL-green.svg)](https://opensource.org/licenses/GPL-3.0)## 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](files/notifications/formats) folder.Currently being pretty-printed:
- [RDS Notification Messages](files/notifications/formats/rds.py)
- [SES Delivery Status Alerts](files/notifications/formats/ses.py)
- [SMS Deliveries](files/notifications/formats/sms.py)
## 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 = truesns_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](#requirement\_terraform) | >= 0.12.0 |
| [aws](#requirement\_aws) | >= 3.19 |## Providers
| Name | Version |
|------|---------|
| [archive](#provider\_archive) | n/a |
| [aws](#provider\_aws) | >= 3.19 |
| [random](#provider\_random) | n/a |## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [aws_iam_role.iam_for_lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_lambda_function.notifications_lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_s3_bucket.s3_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
| [random_id.generator](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |
| [archive_file.notifications_lambda](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [aws\_region](#input\_aws\_region) | AWS region | `string` | n/a | yes |
| [cloudwatch\_subscripted\_log\_group\_names](#input\_cloudwatch\_subscripted\_log\_group\_names) | Cloudwatch log groups subscribed to lambda | `map` | `{}` | no |
| [create\_bucket](#input\_create\_bucket) | Should create bucket? | `bool` | `true` | no |
| [s3\_bucket\_name](#input\_s3\_bucket\_name) | S3 bucket name | `string` | n/a | yes |
| [slack\_channel](#input\_slack\_channel) | Slack channel to send notifications to | `string` | n/a | yes |
| [slack\_username](#input\_slack\_username) | Slack username that will publish notifications | `string` | n/a | yes |
| [slack\_webhook\_url](#input\_slack\_webhook\_url) | Slack incoming-webhook url | `string` | n/a | yes |
| [sns\_subscripted\_topics\_arns](#input\_sns\_subscripted\_topics\_arns) | SNS topic arns subscribed to lambda | `map` | `{}` | no |## Outputs
| Name | Description |
|------|-------------|
| [arn](#output\_arn) | The ARN of the Lambda function |
| [function\_name](#output\_function\_name) | The name of the Lambda function name |
| [role\_name](#output\_role\_name) | The name of the IAM role attached to the Lambda Function |