resource aws_iam_role this { for_each = var.roles name = each.key assume_role_policy = each.value["assume_role_policy"] } resource "aws_iam_role_policy_attachment" "fargate-policy-attachment" { for_each = aws_iam_role.this policy_arn = "arn:aws:iam::aws:policy/job-function/ViewOnlyAccess" role = each.value["name"] }