Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in slack emoji support #11

Merged
merged 7 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 2 additions & 0 deletions functions/notify_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
}

Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down