An enterprise DevOps team is setting up an automated CI/CD pipeline on a self-hosted runner outside of Google Cloud. The deployment script needs to programmatically execute gcloud CLI commands and custom Python client library scripts to manage infrastructure across multiple target Google Cloud projects. Enterprise security policy strictly prohibits creating, downloading, or storing long-lived service account JSON keys. Which approach should the Cloud Architect recommend to enable secure, programmatic authentication for the pipeline?
- Authenticate the runner using Workload Identity Federation to obtain short-lived credentials for a baseline service account, and use service account impersonation for target project deployments.Cevap
- BGenerate service account JSON keys for each target project service account, store them in the pipeline's secret manager, and set GOOGLE_APPLICATION_CREDENTIALS during execution.
- CGrant the primitive Owner role across all target projects to a single runner service account authenticated via a long-lived OAuth2 refresh token.
- DCache authenticated gcloud user tokens and unversioned configuration state files on the local filesystem of the runner to persist access across job runs.
Cevap
Authenticate the runner using Workload Identity Federation to obtain short-lived credentials for a baseline service account, and use service account impersonation for target project deployments.
The correct approach leverages Workload Identity Federation (WIF) alongside service account impersonation. WIF enables on-premises or external CI/CD workloads to authenticate with Google Cloud using native identity tokens, exchanging them for short-lived GCP access tokens without service account keys. Using service account impersonation (`--impersonate-service-account` in gcloud or `google.auth.impersonate` in SDKs) allows the runner to dynamically assume fine-grained identities across target projects safely.
Adım Adım Çözüm
Anahtar Kavram
Workload Identity Federation and Service Account Impersonation for Keyless Programmatic Interaction