“无效的旧提供者地址"Terraform 上的错误 [英] "Invalid legacy provider address" error on Terraform

查看:25
本文介绍了“无效的旧提供者地址"Terraform 上的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 terraform v0.14.3 部署一个 bitbucket 管道,以在谷歌云中创建资源.运行 terraform 命令后,管道失败并出现以下错误:

I'm trying to deploy a bitbucket pipeline using terraform v0.14.3 to create resources in google cloud. after running terraform command, the pipeline fails with this error:

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 更新为 v.0.13.0,然后运行:terraform 0.13upgrade,如本指南中所述:https://www.terraform.io/upgrade-guides/0-13.html.生成了需要 terraform 版本 >=0.13 的 versions.tf 文件,我们所需的提供程序块现在如下所示:

We updated our local version of terraform to v.0.13.0 and then ran: terraform 0.13upgrade as referenced in this guide: https://www.terraform.io/upgrade-guides/0-13.html. A versions.tf file was generated requiring terraform version >=0.13 and our required provider block now looks like this:

terraform {
  backend "gcs" {
    bucket      = "some-bucket"
    prefix      = "terraform/state"
    credentials = "key.json" #this is just a bitbucket pipeline variable
  }
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 2.20.0"
    }
  }
}
provider "google" {
  project     = var.project_ID
  credentials = "key.json"
  region      = var.project_region
}

我们在启动 bitbucket 管道时仍然遇到同样的错误.有谁知道如何克服这个错误?提前致谢.

We still get the same error when initiating the bitbucket pipeline. Does anyone know how to get past this error? Thanks in advance.

推荐答案

解决方案

如果您使用的是较新版本的 Terraform,例如 v0.14.x,您应该:

  1. 使用 replace-provider 子命令

terraform state replace-provider 
-auto-approve 
"registry.terraform.io/-/google" 
"hashicorp/google"

#=>

Terraform will perform the following actions:

  ~ Updating provider:
    - registry.terraform.io/-/google
    + registry.terraform.io/hashicorp/google

Changing x resources:

  . . .

Successfully replaced provider for x resources.

  • 再次初始化 Terraform:

  • initialize Terraform again:

    terraform init
    
    #=>
    
    Initializing the backend...
    
    Initializing provider plugins...
    - Reusing previous version of hashicorp/google from the dependency lock file
    - Using previously-installed hashicorp/google vx.xx.x
    
    Terraform has been successfully initialized!
    
    You may now begin working with Terraform. Try . . .
    

    应该负责安装提供程序.

    说明

    Terraform 一次仅支持从一项主要功能升级进行升级.您的旧状态文件很可能是使用早于 v0.13.x 的版本创建的.

    如果您在升级 Terraform 版本之前没有运行 apply 命令,则可能会出现此错误:从 v0.13.x 升级到 v0.14.x完整.

    If you did not run the apply command before you upgraded your Terraform version, you can expect this error: the upgrade from v0.13.x to v0.14.x was not complete.

    您可以在此处找到更多信息.

    You can find more information here.

    这篇关于“无效的旧提供者地址"Terraform 上的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆