Skip to content

"terraform providers lock" does not lock providers required by tests #37841

@zanecodes

Description

@zanecodes

Terraform Version

Terraform v1.13.3
on darwin_arm64

Terraform Configuration Files

versions.tf

terraform {
  required_providers {
    dns = {
      source  = "hashicorp/dns"
      version = "~> 3.4"
    }
  }
}

tests/versions.tf

terraform {
  required_providers {
    vault = {
      source  = "hashicorp/vault"
      version = "~> 5.3"
    }
  }
}

tests/test.tftest.hcl

run "test" {
  module {
    source = "./tests"
  }
}

Debug Output

N/A

Expected Behavior

Checksums for both hashicorp/dns (required by the root Terraform module) and hashicorp/vault (required by the tests Terraform module, which itself is required by tests/test.tftest.hcl) should be recorded in .terraform.lock.hcl, so that terraform init -lockfile=readonly can install the locked provider versions required by both terraform plan and terraform test commands

Actual Behavior

Only the checksum for hashicorp/dns is recorded in .terraform.lock.hcl, causing terraform init -lockfile=readonly to fail when it tries to add hashicorp/vault to .terraform.lock.hcl, since terraform init respects the providers required by modules in tests/test.tftest.hcl, but terraform providers lock does not

Steps to Reproduce

  1. terraform providers lock
  2. terraform init -lockfile=readonly

Additional Context

No response

References

No response

Generative AI / LLM assisted development?

No response

Metadata

Metadata

Assignees

Labels

bugconfirmeda Terraform Core team member has reproduced this issuenewnew issue not yet triagedterraform test

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions