【问题标题】:Provider versions set in required_providers, but terraform still complains在 required_providers 中设置了提供程序版本,但 terraform 仍然抱怨
【发布时间】:2021-01-03 10:36:18
【问题描述】:

我正在尝试以新的方式在 required_providers 中设置我的提供程序的版本,就像这样

terraform {
  required_providers {
    cloudflare = {
      source = "cloudflare/cloudflare"
      version = "~> 2.11.0"
    }
    google = {
      source = "hashicorp/google"
      version = "~> 3.39.0"
    }
    kubernetes = {
      source = "hashicorp/kubernetes"
      version = "~> 1.13.2"
    }
    vault = {
      source = "hashicorp/vault"
      version = "~> 2.14.0"
    }
  }
  required_version = "~> 0.13.2"
}

符合文档herehere

但是,当我运行 terraform init 时,我仍然得到以下输出。

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.

* -/google: version = "~> 3.39.0"
* -/kubernetes: version = "~> 1.13.2"
* -/vault: version = "~> 2.14.0"

我做错了吗?

这是terraform init的全部输出

❯ terraform init 

Initializing the backend...

Initializing provider plugins...
- Finding latest version of -/google...
- Finding latest version of -/kubernetes...
- Finding latest version of -/vault...
- Finding hashicorp/google versions matching "~> 3.39.0"...
- Finding hashicorp/kubernetes versions matching "~> 1.13.2"...
- Finding hashicorp/vault versions matching "~> 2.14.0"...
- Finding cloudflare/cloudflare versions matching "~> 2.11.0"...
- Installing hashicorp/google v3.39.0...
- Installed hashicorp/google v3.39.0 (signed by HashiCorp)
- Installing hashicorp/kubernetes v1.13.2...
- Installed hashicorp/kubernetes v1.13.2 (signed by HashiCorp)
- Installing hashicorp/vault v2.14.0...
- Installed hashicorp/vault v2.14.0 (signed by HashiCorp)
- Installing cloudflare/cloudflare v2.11.0...
- Installed cloudflare/cloudflare v2.11.0 (signed by a HashiCorp partner, key ID DE413CEC881C3283)
- Installing -/google v3.39.0...
- Installed -/google v3.39.0 (signed by HashiCorp)
- Installing -/kubernetes v1.13.2...
- Installed -/kubernetes v1.13.2 (signed by HashiCorp)
- Installing -/vault v2.14.0...
- Installed -/vault v2.14.0 (signed by HashiCorp)

Partner and community providers are signed by their developers.
If you\'d like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/plugins/signing.html

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.

* -/google: version = "~> 3.39.0"
* -/kubernetes: version = "~> 1.13.2"
* -/vault: version = "~> 2.14.0"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

【问题讨论】:

  • 这些-/name 提供者是您所在州的非命名空间提供者引用的临时表示。如果您运行terraform apply,那么它应该创建一个新的状态快照,其中自动升级(基于配置),然后未来的terraform init 运行不应再次提及它们。

标签: terraform terraform-provider-gcp


【解决方案1】:

@MartinAtkins'comment 变成答案:

这些-/name 提供程序是非命名空间的临时表示 您所在州的提供者参考。如果你运行terraform apply 那么它 应该使用自动升级的那些创建一个新的状态快照 (基于配置)然后未来 terraform init 运行 不应该再提他们。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 2022-11-13
    • 2011-02-22
    • 1970-01-01
    • 2016-02-16
    相关资源
    最近更新 更多