terraform runtime_error ai_generated true

错误:状态快照由 Terraform v1.6 创建,比当前 v1.5 更新

Error: state snapshot was created by Terraform v1.6, which is newer than current v1.5

ID: terraform/state-version-mismatch-major-upgrade

其他格式: JSON · Markdown 中文 · English
95%修复率
85%置信度
1证据数
2024-06-01首次发现

版本兼容性

版本状态引入弃用备注
Terraform v1.5.0 active
Terraform v1.6.0 active
Terraform v1.7.0 active

根因分析

Terraform 状态文件由较新版本的 Terraform(v1.6)写入,无法被较旧版本(v1.5)读取,因为状态格式不兼容。

English

The Terraform state file was written by a newer version of Terraform (v1.6) and cannot be read by the older version (v1.5) due to incompatible state format changes.

generic

官方文档

https://developer.hashicorp.com/terraform/language/state/backends

解决方案

  1. Upgrade the local Terraform version to match or exceed the version that wrote the state: install Terraform v1.6 or later via `tfenv install 1.6.0 && tfenv use 1.6.0`
  2. If you must use an older version, restore a state backup from before the newer version was used (if available): `aws s3 cp s3://bucket/terraform.tfstate.backup terraform.tfstate`

无效尝试

常见但无效的做法:

  1. 100% 失败

    Terraform does not support backward state compatibility. Once state is written by a newer version, older versions cannot parse it.

  2. 100% 失败

    The state format is not just a version number; the internal serialization changed. Editing the version field corrupts the state and may cause data loss.