Azure DevOps error "inconsistent with the current configuration:"

Babychen Daisy, Dona 20 Reputation points
2023-08-25T13:24:43.8832043Z │ Error: Inconsistent dependency lock file
2023-08-25T13:24:43.8845301Z │ 
2023-08-25T13:24:43.8846010Z │ The following dependency selections recorded in the lock file are
2023-08-25T13:24:43.8846408Z │ inconsistent with the current configuration:
2023-08-25T13:24:43.8846857Z │   - provider required by this configuration but no version is selected
2023-08-25T13:24:43.8847312Z │   - provider required by this configuration but no version is selected
2023-08-25T13:24:43.8847619Z │ 
2023-08-25T13:24:43.8847957Z │ To make the initial dependency selections that will initialize the
2023-08-25T13:24:43.8857688Z │ dependency lock file, run:
2023-08-25T13:24:43.8858062Z │   terraform init

I am using Azure pipeline with DevOps and terraform. I am getting the above ereror. Please help.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
30,519 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 4,621 Reputation points

    I think your issue is related to the related to Terraform's dependency lock file. Starting with Terraform v0.14, a new feature was introduced: the dependency lock file (.terraform.lock.hcl). This file helps ensure consistent provider versions across all team members and CI/CD environments. When there's a mismatch between the Terraform configuration and this lock file, you might get errors like the one you've encountered.

    If you have any existing .terraform directory or .terraform.lock.hcl file in your repository or workspace, delete them. These can contain state and lock file data from previous Terraform runs.

       rm -rf .terraform .terraform.lock.hcl

    As the error suggests, you should run terraform init. This command will fetch the required providers and initialize the lock file.

       terraform init

    The .terraform.lock.hcl file, you should commit this to your repository.

       git add .terraform.lock.hcl
       git commit -m "Add/Update Terraform lock file"
       git push

    It's a good practice to specify versions for your providers. In your Terraform configurations, make sure you have something similar to:

    terraform {
         required_providers {
           azuread = {
             source  = "hashicorp/azuread"
             version = "~> 2.0"
           azurerm = {
             source  = "hashicorp/azurerm"
             version = "~> 2.50"

    Azure DevOps pipelines might cache data. If you still face the issue after following the above steps, try to reset or clear the pipeline cache. This ensures that old data doesn't interfere with your new configurations.

    0 comments No comments