Skip to content

Commit

Permalink
feat(sns): made sns dql optional & Fix: #55
Browse files Browse the repository at this point in the history
  • Loading branch information
EreminAnton committed Sep 13, 2023
1 parent 4159897 commit c095c6b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions perm_revoker_lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ module "access_revoker" {
attach_policy_json = true
policy_json = data.aws_iam_policy_document.revoker.json

dead_letter_target_arn = aws_sns_topic.dlq.arn
attach_dead_letter_policy = true
dead_letter_target_arn = var.aws_sns_topic_subscription_email != "" ? aws_sns_topic.dlq[0].arn : null
attach_dead_letter_policy = var.aws_sns_topic_subscription_email != "" ? true : false

# do not retry automatically
maximum_retry_attempts = 0
Expand Down
4 changes: 2 additions & 2 deletions slack_handler_lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ module "access_requester_slack_handler" {
attach_policy_json = true
policy_json = data.aws_iam_policy_document.slack_handler.json

dead_letter_target_arn = aws_sns_topic.dlq.arn
attach_dead_letter_policy = true
dead_letter_target_arn = var.aws_sns_topic_subscription_email != "" ? aws_sns_topic.dlq[0].arn : null
attach_dead_letter_policy = var.aws_sns_topic_subscription_email != "" ? true : false

# do not retry automatically
maximum_retry_attempts = 0
Expand Down
4 changes: 3 additions & 1 deletion sns.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
resource "aws_sns_topic" "dlq" {
count = var.aws_sns_topic_subscription_email != "" ? 1 : 0
name = var.requester_lambda_name
kms_master_key_id = "alias/aws/sns" # tfsec:ignore:aws-sns-topic-encryption-use-cmk
tags = var.tags
}

resource "aws_sns_topic_subscription" "dlq" {
topic_arn = aws_sns_topic.dlq.arn
count = var.aws_sns_topic_subscription_email != "" ? 1 : 0
topic_arn = aws_sns_topic.dlq[0].arn
protocol = "email"
endpoint = var.aws_sns_topic_subscription_email
}
3 changes: 2 additions & 1 deletion vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ variable "tags" {
variable "aws_sns_topic_subscription_email" {
description = "value for the email address to subscribe to the SNS topic"
type = string
default = ""
}

variable "slack_signing_secret" {
Expand Down Expand Up @@ -170,4 +171,4 @@ variable "max_permissions_duration_time" {
description = "Maximum duration of the permissions granted by the Elevator in hours."
type = number
default = 24
}
}

0 comments on commit c095c6b

Please sign in to comment.