diff --git a/iam.tf b/iam.tf index 436a4398..37d7ed6b 100644 --- a/iam.tf +++ b/iam.tf @@ -331,10 +331,10 @@ resource "aws_iam_role_policy_attachment" "additional_one" { ###################################### resource "aws_iam_role_policy_attachment" "additional_many" { - count = local.create_role && var.attach_policies ? var.number_of_policies : 0 + for_each = { for k, v in toset(var.policies) : k => v if local.create_role && var.attach_policies && var.number_of_policies > 0 } role = aws_iam_role.lambda[0].name - policy_arn = var.policies[count.index] + policy_arn = each.value } ###############################