7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Terraform × GCP × GCS で急に Terraform が 400 エラーで実行できなくなった

Last updated at Posted at 2021-10-15

前提

  • Terraform のバージョン 1.0.x 系
  • 対象クラウド GCP
  • Backend Type: gcs

症状

Terraform が実行できなくなった

plan 実行結果

╷
│ Error: Error loading state: Failed to open state file at gs://xxx-terraform-state/hoge/default.tfstate: googleapi: got HTTP response code 400 with body: <?xml version='1.0' encoding='UTF-8'?><Error><Code>UserProjectInvalid</Code><Message>User project specified in the request is invalid.</Message><Details>User project specified in the request is invalid.</Details></Error>
│
│
╵

terraform init -reconfigure 実行結果

╷
│ Error: Failed to get existing workspaces: querying Cloud Storage failed: googleapi: Error 400: User project specified in the request is invalid., invalid
│
│
╵

きっかけ、心当たり

Catalina -> Big Sur へのアップデート(...?)

調査

  • gcloud コマンドは実行できる(e.g gcloud alpha storage ls とか)
  • gcloud config set project xxx でプロジェクトは正しくセットされている
  • terraform init -reconfigure で直るという記事が数件ヒットしたが、私は直らず

解消方法

gcloud auth application-default login を実行したところ、直った

ユーザーADC というものが期限切れになったから、っぽい。

Backend Type: gcs - Terraform by HashiCorp

7
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?