WIF is short for Workload Identity Federation for GCP.
Traditionally, applications running outside Google Cloud can use service account keys to access Google Cloud resources.
However, service account keys are powerful credentials, and can present a security risk if they are not managed correctly.
Workload Identity Federation eliminates the maintenance and security burden associated with service account keys.
Visit the link below for detail explanation.
https://cloud.google.com/iam/docs/workload-identity-federation
Implementing WIF will avoid exposing the GSA's keys, which is a security burden.
This helps to reduce the following:
The implementation of the WIF is intended with certain security measures:
The team for WIF implemenation are defined as the following:
The code below here is a reusable YAML Anchors and Aliases for majority of the pipeline.
The code is simply to perform the following:
.gcloud_auth: &gcloud_auth
# Replace the GCP service account name that needs to perform the deployment.
- export GCP_SERVICE_ACCOUNT=<GSA email>@${PROJECT_ID}.iam.gserviceaccount.com
- echo ${GCP_TOKEN} > .ci_job_jwt_file
- gcloud iam workload-identity-pools create-cred-config ${GCP_WORKLOAD_IDENTITY_PROVIDER}
--service-account=${GCP_SERVICE_ACCOUNT}
--output-file=.gcp_temp_cred.json
--credential-source-file=.ci_job_jwt_file
- gcloud auth login --cred-file=`pwd`/.gcp_temp_cred.json
- gcloud config set project ${PROJECT_ID}
- export GOOGLE_APPLICATION_CREDENTIALS=`pwd`/.gcp_temp_cred.json
|
To use the Anchor defined above, define the PROJECT_ID and GCP_WORKLOAD_IDENTITY_PROVIDER by getting the values from the Gitlab project's CI/CD variables.
Within the deploy step, include the id_tokens declaration and set the aud to https://gitlab.syensqo.com.
deploy-test:
stage: deploy
only:
- develop
id_tokens:
GCP_TOKEN:
aud: https://gitlab.syensqo.com
script:
- export PROJECT_ID=$GCLOUD_TARGET_PROJECT_TEST
- export GCP_WORKLOAD_IDENTITY_PROVIDER=$GCP_WORKLOAD_IDENTITY_PROVIDER_TEST
- *gcloud_auth
- mvn package appengine:deploy -DskipTests |
The following will be required to be configured within the targeted GCP Project:



Request Title: Implement WIF for <gcp project name>
Within description, use the text below and replace with the value required.
Target GCP project: <GCP project ID>
Impersonation GSA: <Service account name used by the gitlab pipeline to perform deployment>
Provider: <https://gitlab.syensqo.com >
Repository Path: <example path url of the repository: cas/sinequa/bigquery-connector>
Branch name for Dev: <develop | other name | NA>
Branch name for Test: <develop | other name | NA>
Branch name for Pre-prod: <develop | other name | NA>
Branch name for Prod: master
If the pipeline is failing, please check on the following:
echo ${GCP_TOKEN} > .ci_job_jwt_file |
Here is a list of Google APIs required for WIF: