Skip to content

Commit

Permalink
update and expose emoji (#15)
Browse files Browse the repository at this point in the history
* update and expose emoji

* Auto Format

Co-authored-by: cloudpossebot <[email protected]>
  • Loading branch information
Benbentwo and cloudpossebot authored Jan 4, 2023
1 parent 9d17ca7 commit 538fca0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Available targets:
| <a name="input_notifications_enabled"></a> [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 |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_slack_channel"></a> [slack\_channel](#input\_slack\_channel) | The name of the channel in Slack for notifications. Only used when `notifications_enabled` is `true` | `string` | `""` | no |
| <a name="input_slack_emoji"></a> [slack\_emoji](#input\_slack\_emoji) | A custom emoji that will appear on Slack messages | `string` | `":amazon-aws:"` | no |
| <a name="input_slack_username"></a> [slack\_username](#input\_slack\_username) | The username that will appear on Slack messages. Only used when `notifications_enabled` is `true` | `string` | `""` | no |
| <a name="input_slack_webhook_url"></a> [slack\_webhook\_url](#input\_slack\_webhook\_url) | The URL of Slack webhook. Only used when `notifications_enabled` is `true` | `string` | `""` | no |
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
Expand Down Expand Up @@ -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)



Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
| <a name="input_notifications_enabled"></a> [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 |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_slack_channel"></a> [slack\_channel](#input\_slack\_channel) | The name of the channel in Slack for notifications. Only used when `notifications_enabled` is `true` | `string` | `""` | no |
| <a name="input_slack_emoji"></a> [slack\_emoji](#input\_slack\_emoji) | A custom emoji that will appear on Slack messages | `string` | `":amazon-aws:"` | no |
| <a name="input_slack_username"></a> [slack\_username](#input\_slack\_username) | The username that will appear on Slack messages. Only used when `notifications_enabled` is `true` | `string` | `""` | no |
| <a name="input_slack_webhook_url"></a> [slack\_webhook\_url](#input\_slack\_webhook\_url) | The URL of Slack webhook. Only used when `notifications_enabled` is `true` | `string` | `""` | no |
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
Expand Down
9 changes: 7 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -148,15 +149,19 @@ 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
threshold = notification.value.threshold
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)
}
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
}

0 comments on commit 538fca0

Please sign in to comment.