You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Terraform从0.13升级至0.14遇‘无效旧版提供商地址’错误求助

Terraform 0.13.7升级至0.14时的"无效旧版提供商地址"问题

切换到Terraform 0.14版本时出现以下错误:

Error: Invalid legacy provider address

This configuration or its associated state refers to the unqualified provider
"aws".

You must complete the Terraform 0.13 upgrade process before upgrading to later
versions.

Error: Terraform exited with code 1.
Error: Process completed with exit code 1.

已尝试的解决方法:

  • 成功使用Terraform v0.13执行terraform init和terraform apply
  • 对主目录及所有嵌套模块的.tf文件执行terraform 0.13upgrade命令
  • 执行命令 terraform state replace-provider "registry.terraform.io/-/aws" "hashicorp/aws"
  • 手动检查状态文件,确认不存在registry.terraform.io/-/aws的引用
  • 执行terraform init -upgrade
  • 移除AWS提供商版本约束,避免与TF v0.13不兼容的旧版本
  • 使用0.13.0版本重新执行Terraform并完成apply验证

更新:当前的required providers配置块如下:

terraform {
  required_version = ">= 0.13"
  required_providers {
    archive = {
      source = "hashicorp/archive"
    }
    aws = {
      source = "hashicorp/aws"
    }
    local = {
      source = "hashicorp/local"
    }
    random = {
      source = "hashicorp/random"
    }
    template = {
      source = "hashicorp/template"
    }
    vault = {
      source = "hashicorp/vault"
    }
  }
}

额外可尝试的排查方向

  • 清理本地缓存:删除项目根目录下的.terraform目录和.terraform.lock.hcl文件,用0.13.7重新执行terraform init,确认缓存加载的都是合格的提供商源后,再切换至0.14版本尝试
  • 深度检查嵌套模块:逐个查看所有嵌套模块的代码,确认模块内的provider "aws"块是否指定了source = "hashicorp/aws",避免模块内存在未限定的旧版提供商引用
  • 检查状态资源的provider字段:执行terraform state list列出所有资源,对每个AWS资源执行terraform state show <资源ID>,查看输出中的provider字段是否为registry.terraform.io/hashicorp/aws,排查是否有隐藏的未限定引用
  • 重新初始化状态:用0.13.7执行terraform state pull > state-backup.tfstate备份状态,删除本地状态文件后,执行terraform init -from-state=state-backup.tfstate重新加载状态,再切换至0.14
  • 验证版本环境:切换至0.14版本后,执行terraform version确认当前使用的确实是目标版本,避免PATH环境变量中旧版本优先级更高
  • 升级第三方模块:如果使用了公共Registry模块,确认模块版本已适配Terraform 0.13+的提供商源,将模块升级至支持0.13的最新稳定版

内容的提问来源于stack exchange,提问作者polo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 18:33:16