diff --git a/README.md b/README.md index 981c4d3..ba06b91 100644 --- a/README.md +++ b/README.md @@ -246,6 +246,7 @@ Available targets: | [notifications\_enabled](#input\_notifications\_enabled) | Whether or not to setup Slack notifications. Set to `true` to create an SNS topic and Lambda function to send alerts to Slack. | `bool` | `false` | no | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [slack\_channel](#input\_slack\_channel) | The name of the channel in Slack for notifications. Only used when `notifications_enabled` is `true` | `string` | `""` | no | +| [slack\_emoji](#input\_slack\_emoji) | A custom emoji that will appear on Slack messages | `string` | `":amazon-aws:"` | no | | [slack\_username](#input\_slack\_username) | The username that will appear on Slack messages. Only used when `notifications_enabled` is `true` | `string` | `""` | no | | [slack\_webhook\_url](#input\_slack\_webhook\_url) | The URL of Slack webhook. Only used when `notifications_enabled` is `true` | `string` | `""` | no | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | @@ -364,7 +365,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. ## Copyrights -Copyright © 2021-2022 [Cloud Posse, LLC](https://cloudposse.com) +Copyright © 2021-2023 [Cloud Posse, LLC](https://cloudposse.com) diff --git a/docs/terraform.md b/docs/terraform.md index ee56512..988f131 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -55,6 +55,7 @@ | [notifications\_enabled](#input\_notifications\_enabled) | Whether or not to setup Slack notifications. Set to `true` to create an SNS topic and Lambda function to send alerts to Slack. | `bool` | `false` | no | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [slack\_channel](#input\_slack\_channel) | The name of the channel in Slack for notifications. Only used when `notifications_enabled` is `true` | `string` | `""` | no | +| [slack\_emoji](#input\_slack\_emoji) | A custom emoji that will appear on Slack messages | `string` | `":amazon-aws:"` | no | | [slack\_username](#input\_slack\_username) | The username that will appear on Slack messages. Only used when `notifications_enabled` is `true` | `string` | `""` | no | | [slack\_webhook\_url](#input\_slack\_webhook\_url) | The URL of Slack webhook. Only used when `notifications_enabled` is `true` | `string` | `""` | no | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | diff --git a/main.tf b/main.tf index f065ecd..ac9a36e 100644 --- a/main.tf +++ b/main.tf @@ -102,6 +102,7 @@ module "slack_notify_lambda" { slack_webhook_url = var.slack_webhook_url slack_channel = var.slack_channel slack_username = var.slack_username + slack_emoji = var.slack_emoji # underlying module doesn't like when `kms_key_arn` is `null` kms_key_arn = local.create_kms_key ? module.kms_key.key_arn : (var.kms_master_key_id == null ? "" : var.kms_master_key_id) @@ -148,7 +149,9 @@ resource "aws_budgets_budget" "default" { } dynamic "notification" { - for_each = lookup(each.value, "notification", null) != null ? try(tolist(each.value.notification), [each.value.notification]) : [] + for_each = lookup(each.value, "notification", null) != null ? try(tolist(each.value.notification), [ + each.value.notification + ]) : [] content { comparison_operator = notification.value.comparison_operator @@ -156,7 +159,9 @@ resource "aws_budgets_budget" "default" { threshold_type = notification.value.threshold_type notification_type = notification.value.notification_type # use SNS topic when `sns_notification_enabled` is true, otherwise either of these values must be present in budgets.notification object - subscriber_sns_topic_arns = local.notifications_enabled ? [module.sns_topic.sns_topic_arn] : lookup(notification.value, "subscriber_sns_topic_arns", null) + subscriber_sns_topic_arns = local.notifications_enabled ? [ + module.sns_topic.sns_topic_arn + ] : lookup(notification.value, "subscriber_sns_topic_arns", null) subscriber_email_addresses = local.notifications_enabled ? null : lookup(notification.value, "subscriber_email_addresses", null) } } diff --git a/variables.tf b/variables.tf index 04dc097..289fd28 100644 --- a/variables.tf +++ b/variables.tf @@ -55,3 +55,9 @@ variable "slack_username" { description = "The username that will appear on Slack messages. Only used when `notifications_enabled` is `true`" default = "" } + +variable "slack_emoji" { + type = string + description = "A custom emoji that will appear on Slack messages" + default = ":amazon-aws:" +}