From d9f419308ae8c7634f4cc7893ecc4f84fe100618 Mon Sep 17 00:00:00 2001 From: Ethan <39577870+ethanndickson@users.noreply.github.com> Date: Wed, 21 Aug 2024 12:46:28 +1000 Subject: [PATCH] chore(dogfood): use remote tf state (#14363) --- .github/workflows/dogfood.yaml | 13 ++++++++++++- dogfood/main.tf | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dogfood.yaml b/.github/workflows/dogfood.yaml index 8379f84739..c9ad797c56 100644 --- a/.github/workflows/dogfood.yaml +++ b/.github/workflows/dogfood.yaml @@ -17,6 +17,10 @@ on: - "flake.nix" workflow_dispatch: +permissions: + # Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage) + id-token: write + jobs: build_image: if: github.actor != 'dependabot[bot]' # Skip Dependabot PRs @@ -85,6 +89,12 @@ jobs: - name: Setup Terraform uses: ./.github/actions/setup-tf + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v2 + with: + workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github + service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com + - name: Terraform init and validate run: | cd dogfood @@ -110,7 +120,7 @@ jobs: cd dogfood terraform apply -auto-approve env: - # Consumed by Coder CLI + # Consumed by coderd provider CODER_URL: https://dev.coder.com CODER_SESSION_TOKEN: ${{ secrets.CODER_SESSION_TOKEN }} # Template source & details @@ -118,3 +128,4 @@ jobs: TF_VAR_CODER_TEMPLATE_VERSION: ${{ steps.vars.outputs.sha_short }} TF_VAR_CODER_TEMPLATE_DIR: ./contents TF_VAR_CODER_TEMPLATE_MESSAGE: ${{ steps.message.outputs.pr_title }} + TF_LOG: info diff --git a/dogfood/main.tf b/dogfood/main.tf index 178b8546af..7617df3227 100644 --- a/dogfood/main.tf +++ b/dogfood/main.tf @@ -4,9 +4,11 @@ terraform { source = "coder/coderd" } } + backend "gcs" { + bucket = "coder-dogfood-tf-state" + } } -// Alternative to committing a state file import { to = coderd_template.dogfood id = "0d286645-29aa-4eaf-9b52-cc5d2740c90b"