Provider Binaries Are Executable Supply-Chain Dependencies
A provider is code you did not write, running with your authority. terraform init downloads a platform-specific plugin, and every later plan or apply starts that plugin as a child process. It reads the environment, opens state and plan files, reaches the network, and uses whatever cloud credentials the Terraform process can see. The plugin protocol is a contract about messages, not a sandbox. The baseline here is Terraform 1.17.1, the release this series pins, and the install behaviour described below is that release's.
The source address is a routing decision with a trust consequence. A required_providers entry names a host, a namespace and a type. By default that host is also the registry Terraform contacts, so hashicorp/aws means the public registry and a private hostname means your own. Change the installation method and the hostname stops being a location: it becomes only an identifier, and a mirror can serve that provider from anywhere.
Two properties are easy to conflate. Authenticity asks whether the publisher really produced this build. Integrity asks whether the bytes you received are the bytes that were described. A checksum gives you integrity. A signature over the checksum list is what can give you authenticity, and only when the signing key is one you have already decided to trust.
The first install is the trust decision. Terraform records hashes on first use, which is trust on first use. If that first install came from a mirror, the mirror supplied the hashes, and every later verification proves only that the mirror agrees with itself. Pre-populating from the origin registry is what turns the lock file into an independent reference rather than a receipt.
A restricted network changes the path, not the privilege. An air gap stops a plugin from reaching the public internet while it is being downloaded. It does not stop an installed plugin from reading a cloud token from the environment or calling an internal API once it starts. The mirror narrows where code comes from; it does not narrow what code can do.
The flow below follows one provider address from declaration to a running process. The branch that matters is not which mirror you choose, but which party supplied the hash that the install is checked against.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
A["required_providers: host, namespace, type"] --> B{"Install method for this address"}
B -->|"direct"| C["Origin registry returns versions and signed checksums"]
B -->|"filesystem mirror"| D["Directory listing is the version index"]
B -->|"network mirror"| E["HTTPS index and version documents"]
C --> F["Terraform selects one version and fetches this platform"]
D --> F
E --> F
F --> G{"Package matches a recorded hash?"}
G -->|"no"| H["init stops with a checksum error"]
G -->|"yes"| I["Plugin installed under the working directory"]
I --> J["Plugin starts as a child process"]
J --> K["Reads environment, state and plan files"]
J --> L["Uses the runner cloud identity"]
J --> M["Opens its own network connections"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class A,B,F,G primary;
class C,D,E secondary;
class I,J ok;
class H danger;
class K,L,M warn;
Verification happens before execution, and only on the package. Nothing in the download step inspects what the plugin will do after it starts. That asymmetry is why the install path deserves the same review as a production dependency, and why a mirror operator is a trust role rather than a file-copying role.
The next figure places the same path inside three zones. The dashed boundaries are not network diagrams; they mark where a different party is able to change what Terraform will run.
A Cache Improves Speed; a Mirror Changes Distribution
A cache is a shortcut inside the existing install path. plugin_cache_dir stores unpacked plugin packages so a second working directory reuses them instead of downloading again. Terraform still asks the configured installation methods which versions exist, and only then looks in the cache. A cache cannot bootstrap a machine with no route to a registry, and it is explicitly not an authoritative source, which is why locking from it is a weaker act.
A mirror replaces the distribution path. It answers both questions init asks: which versions exist, and where the bytes are. A filesystem mirror answers by directory layout; a network mirror answers by JSON documents over HTTPS. Because both answers arrive from inside the boundary, a mirror can serve a runner that has no registry route at all.
The plugin cache has two hard edges. It must not also be configured as a mirror directory, because the cache and mirror logic conflict over the same files. And Terraform documents it as not guaranteed concurrency-safe, so several init runs sharing one cache on a build host is undefined behaviour rather than a mild performance risk.
An explicit installation block replaces the implied one. With no provider_installation block, Terraform treats several user and system plugin directories as implied mirrors and adds an implied direct method, automatically excluding providers it found locally. Write the block explicitly and you own the list. A lone filesystem mirror means no fallback, which is exactly what an air gap requires.
Version selection is across methods, not per method. Terraform collects candidates from every method whose include and exclude patterns match, then picks the newest version that satisfies the constraint. A mirror holding an old package plus an enabled direct method does not force the mirror; it quietly goes to the registry. Excluding direct is the only way to make the mirror authoritative.
Packed and unpacked layouts behave differently at install time. A packed mirror holds the original zips under the host, namespace and type path. An unpacked mirror holds extracted directories, and Terraform links them into the working directory instead of copying. That is fast on a laptop, but a read-only mount or a copy that does not preserve links makes the unpacked layout a poor fit for a runner image.
A network mirror is a small HTTP contract with one dangerous default. The base URL must use HTTPS and end with a trailing slash. Each provider has an index of versions, and each version lists an archive URL per platform with optional hashes. If those hashes are omitted, Terraform installs the archive with no verification from the mirror response, leaving only whatever the lock file already records.
The four distribution paths differ in where metadata comes from, not just in where bytes come from. That is why replacing one with another changes the trust boundary.
Init has four decision points, and each one has a failure branch. The flow traces them: method selection, platform availability, hash agreement and lock file mutation. Only the last is usually allowed to change anything, and on a promoted runner it should not be.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
A["Configuration constraints plus lock file"] --> B["Collect matching installation methods"]
B --> C{"Direct method still enabled?"}
C -->|"yes"| D["Origin registry is a candidate source"]
C -->|"no"| E["Mirror is the only source"]
D --> F["Read versions from every matching method"]
E --> F
F --> G["Choose newest version that satisfies the constraint"]
G --> H{"Package for this platform?"}
H -->|"no"| I["Stop: no package for this platform"]
H -->|"yes"| J["Download or read the archive"]
J --> K{"Hash matches the lock entry?"}
K -->|"no"| L["Stop: checksum error, nothing installed"]
K -->|"yes"| M{"Lock entry complete?"}
M -->|"no, writable"| N["Append hash and review the diff"]
M -->|"no, readonly"| O["Stop: lock file would change"]
M -->|"yes"| P["Install and start the plugin"]
N --> P
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class A,C,G,M primary;
class B,D,E,F,J secondary;
class P ok;
class I,L,O danger;
class H,K warn;
Lock Providers Across OS and CPU Platforms
The lock file is a claim about bytes, per platform. Each provider entry records the selected version, the constraints that produced it, and hashes for the packages Terraform has seen. Cross-platform work fails not because the version is wrong but because the entry has no hash for the machine running init.
The two hash schemes answer different questions. A zh: value is a SHA-256 of the published zip, tied to the exact archive the registry serves. An h1: value is a SHA-256 of the package contents, so it survives recompression, a different archiver and the unpacked mirror layout. Terraform prefers the content hash and adds it opportunistically as it meets new platforms.
terraform providers lock exists for that platform gap. It consults origin registries, downloads the official package for every platform you name, and writes both schemes. Run it on a connected host, not on the runner, and read the signing-key fingerprints it prints: the command can report them but cannot decide whether you trust them.
Locking from a mirror is a different claim. With the mirror options, the command records only the platforms you requested and only the checksums the mirror reports. That is correct for a provider with no public registry and wrong for one that has a registry, because it moves the authenticity anchor to whoever built the mirror.
Then insist that the lock file cannot move at runtime. A readonly lockfile makes init verify the recorded selection and fail instead of appending a hash for a new platform. That turns a silent platform addition into a failed job, which is the behaviour a promotion gate needs.
Signatures and checksums are not interchangeable. Terraform verifies a signed checksum document from the registry, and once one package hash matches it treats the other signed hashes as valid too. That is why a single install can fill in every platform at once. A mirror carries no such document, so nothing on the mirror path tells you who chose the list.
The panel is the whole lock workflow: inspect, pre-populate from origin, build the mirror, then verify without allowing a rewrite.
What the lock file cannot tell you is as important as what it can. It records bytes for named platforms. It does not record who built the package, who reviewed the upgrade, which CLI version ran, or which remote modules were fetched. Those remain separate controls, and a mirror only covers the first item.
The figure separates the part a hash validates from the part it leaves to process. The amber platform is the common failure: a correct lock file that simply does not describe the machine that is running.
Promote Verified Artifacts into Restricted Environments
Promotion is a release process, not a copy. The artefact that crosses the boundary is a bundle: the mirror directory, the lock file, and a record of what was verified. Treat it like a container image release. Build it once, identify it by digest, approve it, then consume it unchanged.
The lock file is the specification the mirror must satisfy. Build the mirror from the same configuration and the same lock file that will ship, with the platform list taken from the runner inventory. A mirror holding an extra version is not a bonus; it is an unapproved artifact sitting inside the trust boundary.
Verification belongs on the connected side, before transfer. Three checks matter: the lock file was produced against origin registries and its signing keys were reviewed; the mirror serves exactly the locked versions; and a clean init against the mirror succeeds with a readonly lock. The first is authenticity, the second is inventory, the third is fitness.
Seal the bundle so the receiving side can detect substitution. Hash the archive and sign that digest with the organization's release key, then store it under an immutable name that includes the configuration commit. The runner then needs one public key, not registry credentials and not a fresh judgement about a provider vendor.
Ownership has to be named, or the process decays. A provider version bump is an application change and belongs to the team that uses the provider. Adding a platform is a capacity and security change. Changing the mirror format, signing key or serving path is a platform change. When all three land in one unnamed queue, the first urgent fix bypasses all of them.
Serving is the smallest part, and it has one trap. A network mirror needs HTTPS, a trailing slash and valid JSON; a filesystem mirror needs a directory Terraform can read. Generating the JSON with the mirror command keeps the hashes populated. Hand-write the index and it is easy to omit the hashes field, after which the mirror serves packages with no verification of its own.
Revocation is a deliberate outage. If a provider version must be withdrawn, remove it from the mirror and raise the constraint in the same change, then rebuild. Pulling a version while the lock file still pins it turns every runner into a failed init. That outcome is correct, but it should be a decision rather than a surprise.
The figure contrasts the two shapes of the problem. On the left every runner makes its own trust decision at run time; on the right the decision is made once and every runner only verifies a fixed artefact.
Two policies keep the bundle honest. First, a version directory in the mirror is immutable once published; a correction ships as a new bundle with a new digest, even when the package bytes are identical. Second, the approval record names the provider addresses and versions it covers, so a later reviewer can tell which change introduced a package without reconstructing the pipeline.
The runner configuration is part of the artefact, not local folklore. The CLI configuration that points at the mirror should be baked into the image and identified by the same digest. If it lives in a home directory, drift returns through the one file nobody reviews.
Test Initialization Without Public Registry Access
A mirror is not proven until init has run with no route out. Configuration review cannot show that every package is present, that every platform hash matches, or that no fallback path remains. Only an init on a host that cannot reach the registry can show those things.
Make the test hostile. Use a clean working directory containing only the configuration and the lock file, a CLI configuration that lists the mirror and nothing else, a read-only mount of the bundle, and a network namespace with no default route. If the test host still has registry access, a missing package can be fetched silently and the rehearsal proves nothing.
Inventory first, then break it on purpose. The inventory is the list of provider addresses, versions and platforms the estate actually runs. The rehearsal should prove the happy path and at least two failure paths: an empty mirror must fail, and a tampered package must fail the checksum. A test that only proves success cannot distinguish verification from luck.
Record evidence that outlives the terminal. Capture the CLI version, the lock file commit, the bundle digest, the init exit status and the provider list init installed. Those five items let a reviewer reconstruct the run without trusting the person who performed it.
Then make the rehearsal repeatable. The same script should run on every bundle promotion, before approval. A one-off air-gap test is a project; a promotion gate is a control.
Design the provider promotion path
Execution status: design-only. No output below is presented as observed. You run the rehearsal and keep your own evidence.
Goal. Move a small configuration from "init works on my laptop" to "init works on a runner with no registry route, and fails when the mirror is wrong".
Prerequisites. A connected host with registry access, and a restricted host or a container runtime that can start a container with no network. Terraform 1.17.1 on both, a scratch configuration with two providers, and a way to move a directory across the boundary.
- Write the inventory before touching a mirror. For each provider, record the address from the configuration, the version in the lock file, and every platform used by developer laptops and runner images.
- On the connected host, check out the exact commit to promote and run
terraform init. Confirm the lock file is tracked by version control before you change anything in it. - Run
terraform providers lockwith one platform flag per inventory entry. Read every signing-key fingerprint it prints and write the accepted fingerprints into the change record. - Run
terraform providers mirroragainst a fresh output directory with the same platform list. Confirm the layout is host, namespace, type and that only locked versions appear. - Prove the mirror against the lock before transfer: point a temporary CLI configuration at the directory, run
terraform init -lockfile=readonly, thenterraform providersand compare with the lock entry. - Seal the bundle. Archive the mirror and the lock file together, hash the archive, sign the digest with the release key, and record both the digest and the configuration commit.
- Publish once into the internal artifact store under an immutable path. Do not edit a published directory; a correction is a new bundle with a new digest.
- On the restricted side, start from an empty directory containing only the configuration and the lock file. Point
TF_CLI_CONFIG_FILEat a mirror-only configuration file and run init with the lock readonly in a container that has no network and a read-only mount. - Break it twice. Point the configuration at an empty mirror directory and confirm init fails rather than reaching a registry. Restore it, replace one archived provider file with a corrupted copy, and confirm init fails on the checksum. Restore the original and run once more to show the result is repeatable.
The finished record answers these questions, and each answer has an artefact behind it:
| Field | Evidence |
|---|---|
| Provider addresses | the required_providers block at the promoted commit |
| Locked versions | the lock entry in that commit |
| Platforms covered | the platform flags used for locking and mirroring |
| Bundle identity | the signed archive digest |
| Approver and date | the change record that names versions and platforms |
Expected observation. Init succeeds with no registry route, the working directory gains a package for each provider on the platform, and a second run leaves the lock file byte-identical. The empty-mirror and tampered-package runs both fail, and they fail at different points: one cannot find a package, the other finds a package it refuses.
Failure checks. If init succeeds with the network blocked but the CLI configuration still contains a direct method, the test proved nothing about the mirror. If init appends hashes, the lock file was incomplete for that platform. If the bundle digest after transfer differs from the approved digest, stop and rebuild rather than repairing the copy.
Cost dimensions. Disk and transfer only. The mirror grows with providers multiplied by platforms, and every provider zip is kept for the life of the pinned version. No cloud account, credential or billable resource is involved.
Cleanup. Delete the scratch working directories and the transferred copy used for the rehearsal. Keep the signed digest, the lock commit and the rehearsal result in the change record; deleting those removes the only evidence that the control ran.
References (checked 6 November 2026): Dependency lock file, terraform providers lock, terraform providers mirror, provider installation configuration, provider network mirror protocol, and plugin signing.