6

hi when i tried to run terraform plan in my azure ADF code, this error is popping out

please refer the attached image for more details

enter image description here

Adiii
  • 54,482
  • 7
  • 145
  • 148
  • 1
    Hi there! Please kindly paste the error message to the body of your questions instead of uploading the screenshot of it. Providing more background on how you "Run terraform plan in my azure ADF code" will also make it easier for others to understand and help you solve the problem you face. Cheers! – Raymond Aug 12 '21 at 06:31

3 Answers3

14

The error from the screenshot is: Error: resource version managed by newer provider version

Error description:

The resource was created using a newer provider version than you have on your machine. You specify which providers to use like azurerm >= 2.7, so if you have 2.7 in your local environment terraform will not update the provider you have downloaded when you run the INIT, however, if the resource was created using azurerm 2.8 by someone else, a pipeline, etc, you will receive the error because they just downloaded the most recent provider, which you don't have.

Quick Fix:

Delete the file .terraform.lock.hcl and the folder .terraform from the folder you store your terraform files and run terraform init once again. Terraform will recreate the lock file and download the newest providers.

How to avoid it in the future:

Include the file .terraform.lock.hcl as part of the source code, this way everyone will use the same provider versions.

sources:

Gabriel Molter
  • 333
  • 2
  • 10
5

Maybe try

terraform init -upgrade
user2654744
  • 438
  • 5
  • 8
0

I was using terragrunt with remote s3 state and dynamo db and sadly this does not work for me.

I have to re-generate the provider with the desired version

terraform {
  source = "git::git@gitlab.com:abc/postgres?ref=1.39.2"
}
locals {
  aws-provider = yamldecode(file("${find_in_parent_folders("aws-provider.yaml")}"))
}

inputs = {
  aws_region               = local.aws-provider.aws_region
  version                  = local.aws-provider.version
  profile                  = local.aws-provider.profile
  environment              = local.common-vars.environment
......
}

generate "provider" {
  path      = "provider.tf"
  if_exists = "overwrite"
  contents = <<EOF
provider "aws" {
  region              = "${local.aws-provider.aws_region}"  
  profile             = "${local.aws-provider.profile}"
  version             = "${local.aws-provider.version}"
}
EOF
}
Adiii
  • 54,482
  • 7
  • 145
  • 148