Skip to content

Commit 53fe2de

Browse files
committed
fix: prevent lambda IAM policies from detaching when orders are swapped
1 parent 7bd028b commit 53fe2de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

iam.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ resource "aws_iam_role_policy_attachment" "additional_one" {
331331
######################################
332332

333333
resource "aws_iam_role_policy_attachment" "additional_many" {
334-
count = local.create_role && var.attach_policies ? var.number_of_policies : 0
334+
for_each = { for k, v in toset(var.policies) : k => v if local.create_role && var.attach_policies && var.number_of_policies > 0 }
335335

336336
role = aws_iam_role.lambda[0].name
337-
policy_arn = var.policies[count.index]
337+
policy_arn = each.value
338338
}
339339

340340
###############################

0 commit comments

Comments
 (0)