Skip to content

Commit

Permalink
Replace for_each with count for producing ECS custom policies. (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbeloglazov authored Jul 30, 2022
1 parent aabef48 commit 63bc783
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_policy_attach
}

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

resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_custom_policy" {
for_each = aws_iam_policy.ecs_task_execution_role_custom_policy
count = length(var.ecs_task_execution_role_custom_policies)
role = aws_iam_role.ecs_task_execution_role.name
policy_arn = each.value.arn
policy_arn = aws_iam_policy.ecs_task_execution_role_custom_policy[count.index].arn
}

#------------------------------------------------------------------------------
Expand Down

0 comments on commit 63bc783

Please sign in to comment.