Search code examples
terraformgoogle-cloud-build

Failed to get existing workspaces: querying Cloud Storage failed: storage: bucket doesn't exist


I was using terraform in cloud build, but it fails at this step

steps:
  # Terraform
  - id: 'configure_terraform'
    name: node:10.16.3
    entrypoint: "node"
    args: ["./create_terraform_config.js",
           "../terraform/override.tf",
           "${_TERRAFORM_BUCKET_NAME}",
           "${_TERRAFORM_BUCKET_PATH}"]
    dir: "app/scripts"
  - id: 'init_terraform'
    name: hashicorp/terraform:light
    args: ["init"]
    dir: "app/terraform"

Initializing the backend...

Successfully configured the backend "gcs"! Terraform will automatically
use this backend unless the backend configuration changes.

Error: Failed to get existing workspaces: querying Cloud Storage failed: storage: bucket doesn't exist

Solution

  • This might fix the issue

    terraform init -reconfigure
    

    reference: https://github.com/hashicorp/terraform/issues/23532#issuecomment-560493391