Skip to content

Commit 28304a7

Browse files
committed
Fixing error
1 parent 9c11d95 commit 28304a7

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

main.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_policy_attach
1212
}
1313

1414
resource "aws_iam_policy" "ecs_task_execution_role_custom_policy" {
15-
count = length(var.ecs_task_execution_role_custom_policy) > 0 ? 1 : 0
15+
for_each = toset(var.ecs_task_execution_role_custom_policies)
1616
name = "${var.name_prefix}-ecs-task-execution-role-custom-policy"
1717
description = "A custom policy for ${var.name_prefix}-ecs-task-execution-role IAM Role"
18-
19-
policy = var.ecs_task_execution_role_custom_policy
18+
policy = each.value
2019
}
2120

2221
resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_custom_policy" {
23-
count = length(var.ecs_task_execution_role_custom_policy) > 0 ? 1 : 0
22+
for_each = aws_iam_policy.ecs_task_execution_role_custom_policy
2423
role = aws_iam_role.ecs_task_execution_role.name
25-
policy_arn = aws_iam_policy.ecs_task_execution_role_custom_policy[*].arn
24+
policy_arn = each.value.arn
2625
}
2726

2827
#------------------------------------------------------------------------------

variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,10 @@ variable "task_role_arn" {
322322
default = null
323323
}
324324

325-
variable "ecs_task_execution_role_custom_policy" {
326-
description = "(Optional) A custom policy to attach to the ECS task execution role. For example for reading secrets from AWS Systems Manager Parameter Store or Secrets Manager"
327-
type = string
328-
default = null
325+
variable "ecs_task_execution_role_custom_policies" {
326+
description = "(Optional) Custom policies to attach to the ECS task execution role. For example for reading secrets from AWS Systems Manager Parameter Store or Secrets Manager"
327+
type = list(string)
328+
default = []
329329
}
330330

331331
variable "placement_constraints" {

0 commit comments

Comments
 (0)