Interview Prep/Terraform/Dependencies, Cycles and Providers

`Error: Inconsistent dependency lock file` with `provider registry.terraform.io/hashicorp/random: required by this configuration but no version is selected`.

BeginnerTroubleshootingDependencies, Cycles and Providers
Answer

Likely causes → A new provider was introduced (directly or by a new module) and terraform init wasn't re-run, or the lock file in CI is older than the code.

Diagnose → terraform providers shows random but the lock file lacks it.

Fix → terraform init locally (adds the entry), commit .terraform.lock.hcl.

Prevent → CI should run terraform init -lockfile=readonly so missing entries fail early in PR checks, not at apply time.

All Terraform questions Roadmap: Terraform

More on Dependencies, Cycles and Providers