GCP Cloud Architecture (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is Workload Identity Federation in GCP and why should you eliminate service account JSON keys?
senior LevelCode ExampleSystem Design
In Simple Words: Hardcoded JSON keys are the #1 cause of cloud credential leaks on GitHub:
- Workload Identity Federation: Allows external workloads (AWS EC2, GitHub Actions, Kubernetes pods) to impersonate a GCP Service Account using short-lived OpenID Connect (OIDC) tokens.
- Flow: GitHub Actions generates an OIDC JWT token -> GCP Security Token Service (STS) verifies GitHub's signature -> GCP issues a temporary 1-hour OAuth access token.
yaml
# GitHub Actions Workload Identity Example:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: 'projects/123/locations/global/workloadIdentityPools/github-pool/providers/github-provider'
service_account: 'deployer@my-project.iam.gserviceaccount.com'