terraform providers: Usage, lock & Common CI Errors
See your provider dependency tree - and lock it for every CI platform.
terraform providers prints the providers required across your configuration and modules. Its lock subcommand writes provider checksums for the platforms your CI runs on.
What it does
terraform providers displays a tree of provider requirements per module. terraform providers lock populates .terraform.lock.hcl with checksums for one or more target platforms so the same lock file verifies on macOS dev machines and Linux CI alike. There are also providers schema and providers mirror subcommands.
Common usage
# Show the provider requirements tree
terraform providers
# Lock checksums for the platforms your team + CI use
terraform providers lock \
-platform=linux_amd64 \
-platform=darwin_arm64
# Dump full provider schemas as JSON
terraform providers schema -jsonCommon error in CI: lock file missing platform checksums
init in Linux CI fails with "Inconsistent dependency lock file: the cached package ... does not match any of the checksums recorded" because the lock was generated only for your local OS. Fix: run terraform providers lock -platform=linux_amd64 -platform=darwin_arm64 (add every platform your team and runners use), commit .terraform.lock.hcl, then re-run init. This records checksums for all platforms up front instead of failing on the first foreign one.
Key subcommands
| Subcommand | Purpose |
|---|---|
| (none) | Print the provider requirement tree |
| lock -platform=... | Record checksums for given platforms |
| schema -json | Output full provider schemas |
| mirror DIR | Mirror providers to a local directory |