gonfy
gonfy

Reputation: 454

Conflicting provider version contraints in Terraform tutorial

I’m following the Target Resources tutorial and I get the following failure when I run the terraform init setup step:

│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/aws: locked provider registry.terraform.io/hashicorp/aws 3.39.0 does not match configured version
│ constraint ~> 3.39.0, >= 3.50.0; must use terraform init -upgrade to allow selection of new versions

Running terraform init -upgrade results in this similar error message:

│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/aws: no available releases match the given constraints ~> 3.39.0, >= 3.50.0

It looks like the ~>3.39.0 version specified in ./main.tf conflicts with the >=3.5.0 contraint from the s3_bucket module (.terraform/modules/s3_bucket/versions.tf).

I’ve tried cloning a clean version of the tutorial repository and keep running into this error. Is this a problem with my local configuration or with the tutorial code? If the latter, what’s the best way to move past this? Should I adjust one of the constraints manually to resolve the conflict?

I am using a much newer version of the Terraform CLI (v1.0.7) where the tutorial text requires v0.14 and up. I haven't gotten a chance to downgrade and test again, but that would be interesting to see.

thanks!

Upvotes: 2

Views: 2696

Answers (1)

Matthew Schuchard
Matthew Schuchard

Reputation: 28774

There is a bug in the main.tf located in the root module config in the repository for that tutorial. The bug is located here. The line should be modified and the resulting argument object appear like:

aws = {
  source  = "hashicorp/aws"
  version = "~> 3.39"
}

That will lock the version to the range >= 3.39.0 < 4.0.0, which is almost certainly the config's original intent. You can read more about the syntax behind the provider version specifications in the documentation.

Upvotes: 4

Related Questions