Hamma
Hamma

Reputation: 37

Upgrade the version of terraform provider

I want to deploy this portion of code about azure frontdoor :

`

resource "azurerm_cdn_frontdoor_profile" "example" {
   name                = "example-cdn-profile"
  resource_group_name = "frdoor-p-to-01"
  sku_name            = "Standard_AzureFrontDoor"
  tags = {
    environment = "Production"
  }
}

`

But when i run the pipeline, i have this problem : │ Error: Failed to query available provider packages │ │ Could not retrieve the list of available versions for provider │ hashicorp/azurerm: no available releases match the given constraints ~> │ 3.27.0, 3.28.0

#--------------------------------------------------

I use a VM hosted agent (linux) I try to modify the provider file to the another version but the same error.

Some one have a solution please ?

`

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      #version = "~> 3.27.0"
            version = "=3.28.0"
      #version = "=2.97.0"
    }

`

I use a VM Hosted agent where terraform is installed and azure devops pipeline.

Upvotes: 1

Views: 3635

Answers (1)

Martin Atkins
Martin Atkins

Reputation: 74299

This error suggests that you have two modules in your configuration with contradictory version constraints: it isn't possible to require both exactly 3.28.0 and exactly 3.27.0 at the same time.

You can use the terraform providers command to learn which version constraints are specified in which of your modules. To proceed with this change you will need to make sure that there is at least one version that all of your modules declare that they are compatible with.

To avoid situations like this, it's better to only use lower-bound version constraints >= in your shared modules, declaring the minimum version that the module has been tested with, and leave the upper bound unspecified unless you already know that the module is incompatible with a later provider version. This means you can then gradually upgrade the provider without having to update the version constraints across all of your modules in lockstep.

The dependency lock file is the correct place to record exact version selections, and Terraform generates that automatically during terraform init so you do not need to edit it yourself. If you are using only >= constraints in your modules then you can run terraform init -upgrade whenever you wish to upgrade to the latest compatible version of each provider.

Upvotes: 2

Related Questions