I am working on automating our GCE deployments and I am not sure how to handle authentication safely. I don't want to bake JSON keys into my build images.
What is the best way to authenticate Cloud Build against our projects? Should I be using Workload Identity Federation? I want to follow the best security practices for the exam and for my real-world work.
Workload Identity Federation provides secure, keyless authentication to Google Cloud by using short-lived access tokens derived from trusted external identity providers.
3 answers
Using Workload Identity Federation is the only acceptable path for modern deployments, as it replaces long-lived secrets with ephemeral tokens tied to specific pipeline runs.
- Configure your OIDC provider in your source repository settings
- Define a workload identity pool and provider within your Google Cloud project
- Map your identity attributes to a service account that has the minimum required permissions
You should prioritize Workload Identity Federation to eliminate static credentials entirely from your deployment pipelines. By leveraging short-lived tokens, you align your architecture with the principle of least privilege and remove the operational burden of key rotation.
Back when I was auditing a large migration project, we found a service account JSON file committed to a public repository that triggered a massive security incident. Since then, I have absolutely refused to allow static keys in any pipeline environment I manage.
You must move to identity-based authentication immediately to ensure your environment stays secure. It is the only way to avoid the catastrophic risk of leaked secrets.

