Skip to content

Commit

Permalink
Setup Workload Identity Federation (#323)
Browse files Browse the repository at this point in the history
* Use Google auth action for WIF

* Update action

* Try using new GKE auth action

* Specify cluster location

* Remove deprecated action

* Use correct project ID

* Install gke-gcloud-auth-plugin

* Do we need GKE auth?

* Remove comments

* Update pool and provider

* Copy changes to staging and default

* Test removing permissions block

* Only add back id-token write permission

* Remove contents permission
  • Loading branch information
faucomte97 authored Jun 27, 2024
1 parent 60ea981 commit ca3d50d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/actions/deploy_gcloud/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ runs:
shell: bash

- name: "Get cluster credentials"
run: |-
run: |
gcloud components install gke-gcloud-auth-plugin
gcloud container clusters get-credentials "aimmo-$MODULE_NAME" --zone "$GKE_ZONE"
env:
MODULE_NAME: ${{ inputs.module-name }}
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/deploy_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
MODULE_NAME: default
VERSION: ${{ github.run_number }}
DATABASE_POSTFIX: ${{ secrets.DATABASE_POSTFIX }}
permissions:
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -25,18 +27,17 @@ jobs:
python-version: "3.8.x"
architecture: "x64"

- id: gcauth
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_AUTH }}
project_id: 'decent-digit-629'
workload_identity_provider: 'projects/354656325390/locations/global/workloadIdentityPools/cfl-pool/providers/cfl-provider'
service_account: '[email protected]'

- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@v2

- name: GKE auth
uses: simenandre/setup-gke-gcloud-auth-plugin@v1

- name: Deploy to Google Cloud
uses: ./.github/actions/deploy_gcloud
with:
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
MODULE_NAME: dev
VERSION: ${{ github.run_number }}
DATABASE_POSTFIX: ${{ secrets.DATABASE_POSTFIX }}
permissions:
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -39,18 +41,17 @@ jobs:
python-version: "3.8.x"
architecture: "x64"

- id: gcauth
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_AUTH }}
project_id: 'decent-digit-629'
workload_identity_provider: 'projects/354656325390/locations/global/workloadIdentityPools/cfl-pool/providers/cfl-provider'
service_account: '[email protected]'

- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@v2

- name: GKE auth
uses: simenandre/setup-gke-gcloud-auth-plugin@v1

- name: Deploy to Google Cloud
uses: ./.github/actions/deploy_gcloud
with:
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
MODULE_NAME: staging
VERSION: ${{ github.run_number }}
DATABASE_POSTFIX: ${{ secrets.DATABASE_POSTFIX }}
permissions:
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -25,18 +27,17 @@ jobs:
python-version: "3.8.x"
architecture: "x64"

- id: gcauth
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_AUTH }}
project_id: 'decent-digit-629'
workload_identity_provider: 'projects/354656325390/locations/global/workloadIdentityPools/cfl-pool/providers/cfl-provider'
service_account: '[email protected]'

- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@v2

- name: GKE auth
uses: simenandre/setup-gke-gcloud-auth-plugin@v1

- name: Deploy to Google Cloud
uses: ./.github/actions/deploy_gcloud
with:
Expand Down

0 comments on commit ca3d50d

Please sign in to comment.