概要
- GitHub.com と Terraform Cloud 利用環境(state を Terraform Cloud で管理している)
- Terraform Cloud の Workspace の terraform version を 0.13 より古いものから最新版(1.2.1)に Upgrade したところ、terraform plan で Invalid legacy provider address が発生するようになってしまった。
- provider も最新化している。
エラー詳細
│ Error: Invalid legacy provider address
│
│ This configuration or its associated state refers to the unqualified
│ provider "google".
│
│ You must complete the Terraform 0.13 upgrade process before upgrading to
│ later versions.
原因
- Terraform アップグレードに伴う、 google providor の更新が必要
対応
- Cloud でも local でも terraform plan すると、同じ Invalid legacy provider address になってしまう。
- とりあえずLocalで
terraform login
して、terraform init
し、Invalid legacy provider address が表示されても、 .terraform 配下に backend 情報が生成される。 - state を replace する(具体的には以下)
terraform state replace-provider registry.terraform.io/-/google registry.terraform.io/hashicorp/google
- そうすると、
terraform init
とterraform plan
が通るようになった。-
.terraform.lock.hcl
が生成されるように変わるので、忘れずコミットする。
-