Skip to content

Install providers from registries and mirrors

Netherframe runs Terraform providers itself, so it fetches them itself: when an app, nf drift or nf generate providers needs a provider version that is not in the provider cache, it is installed the way terraform init installs it. Terraform is not needed for this, and nothing of Terraform's configuration is read: where providers come from is a matter of Netherframe's own settings.

Where providers come from

Without settings, a provider comes from its own registry: hashicorp/aws from registry.terraform.io, registry.example.com/acme/widget from registry.example.com. A registry is found by service discovery (https://<host>/.well-known/terraform.json, its providers.v1 service), and speaks the provider registry protocol.

In environments that may not reach registries, mirrors serve providers instead:

Setting Flag What it is
provider_mirrors --provider-mirror URL\|DIR, once per mirror Mirrors, asked in order. An https URL is a server of the provider network mirror protocol (Artifactory, Nexus, or a static site written by terraform providers mirror); anything else is a directory laid out as terraform providers mirror writes it
provider_mirror_include --provider-mirror-include PATTERNS The providers served by mirrors that name none of their own (default all)
provider_direct --provider-direct / --no-provider-direct Whether registries are asked too

In [tool.nf.config], a mirror may also be a table naming the providers it serves, with Terraform's include and exclude:

[tool.nf.config]
provider_mirrors = [
  { url = "https://mirror.example.com/terraform/providers/", include = ["hashicorp/*"] },
  { path = "/srv/terraform-providers", exclude = ["hashicorp/*"] },
  "https://artifactory.example.com/artifactory/api/terraform/terraform-remote/providers/",
]

Mirrors are asked first, in the order given, each for the providers it serves. Then:

  • a mirror with patterns (include or exclude) is the only source of the providers it serves; registries serve the rest (as a Terraform mirror block with include, followed by direct { exclude = ... });
  • a mirror without patterns serves every provider, so no registry is asked (as a provider_installation block that names only mirrors);
  • with provider_direct on as well, registries back such a mirror up;
  • --no-provider-direct never asks a registry.

When several sources serve a provider, its versions are those any of them has, and a package comes from the first that has it. A source that did not list a version is not asked for it. Terraform does ask it, and a network mirror's "not found" then stops the installation.

Patterns are Terraform's: hashicorp/aws, hashicorp/* (on registry.terraform.io), example.com/*/*, */*/*. On the command line they are comma-separated; in [tool.nf.config] they may be a list.

An Artifactory remote repository

An Artifactory Terraform repository serves the network mirror protocol at https://<host>/artifactory/api/terraform/<repository>/providers/:

[tool.nf.config]
provider_mirrors = ["https://artifactory.example.com/artifactory/api/terraform/terraform-remote/providers/"]
provider_credentials_file = "~/.terraform.d/credentials.tfrc.json"

Every provider then comes from Artifactory, and registry.terraform.io is never contacted.

Internal providers from their own mirror

[tool.nf.config]
provider_mirrors = [
  { url = "https://providers.internal.example.com/mirror/", include = ["registry.internal.example.com/*/*"] },
  "https://artifactory.example.com/artifactory/api/terraform/terraform-remote/providers/",
]

The internal registry's providers come from the internal mirror (and from Artifactory, if it has versions the internal one lacks); every other provider from Artifactory only.

Some providers from a mirror

[tool.nf.config]
provider_mirrors = ["https://mirror.example.com/terraform/providers/"]
provider_mirror_include = ["hashicorp/*", "registry.example.com/*/*"]

HashiCorp's providers and those of registry.example.com come from the mirror; others from their registries.

Offline

A directory filled by terraform providers mirror (on a machine that can reach the registries) serves an offline one:

terraform providers mirror -platform=linux_amd64 /srv/terraform-providers
nf --provider-mirror /srv/terraform-providers apply

Both layouts are read: HOST/NAMESPACE/TYPE/terraform-provider-TYPE_VERSION_OS_ARCH.zip (packed) and HOST/NAMESPACE/TYPE/VERSION/OS_ARCH/ (unpacked). Symbolic links are followed for the base directory and for packages themselves, not for the directories between them.

Credentials and certificates

provider_credentials_file names a JSON file of tokens, in the shape of Terraform's credentials.tfrc.json, so the file terraform login writes can be named as it is:

{"credentials": {"artifactory.example.com": {"token": "..."}}}

A token is sent as Authorization: Bearer <token> to its own host only: a mirror that redirects a download to another host (object storage) does not pass it on. A host that answers 401 or 403 is reported with whether a token was given for it. The file is read again when it changes.

Certificates are the system's (SSL_CERT_FILE and SSL_CERT_DIR apply); provider_ca_bundle adds a PEM bundle to them, for a mirror whose certificate an internal authority issued. Proxies come from HTTPS_PROXY, HTTP_PROXY and NO_PROXY, as for other tools.

What a package is checked against

Source Check Reported as
A registry The archive's SHA-256 is the registry's; the registry's SHA256SUMS lists it under the package's file name; the SHA256SUMS is signed (OpenPGP) by a key the registry names signed by HashiCorp, signed by a HashiCorp partner, or self-signed
A network mirror The package has one of the mirror's hashes (h1: or zh:) verified checksum
A filesystem mirror Nothing: the directory is trusted

A signature by HashiCorp's key makes a provider official; one by a key HashiCorp's partners key vouches for (the registry's trust signature) makes it a partner's; any other key the registry names makes it the author's own (a community provider). A package that fails a check is not installed. Each installation is logged at INFO with how it was checked and by which key.

A provider version whose protocols Netherframe does not speak (5 and 6) is refused, naming the newest version that does.

The provider cache

Installed providers are kept in provider_cache_dir (default ~/.nf/providers), which every app on the machine shares, as Terraform's plugin cache is shared: NAMESPACE/TYPE/VERSION/OS_ARCH/ for registry.terraform.io, HOST/NAMESPACE/TYPE/VERSION/OS_ARCH/ for others. A version in the cache is never fetched again. A version constraint (~> 5.0) takes the newest cached version that meets it, and otherwise the newest its sources have; latest (or no version) takes the newest version that is not a pre-release, as Terraform does.

A provider's binary_path uses a binary you built instead (Terraform's dev_overrides).

Differences from Terraform

  • Terraform's CLI configuration (~/.terraformrc, TF_CLI_CONFIG_FILE, TF_TOKEN_*, credentials helpers) is not read: the settings above say the same things. Legacy stacks (--stack), which Terraform or OpenTofu runs, still install providers as that tool's own configuration says.
  • Registries have no patterns of their own: they serve what no mirror with patterns serves.
  • No dependency lock file: the cache keeps the versions an app has used.