Hi @Satish B
Thank you for reaching out to Microsoft Q&A.
The “Inconsistent dependency lock file” error occurs because Terraform enforces strict consistency between the configuration used during the plan phase and the one used during the apply phase. When a saved plan (tfplan) is created, Terraform embeds the selected provider versions and their checksums (from .terraform.lock.hcl) directly into that plan file. During terraform apply tfplan, Terraform verifies that the current working directory uses exactly the same provider selections and lock file as were present when the plan was generated. In your GitHub Actions workflow, the lock file is being modified after the plan is created (by running terraform providers lock again in the apply job). This causes a mismatch between the dependency selections stored inside the plan and the lock file present at apply time. As a result, Terraform intentionally fails to prevent applying infrastructure changes with a potentially different set of providers, which could lead to unpredictable or unsafe behavior.
Refer below points to resolve this issue or as a workaround
1. Do not modify .terraform.lock.hcl between Plan and Apply
Once terraform plan -out=tfplan is executed, the lock file must remain unchanged until terraform apply tfplan completes.
Remove any terraform providers lock or terraform init -upgrade commands from the apply job.
Ensure that the same .terraform.lock.hcl used during the plan phase is present and untouched during apply.
2. Commit the provider lock file to version control (Recommended approach)
The best practice is to generate the lock file once and commit it to the repository.
Generate the lock file (locally or in a controlled CI step):
terraform providers lock -platform=linux_amd64 -platform=linux_arm64
Commit .terraform.lock.hcl to Git.
In CI/CD, run only:
terraform init -upgrade=false
terraform plan -out=tfplan
terraform apply tfplan
This guarantees consistent provider versions across all pipeline runs and environments.
3. If you cannot commit the lock file, treat it as an immutable artifact
If organizational constraints prevent committing .terraform.lock.hcl, then:
Generate the lock file once during the plan job.
Upload it as an artifact along with tfplan.
In the apply job, download and use the same lock file without regenerating or modifying it.
Any regeneration of the lock file after the plan phase will cause the same inconsistency error.