Skip to content

Commit

Permalink
Merge pull request #3 from digirati-co-uk/feature/deadletter
Browse files Browse the repository at this point in the history
Support optional deadletter config
  • Loading branch information
donaldgray committed Aug 28, 2024
2 parents 72bb74e + c91a7da commit b47ced5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ Terraform creates:
| slack_webhook_url | Slack webhook URL to call (optional) | |
| slack_webhook_secret | AWS SecretsManager secret storing Slack webhook URL to call (optional) | |
| runtime | Python runtime to use for lambda | python3.11 |
| dead_letter_arn | (Optional) ARN of SNS topic or SQS queue to notify if invocation fails | |

### Outputs

| Variable | Description |
| ------------- | ---------------------------------------------- |
| sns_topic_arn | ARN of SNS topic for handling Cloudwatch Alarm |
| sns_topic_arn | ARN of SNS topic for handling Cloudwatch Alarm |
| role_arn | ARN of lambda role |
8 changes: 8 additions & 0 deletions terraform/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ resource "aws_lambda_function" "cloudwatch_to_slack" {

role = aws_iam_role.cloudwatch_to_slack_exec_role.arn

dynamic "dead_letter_config" {
for_each = var.dead_letter_arn == null ? [] : [{}]

content {
target_arn = var.dead_letter_arn
}
}

environment {
variables = local.env_vars
}
Expand Down
5 changes: 5 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ output "sns_topic_arn" {
value = aws_sns_topic.cloudwatch_alarm.arn
description = "ARN of SNS topic"
}

output "role_name" {
value = aws_iam_role.cloudwatch_to_slack_exec_role.name
description = "Name of Lambda role"
}
6 changes: 6 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ variable "region" {
type = string
}

variable "dead_letter_arn" {
description = "ARN of SNS topic or SQS queue to notify when invocation fails"
type = string
default = null
}

locals {
env_candidates = {
SLACK_WEBHOOK_URL = var.slack_webhook_url
Expand Down

0 comments on commit b47ced5

Please sign in to comment.