Safeguard
Developer Tools•

How do you run Terraform providers from a local or air-gapped mirror?

Use terraform providers mirror to copy providers to a folder, then point provider_installation at it. Layout, lock file steps and checks, explained.

Safeguard Security Team
3 min read

To run Terraform where the public registry is unreachable, copy the providers into a directory with terraform providers mirror, then configure a filesystem_mirror in the CLI configuration. Add official checksums to the lock file so the mirror is checked against the origin.

Step 1: build the mirror

On a machine with registry access:

terraform providers mirror -platform=linux_amd64 ./mirror

Terraform creates the directory structure it expects and fills it with the provider zip files. It also writes index files that can serve the network mirror protocol if you upload the folder to a static host. For a filesystem mirror, Terraform ignores those index files and treats the directory entries as authoritative.

By default the command uses the lock file versions if the directory was already initialized, and it builds for the platform where you run it unless you pass -platform.

Step 2: point Terraform at the mirror

In the CLI configuration file, a provider_installation block selects the method:

provider_installation {
  filesystem_mirror {
    path    = "/usr/share/terraform/providers"
    include = ["registry.terraform.io/*/*"]
  }
}

Each installation method accepts include and exclude patterns, and exclusions win if both match. A direct block fetches from the origin registry. A network_mirror block uses an HTTPS server.

Step 3: protect the mirror with checksums

A first install from a mirror cannot verify checksums for other platforms. HashiCorp suggests running terraform providers lock to pre-populate the official checksums, after which terraform init verifies that the packages in your mirror match the official ones. Without this step, a mirror is trusted simply because it is your mirror.

Choosing a method

MethodFits whenWatch for
DirectNormal internet accessRegistry availability
Filesystem mirrorIsolated build hostsKeeping the folder updated and access controlled
Network mirrorMany hosts, one internal serverSecuring the HTTPS server and its content

Operational checks

  • Restrict who can write to the mirror, since it becomes your provider source.
  • Rebuild the mirror when provider versions change, and review the lock file diff in the same pull request.
  • Keep the platform list in sync with the platforms that run Terraform.

Try it yourself

Click through it at your own pace, or open it full screen. Notice how a changed dependency gets flagged over time, the same habit you want for a provider mirror.

Quick check

Does a mirror replace the lock file?

No. The lock file still records versions and checksums, and it is what lets Terraform compare mirror packages with official ones.

Can I mirror only some providers?

Yes. Include and exclude patterns choose which providers each installation method serves.

Does Terraform need the registry at all with a mirror?

Not if you configure installation to use only the mirror and the checksums are already in the lock file.

Safeguard offers SBOM and dependency scanning and policy gates that can block a pull request on findings, and you can try a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.