Terraform module that builds and deploys a lamdbda function for the
aws-to-slack
package.
This module supports a couple use cases:
- Create the
aws-to-slack
lambda function - Create triggers for the lambda function
To create just the lambda function, use only the variable hook_url
.
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"
}
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
.
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
}
]
}
Name | Description | Type | Default |
---|---|---|---|
hook_url |
Slack webhook URL; see https://api.slack.com/incoming-webhooks | 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 |
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.
event_rules = [
{
name = "" // Optional. Name for the CloudWatch Event rule. Defaults to var.name_<index>
description = "" // Optional. Description for the CloudWatch Event rule. Defaults to "Managed by Terraform"
pattern = "" // Required. JSON object describing events the rule will match.
}
]
This module is maintained by Plus3 IT Systems.
Apache 2 licensed. See the LICENSE.md file for details.
Name | Version |
---|---|
terraform | >= 0.12 |
Name | Version |
---|---|
aws | n/a |
Name | Type |
---|
Name | Description | Type | Default | Required |
---|---|---|---|---|
hook_url | Slack webhook URL; see https://api.slack.com/incoming-webhooks | string |
n/a | yes |
create_sns_topic | (Optional) Creates an SNS topic and subscribes the lambda function; conflicts with sns_topics |
bool |
false |
no |
event_rules | (Optional) List of config maps of CloudWatch Event Rules that will trigger notifications | list(map(string)) |
[] |
no |
lambda | Object of optional attributes passed on to the lambda module | object({ |
{} |
no |
name | (Optional) Name to associate with the lambda function | string |
"aws-to-slack" |
no |
sns_topics | (Optional) List of SNS ARNs the lambda function will be subscribed to; conflicts with create_sns_topic |
list(string) |
[] |
no |
Name | Description |
---|---|
events_rule_arns | ARNs of the CloudWatch Event Rules |
function_arn | The ARN of the Lambda function |
function_name | The name of the Lambda function |
role_arn | The ARN of the IAM role created for the Lambda function |
role_name | The name of the IAM role created for the Lambda function |
sns_topic_arn | ARN of the SNS Topic |
sns_topic_subscription_arns | ARN of the SNS Topic Subscription |