https://github.com/plus3it/terraform-aws-slack-notifier
Terraform module that builds and deploys a lamdbda function for the aws-to-slack package.
https://github.com/plus3it/terraform-aws-slack-notifier
Last synced: 5 months ago
JSON representation
Terraform module that builds and deploys a lamdbda function for the aws-to-slack package.
- Host: GitHub
- URL: https://github.com/plus3it/terraform-aws-slack-notifier
- Owner: plus3it
- License: apache-2.0
- Created: 2018-09-13T16:56:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-02-20T03:49:30.000Z (over 1 year ago)
- Last Synced: 2025-02-20T04:29:32.070Z (over 1 year ago)
- Language: HCL
- Homepage:
- Size: 1.43 MB
- Stars: 4
- Watchers: 7
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pullreminders.com?ref=badge)
# terraform-aws-slack-notifier
Terraform module that builds and deploys a lamdbda function for the
[`aws-to-slack`][aws-to-slack] package.
[aws-to-slack]: https://github.com/arabold/aws-to-slack
## Usage
This module supports a couple use cases:
* Create the `aws-to-slack` lambda function
* Create triggers for the lambda function
### Just the aws-to-slack Lambda Function
To create just the lambda function, use only the variable `hook_url`.
```hcl
module "aws-to-slack" {
source = "git::https://github.com/plus3it/terraform-aws-slack-notifier.git"
hook_url = "https://hooks.slack.com/services/your/hook/id"
}
```
### Trigger Notifications from CloudWatch Event Rules
To trigger notifications from CloudWatch Event Rules, use the variable
`event_rules`. This will create the `aws-to-slack` lambda function, the
specified event rule(s), and the trigger, and it will add the necessary
permissions to the lambda function. See the section [Details for `event_rules`](#details-for-event_rules).
```hcl
module "aws-to-slack" {
source = "git::https://github.com/plus3it/terraform-aws-slack-notifier.git"
hook_url = "https://hooks.slack.com/services/your/hook/id"
event_rules = [
{
pattern = <<-PATTERN
{
"detail-type": ["CodeBuild Build State Change"]
"source": ["aws.codebuild"]
}
PATTERN
}
]
}
```
## Variables
| Name | Description | Type | Default |
|------|-------------|:----:|:-------:|
| `hook_url` | Slack webhook URL; see | string | - |
| `name` | (Optional) Name to associate with the lambda function | string | `"aws-to-slack"` |
| `event_rules` | (Optional) List of config maps of CloudWatch Event Rules that will trigger notifications | string | `[]` |
| `sns_trigger` | (Optional) Toggle to control whether to create an SNS topic and subscription for the lambda function | bool | `false` |
### Details for `event_rules`
The `event_rules` variable is a list of config maps. Each map describes an
event rule that will be created. The supported structure is depicted below.
Only the `pattern` key is required. More information on the supported JSON
for the pattern is available in the [Amazon CloudWatch Events documentation][cloudwatch-docs].
[cloudwatch-docs]: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatchEventsandEventPatterns.html
```hcl
event_rules = [
{
name = "" // Optional. Name for the CloudWatch Event rule. Defaults to var.name_
description = "" // Optional. Description for the CloudWatch Event rule. Defaults to "Managed by Terraform"
pattern = "" // Required. JSON object describing events the rule will match.
}
]
```
## Authors
This module is maintained by [Plus3 IT Systems](https://github.com/plus3it).
## License
Apache 2 licensed. See the [LICENSE.md](LICENSE.md) file for details.
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.12 |
## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | n/a |
## Resources
| Name | Type |
|------|------|
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [hook\_url](#input\_hook\_url) | Slack webhook URL; see | `string` | n/a | yes |
| [create\_sns\_topic](#input\_create\_sns\_topic) | (Optional) Creates an SNS topic and subscribes the lambda function; conflicts with `sns_topics` | `bool` | `false` | no |
| [event\_rules](#input\_event\_rules) | (Optional) List of config maps of CloudWatch Event Rules that will trigger notifications | `list(map(string))` | `[]` | no |
| [lambda](#input\_lambda) | Object of optional attributes passed on to the lambda module |
object({
artifacts_dir = optional(string, "builds")
build_in_docker = optional(bool, false)
create_package = optional(bool, true)
ephemeral_storage_size = optional(number)
ignore_source_code_hash = optional(bool, true)
local_existing_package = optional(string)
memory_size = optional(number, 128)
recreate_missing_package = optional(bool, false)
runtime = optional(string, "nodejs22.x")
s3_bucket = optional(string)
s3_existing_package = optional(map(string))
s3_prefix = optional(string)
store_on_s3 = optional(bool, false)
timeout = optional(number, 300)
}) | `{}` | no |
| [name](#input\_name) | (Optional) Name to associate with the lambda function | `string` | `"aws-to-slack"` | no |
| [sns\_topics](#input\_sns\_topics) | (Optional) List of SNS ARNs the lambda function will be subscribed to; conflicts with `create_sns_topic` | `list(string)` | `[]` | no |
## Outputs
| Name | Description |
|------|-------------|
| [events\_rule\_arns](#output\_events\_rule\_arns) | ARNs of the CloudWatch Event Rules |
| [function\_arn](#output\_function\_arn) | The ARN of the Lambda function |
| [function\_name](#output\_function\_name) | The name of the Lambda function |
| [role\_arn](#output\_role\_arn) | The ARN of the IAM role created for the Lambda function |
| [role\_name](#output\_role\_name) | The name of the IAM role created for the Lambda function |
| [sns\_topic\_arn](#output\_sns\_topic\_arn) | ARN of the SNS Topic |
| [sns\_topic\_subscription\_arns](#output\_sns\_topic\_subscription\_arns) | ARN of the SNS Topic Subscription |