前提
- 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 というものが期限切れになったから、っぽい。