Skip to content

Commit

Permalink
Specify ECR for IAM policy
Browse files Browse the repository at this point in the history
Signed-off-by: kevin <[email protected]>
  • Loading branch information
khluu committed Dec 3, 2024
1 parent 4f70d03 commit 44b6964
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions infra/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ resource "aws_iam_policy" "premerge_ecr_public_read_access_policy" {
"ecr-public:DescribeRegistries",
"sts:GetServiceBearerToken"
]
Resource = "*"
Resource = "arn:aws:ecr-public::936637512419:repository/vllm-ci-test-repo"
}]
})
}
Expand Down Expand Up @@ -329,7 +329,7 @@ resource "aws_iam_policy" "premerge_ecr_public_write_access_policy" {
"ecr-public:UploadLayerPart",
"sts:GetServiceBearerToken"
]
Resource = "*"
Resource = "arn:aws:ecr-public::936637512419:repository/vllm-ci-test-repo"
}]
})
}
Expand All @@ -352,7 +352,7 @@ resource "aws_iam_policy" "postmerge_ecr_public_read_access_policy" {
"ecr-public:DescribeRegistries",
"sts:GetServiceBearerToken"
]
Resource = "*"
Resource = "arn:aws:ecr-public::936637512419:repository/vllm-ci-postmerge-repo"
}]
})
}
Expand Down Expand Up @@ -384,7 +384,39 @@ resource "aws_iam_policy" "postmerge_ecr_public_read_write_access_policy" {
"ecr-public:UploadLayerPart",
"sts:GetServiceBearerToken"
]
Resource = "*"
Resource = "arn:aws:ecr-public::936637512419:repository/vllm-ci-postmerge-repo"
}]
})
}

resource "aws_iam_policy" "release_ecr_public_read_write_access_policy" {
name = "release-ecr-public-read-write-access-policy"
description = "Policy to push and pull images from release ECR"

policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Effect = "Allow"
Action = [
"ecr-public:BatchCheckLayerAvailability",
"ecr-public:CompleteLayerUpload",
"ecr-public:DescribeImageTags",
"ecr-public:DescribeImages",
"ecr-public:DescribeRegistries",
"ecr-public:DescribeRepositories",
"ecr-public:GetAuthorizationToken",
"ecr-public:GetRegistryCatalogData",
"ecr-public:GetRepositoryCatalogData",
"ecr-public:GetRepositoryPolicy",
"ecr-public:InitiateLayerUpload",
"ecr-public:ListTagsForResource",
"ecr-public:PutImage",
"ecr-public:PutRegistryCatalogData",
"ecr-public:TagResource",
"ecr-public:UploadLayerPart",
"sts:GetServiceBearerToken"
]
Resource = "arn:aws:ecr-public::936637512419:repository/vllm-release-repo"
}]
})
}
Expand Down Expand Up @@ -495,6 +527,14 @@ resource "aws_iam_role_policy_attachment" "postmerge_ecr_public_read_write_acces
policy_arn = aws_iam_policy.postmerge_ecr_public_read_write_access_policy.arn
}

resource "aws_iam_role_policy_attachment" "release_ecr_public_read_write_access" {
for_each = merge(
aws_cloudformation_stack.bk_queue_postmerge
)
role = each.value.outputs.InstanceRoleName
policy_arn = aws_iam_policy.release_ecr_public_read_write_access_policy.arn
}

resource "aws_iam_role_policy_attachment" "bk_stack_secrets_access" {
for_each = merge(
aws_cloudformation_stack.bk_queue,
Expand Down

0 comments on commit 44b6964

Please sign in to comment.