GCP IAM roles¶
Five grants, across three identities.
| Identity | Role | Scope | For |
|---|---|---|---|
| Runtime | roles/artifactregistry.writer |
Project | Pulling and pushing tenant images |
| Runtime | roles/storage.objectAdmin |
Bucket | Reading and writing artifact bytes |
| Build | roles/storage.objectAdmin |
Bucket | Reading and writing build inputs and outputs |
| Build | roles/iam.serviceAccountTokenCreator |
The publish delegate | Impersonating the delegate to push |
| Publish delegate | roles/artifactregistry.writer |
Repository | Pushing published images |
Plus one roles/iam.workloadIdentityUser binding per Kubernetes service
account. See Workload Identity.
The delegation¶
Build does not hold a push grant itself. It holds token-creator on a third identity, and that identity holds the repository-scoped writer role:
resource "google_service_account_iam_member" "build_publish_delegate_token_creator" {
service_account_id = google_service_account.publish_delegate.name
role = "roles/iam.serviceAccountTokenCreator"
member = "serviceAccount:dp-eu-west1-build@<gcp-project-id>.iam.gserviceaccount.com"
}
flowchart LR
B["Build identity"] -->|"tokenCreator"| PD["Publish delegate"]
PD -->|"artifactregistry.writer<br/>repository-scoped"| REPO["Repository xratu"]
The push capability sits on a principal that runs nothing, reached only by
impersonation. gcp_iamcredentials_endpoint is the endpoint that impersonation
call goes to, which is why it is a required field.
How the scopes differ¶
Runtime's registry grant is project-wide, roles/artifactregistry.writer on
the project. The delegate's is repository-scoped, bound to the one
repository in your registry path.
Bucket grants are bucket-wide. roles/storage.objectAdmin on the bucket
covers every object in it, and the prefix in your bucket path organises rather
than restricts.
Where a tighter grant is required, the Terraform is yours to edit before apply. See GCP-specific edits before apply.
What is outside this baseline¶
The baseline covers tenant-owned registry and bucket access. Private upstream registries, external buckets, and third-party tokens are explicit add-on profiles you grant deliberately rather than ambient permissions.