Skip to content

Commit

Permalink
feat: adding the ability source the username from the configuration (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
gambol99 authored Apr 26, 2024
1 parent 0db8855 commit a15c328
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ The `terraform-docs` utility is used to generate this README. Follow the below s
2. Fetch the `terraform-docs` binary (https://terraform-docs.io/user-guide/installation/)
3. Run `terraform-docs markdown table --output-file ${PWD}/README.md --output-mode inject .`

## Using Secrets Manager

The `slack` configuration can be sourced from AWS Secrets Manager, using the `var.slack.secret_name`. The secret should be a JSON object reassembling the `slack` configuration.

```json
{
"channel": "#channel",
"username": "username",
"webhook_url": "https://hooks.slack.com/services/..."
}
```

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand Down
2 changes: 2 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ locals {
slack_webhook_url = local.enable_slack_secret ? jsondecode(data.aws_secretsmanager_secret_version.slack[0].secret_string)["webhook_url"] : try(var.slack.webhook_url, null)
## The slack channel to post to
slack_channel = local.enable_slack_secret ? jsondecode(data.aws_secretsmanager_secret_version.slack[0].secret_string)["channel"] : try(var.slack.channel, null)
## slack_username to use
slack_username = local.enable_slack_secret ? jsondecode(data.aws_secretsmanager_secret_version.slack[0].secret_string)["username"] : try(var.slack.username, null)
}
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module "slack" {
lambda_function_tags = var.tags
recreate_missing_package = false
slack_channel = local.slack_channel
slack_username = var.slack.username
slack_username = local.slack_username
slack_webhook_url = local.slack_webhook_url
sns_topic_name = var.sns_topic_name
tags = var.tags
Expand Down

0 comments on commit a15c328

Please sign in to comment.