Skip to content

AWS IAM policies

Four inline policies, two on each role.

Role Policy Grants
Runtime xratu-runtime-ecr ECR pull and push
Runtime xratu-runtime-s3 Bucket list, and object access under the prefix
Build xratu-build-ecr ECR pull and push
Build xratu-build-s3 Bucket list, and object access under the prefix

The ECR policy

resource "aws_iam_role_policy" "runtime_ecr" {
  name = "xratu-runtime-ecr"
  role = aws_iam_role.runtime.id
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect = "Allow"
      Action = ["ecr:GetAuthorizationToken", "ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer", "ecr:PutImage", "ecr:UploadLayerPart", "ecr:InitiateLayerUpload", "ecr:CompleteLayerUpload", "ecr:BatchCheckLayerAvailability"]
      Resource = "*"
    }]
  })
}

Eight actions covering the pull and push paths. Resource = "*" because ecr:GetAuthorizationToken is account-scoped and cannot be restricted to a repository. Narrowing the other seven to your repository ARN is the common edit. See AWS-specific edits before apply.

The S3 policy

    Statement = [
      {
        Effect = "Allow"
        Action = ["s3:ListBucket", "s3:GetBucketLocation"]
        Resource = ["arn:aws:s3:::<bucket>"]
      },
      {
        Effect = "Allow"
        Action = ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"]
        Resource = ["arn:aws:s3:::<bucket>/<prefix>/*"]
      }
    ]

Two statements, because list and object actions take different resource forms. Object access is already confined to the prefix from your bucket path.

Compared with the other clouds

AWS GCP Azure
Identities 2 roles 3 service accounts 2 managed identities
Registry grant Inline policy, Resource = "*" Project role, plus a repository-scoped delegate AcrPush at registry scope
Bucket grant Prefix-scoped objects Bucket-wide Container-scoped
Publish path Direct on each role Through a delegate identity Direct on each identity

AWS is the only one where object access is prefix-scoped by default, and the only one where the registry grant is account-wide by default.

What is outside this baseline

Tenant registry and bucket access only. Private upstream registries, external buckets and third-party tokens are explicit add-on profiles.

Verifying after apply

aws iam list-role-policies --role-name dp-eu-west1-runtime
aws iam get-role-policy --role-name dp-eu-west1-runtime --policy-name xratu-runtime-s3