This repository uses Google Cloud Workload Identity Federation for secure CI/CD authentication without static service account keys.
Workload Identity Federation allows external identity providers (like GitHub) to authenticate with Google Cloud using short-lived credentials instead of long-lived service account keys. It's a more secure alternative to downloading and storing service account JSON keys.
- Security: Eliminates the need for static service account keys that could be compromised
- Compliance: Follows security best practices for cloud-native applications
- Automation: Enables secure CI/CD pipelines without manual key management
- Auditability: All actions are properly attributed to the CI/CD service account
- GitHub Actions workflows authenticate to Google Cloud when deploying to staging/production
- Used in the deployment workflow that runs on pushes to
devandmainbranches
- Ansible playbooks run with WIF-authenticated credentials to manage VMs
- Terraform operations use WIF for provisioning and managing cloud resources
- The CI/CD process impersonates the Ansible service account
- This service account has the necessary permissions for deployment and infrastructure management
- GitHub OIDC Token: GitHub Actions provides an OpenID Connect token
- WIF Exchange: The token is exchanged for Google Cloud credentials via the WIF provider
- Service Account Impersonation: Short-lived credentials are used to impersonate the Ansible service account
- Secure Operations: All cloud operations are performed with proper authentication and audit trails
dev→nuspace-staging(staging environment)main→nuspace2025(production environment)
The WIF setup is automatically provisioned via Terraform (terraform/iam.tf) and includes:
- Workload Identity Pool and Provider
- IAM bindings for the Ansible service account
- Required API enablement (
iamcredentials.googleapis.com,sts.googleapis.com)
When WIF is working correctly:
- GitHub Actions authentication step succeeds without JSON key material
gcloud auth listshows the impersonated service account- Cloud Audit Logs attribute actions to the Ansible service account
- No manual authentication overrides are needed in workflows
We use IAP TCP forwarding so GitHub Actions can reach the VM without opening SSH to the public internet.
- GitHub Actions authenticates to GCP using WIF.
- The workflow impersonates the Ansible service account.
- IAP authorizes a TCP tunnel to the VM (port 22) using IAM.
roles/iap.tunnelResourceAccessoron the Ansible service accountroles/compute.osLoginorroles/compute.osAdminLogin- Firewall rule allowing
tcp:22from35.235.240.0/20(IAP range)
gcloud compute ssh nuspace-instance \
--project=nuspace2025 \
--zone=europe-central2-a \
--tunnel-through-iap