Skip to content

Commit

Permalink
Fix pull_from_ecr policy attachment for nodes
Browse files Browse the repository at this point in the history
The existing policy attachment resource loop only supported AWS managed
policies (as it assumes the structure of the ARN).
  • Loading branch information
theseanything committed Jul 8, 2024
1 parent d6f59c4 commit 9d5f3b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion terraform/deployments/cluster-infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,16 @@ resource "aws_iam_policy" "pull_from_ecr" {
policy = data.aws_iam_policy_document.pull_from_ecr.json
}

resource "aws_iam_role_policy_attachment" "pull_from_ecr" {
policy_arn = aws_iam_policy.pull_from_ecr.arn
role = aws_iam_role.node.name
}

resource "aws_iam_role_policy_attachment" "node" {
for_each = toset([
"AmazonEKSWorkerNodePolicy",
"AmazonEKS_CNI_Policy",
"AmazonSSMManagedInstanceCore",
aws_iam_policy.pull_from_ecr.name,
])
policy_arn = "arn:aws:iam::aws:policy/${each.key}"
role = aws_iam_role.node.name
Expand Down

0 comments on commit 9d5f3b7

Please sign in to comment.