Skip to content

Commit 63bc783

Browse files
authored
Replace for_each with count for producing ECS custom policies. (#30)
1 parent aabef48 commit 63bc783

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_policy_attach
1414
}
1515

1616
resource "aws_iam_policy" "ecs_task_execution_role_custom_policy" {
17-
for_each = { for s in var.ecs_task_execution_role_custom_policies : index(var.ecs_task_execution_role_custom_policies, s) => s }
18-
name = "${var.name_prefix}-ecs-task-execution-role-custom-policy-${each.key}"
17+
count = length(var.ecs_task_execution_role_custom_policies)
18+
name = "${var.name_prefix}-ecs-task-execution-role-custom-policy-${count.index}"
1919
description = "A custom policy for ${var.name_prefix}-ecs-task-execution-role IAM Role"
20-
policy = each.value
20+
policy = var.ecs_task_execution_role_custom_policies[count.index]
2121
tags = var.tags
2222
}
2323

2424
resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_custom_policy" {
25-
for_each = aws_iam_policy.ecs_task_execution_role_custom_policy
25+
count = length(var.ecs_task_execution_role_custom_policies)
2626
role = aws_iam_role.ecs_task_execution_role.name
27-
policy_arn = each.value.arn
27+
policy_arn = aws_iam_policy.ecs_task_execution_role_custom_policy[count.index].arn
2828
}
2929

3030
#------------------------------------------------------------------------------

0 commit comments

Comments
 (0)