diff --git a/README.md b/README.md index 2d8e30d5..81e1afb2 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ If you want to subscribe AWS Lambda Function created by this module to an existi | kms_key_arn | ARN of the KMS key used for decrypting slack webhook url | string | `` | no | | lambda_function_name | The name of the Lambda function to create | string | `notify_slack` | no | | slack_channel | The name of the channel in Slack for notifications | string | - | yes | +| slack_emoji | The name of the slack emoji you want to use | string | `:aws:` | no | | slack_username | The username that will appear on Slack on messages | string | - | yes | | slack_webhook_url | The URL of Slack webhook | string | - | yes | | sns_topic_name | The name of the SNS topic to create | string | - | yes | diff --git a/functions/notify_slack.py b/functions/notify_slack.py index 9760e33c..1af201ef 100644 --- a/functions/notify_slack.py +++ b/functions/notify_slack.py @@ -51,10 +51,12 @@ def notify_slack(message, region): slack_channel = os.environ['SLACK_CHANNEL'] slack_username = os.environ['SLACK_USERNAME'] + slack_emoji = os.environ['SLACK_EMOJI'] payload = { "channel": slack_channel, "username": slack_username, + "icon_emoji": slack_emoji, "attachments": [] } if "AlarmName" in message: diff --git a/main.tf b/main.tf index 114e85d6..8cd5f57e 100644 --- a/main.tf +++ b/main.tf @@ -49,6 +49,7 @@ resource "aws_lambda_function" "notify_slack" { SLACK_WEBHOOK_URL = "${var.slack_webhook_url}" SLACK_CHANNEL = "${var.slack_channel}" SLACK_USERNAME = "${var.slack_username}" + SLACK_EMOJI = "${var.slack_emoji}" } } diff --git a/variables.tf b/variables.tf index 9940da82..da02925f 100644 --- a/variables.tf +++ b/variables.tf @@ -24,6 +24,11 @@ variable "slack_username" { description = "The username that will appear on Slack on messages" } +variable "slack_emoji" { + default = ":aws:" + description = "A custom emoji that will appear on slack messages" +} + variable "kms_key_arn" { description = "ARN of the KMS key used for decrypting slack webhook url" default = ""