skip to Main Content

I have a simple terraform configuration as follows.

# Terraform settings Block
terraform {
  required_version = "~> 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm" # https://registry.terraform.io/providers/hashicorp/azurerm/latest
      version = "~> 3.0"
    }
  }
}

provider "azurerm" {
  features { }
}

resource "azurerm_resource_group" "rg" {
  name     = var.resource_group_name
  location = var.resource_group_location
}

When I run

terraform init

I get the following error.

╷
│ Error: Unsupported Terraform Core version
│
│   on main.tf line 3, in terraform:
│    3:   required_version = "~> 1.0.0"
│
│ This configuration does not support Terraform version 1.2.2. To proceed, either choose another supported Terraform version or update this version
│ constraint. Version constraints are normally set for good reason, so updating the constraint may lead to other errors or unexpected behavior.    
╵

If the required version is set the following way, it works fine(Changed ~> to >=).

required_version = ">= 1.0.0"

Looked at this doc, but not clear what to do. Should I revert back to required_version = ">= 1.0.0"

Just wanted to ensure that lastest minor is in place. Also read somewhere that for production, the one with tilde(~) is recommended. Bit confused now.

2

Answers


  1. You have already installed TF version 1.2.2, which obviously is far newer then 1.0.0. If you want to use such an old version of TF, you have download older version of terraform, and use that to run your scripts.

    Login or Signup to reply.
  2. I had the same issue after upgrading both the terraform and the azurerm terraform provider to the latest versions (up to the date of writing this answer):

    terraform {
      backend "azurerm" { }
    
      required_version = "1.2.5"
      required_providers {
        azurerm = {
          source  = "hashicorp/azurerm"
          version = "3.14.0"
        }
      }
    }
    

    I managed to fix the issue locally by using an older version of terraform (1.2.3 instead of 1.2.5), so I’m guessing the issue you experienced is similar to mine.

    terraform {
      backend "azurerm" { }
    
      required_version = "1.2.3"
      required_providers {
        azurerm = {
          source  = "hashicorp/azurerm"
          version = "3.14.0"
        }
      }
    }
    

    However, when running terraform in a ubuntu 20.04 agent in Azure DevOps pipelines the exact same provider configuration, I was still getting the same error (for some weird reason – a bug maybe? – the pipeline would try to use terraform 1.2.4, when I locked it to 1.2.3) … I was able to fix it by using the same versions with >= :

    terraform {
      backend "azurerm" { }
    
      required_version = ">=1.2.3"
      required_providers {
        azurerm = {
          source  = "hashicorp/azurerm"
          version = ">=3.14.0"
        }
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search