Skip to content

Commit

Permalink
Add dynamic statement blocks (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaiPrasannaGopularam authored May 28, 2024
1 parent fbe38d1 commit d6f080a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
27 changes: 23 additions & 4 deletions data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,29 @@ data "aws_iam_policy_document" "task_execution_role_policy" {
resources = concat([var.docker_secret], var.secret_arns)
}

statement {
effect = "Allow"
actions = ["kms:Decrypt"]
resources = var.encryption_keys
dynamic "statement" {
for_each = length(var.ssm_param_arns) > 0 ? [1] : []

content {
effect = "Allow"
actions = [
"ssm:GetParameter",
"ssm:GetParameters"
]
resources = var.ssm_param_arns
}
}

dynamic "statement" {
for_each = length(var.encryption_keys) > 0 ? [1] : []

content {
effect = "Allow"
actions = [
"kms:Decrypt"
]
resources = var.encryption_keys
}
}

statement {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,9 @@ variable "encryption_keys" {
type = list(string)
default = []
}

variable "ssm_param_arns" {
description = "Arn of the ssm parameters that are passed to the container environment"
type = list(string)
default = []
}

0 comments on commit d6f080a

Please sign in to comment.