0

我只是想terrafomr init成为 opsgenie 的提供者。

我的 terraform 版本是:

Terraform v0.12.6

Your version of Terraform is out of date! The latest version
is 0.14.10. You can update by downloading from www.terraform.io/downloads.html

我的提供者是:

terraform {
  # https://www.terraform.io/docs/configuration/terraform.html#specifying-a-required-terraform-version
  required_version = "~> 0.12"

  # https://www.terraform.io/docs/configuration/provider-requirements.html
  required_providers {
    opsgenie = {
      source  = "opsgenie/opsgenie",
      version = "~> 0"
    }
  }

我得到的错误是:

There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Invalid version constraint

  on provider.tf line 16, in terraform:
  16:     opsgenie = {
  17:       source = "opsgenie/opsgenie"
  18:       version = "0.6.3"
  19:     }

A string value is required for opsgenie.
4

1 回答 1

0

你的 TF太旧了,你的语法是新的。来自文档

在 Terraform v0.13 中添加了required_providers 的 name = { source, version } 语法。以前版本的 Terraform 使用版本约束字符串而不是对象(如 mycloud = "~> 1.0"),并且无法指定提供程序源地址。如果您想编写一个适用于 Terraform v0.12 和 v0.13 的模块,请参阅下面的 v0.12-Compatible Provider Requirements。

您可以尝试旧语法(或升级您的 TF):

terraform {
  # https://www.terraform.io/docs/configuration/terraform.html#specifying-a-required-terraform-version
  required_version = "~> 0.12"

  # https://www.terraform.io/docs/configuration/provider-requirements.html
  required_providers {
    opsgenie = "~> 0"
  }
于 2021-04-08T22:03:10.183 回答