gcp, terraform,

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

Jul 05, 2022 · 1 min read · Post a comment

One more issue from the Terraform error list that I want to share with y’all. While I was struggling with GCP on a day-to-day basis, I tried to initialize the remote TF state file stored in a GCS bucket and received the following console output:
Error: Failed to get existing workspaces: querying Cloud Storage failed: storage: bucket doesn't exist

Prerequisites

  • GCP account
  • Terraform

Solution(s)

  1. The Terraform state bucket must be created in advance. Verify it from the GCP Console or simply list all the buckets located in a specific project from the CLI:
    gcloud alpha storage ls --project=<some_project_name>
    
  2. If the bucket is there, make sure you are authenticated against the correct project.
    gcloud auth application-default login --project <some_project_name>
    
  3. Last but not least, run:
    terraform init -reconfigure
    

Conclusion

Tried everything and nothing works? Let me know. On a side note, follow our official channel on Telegram.