0

I am simplying trying to terrafomr init a provider for opsgenie.

My version of terraform is:

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

and my provider is:

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"
    }
  }

The error I get is:

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.
0xtuytuy
  • 1,494
  • 6
  • 26
  • 51

1 Answers1

0

Your TF is too old, and your syntax is new. From docs:

The name = { source, version } syntax for required_providers was added in Terraform v0.13. Previous versions of Terraform used a version constraint string instead of an object (like mycloud = "~> 1.0"), and had no way to specify provider source addresses. If you want to write a module that works with both Terraform v0.12 and v0.13, see v0.12-Compatible Provider Requirements below.

You can try old syntax (or upgrade your 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"
  }
Marcin
  • 215,873
  • 14
  • 235
  • 294