Providers Reference
Requirements, blocks, aliases, sources and the lock file. There is no configure step: the configuration’s provider {} blocks are the provider configuration, and the engine evaluates them at every plan — in dependency order, against state, the plan so far and the variable values — and configures each plugin from the result.
Requiring and installing
Section titled “Requiring and installing”Declare each provider in required_providers and pin it (~> MAJOR.MINOR):
terraform { required_providers { aws = { source = "hashicorp/aws", version = "~> 5.0" } }}init installs what the root module and every child module require, and reports each in providers[] as the lock file records it — provider (its address), resolved version, constraints, hashes — with its package_dir. After adding a provider or changing a constraint, re-run init (path may be omitted: the alias’s registered directory), then up. The open workspace needs nothing: the engine reads the directory at every plan.
- An entry with no
constraintsis pinned by nothing: either it was never declared (its address is the one OpenTofu implies for the name,random→hashicorp/random) or it was declared without aversion. Declare it with one. - A provider that fails to install is reported with its
errorrather than failinginit. open’swarningsmay name state recorded under a provider the configuration no longer declares. Restore itsproviderblock: a destroy that routes through it needs it.
The lock file
Section titled “The lock file”init records the selections in .terraform.lock.hcl (lock_file: created, updated, unchanged, or not_updated when a provider failed to install), as tofu init does, and every plan installs what the lock selects, checksums verified. Commit it with the configuration. A provider added since, or a constraint the locked version no longer meets, is refused as an “Inconsistent dependency lock file”: run init again, with upgrade: true to move a locked version. A change to the lock file makes a paused plan stale.
Source formats
Section titled “Source formats”| Format | Registry | Example |
|---|---|---|
namespace/name |
the OpenTofu registry | hashicorp/aws |
hostname/namespace/name |
a custom registry | registry.acme.com/internal/mycloud |
A private registry authenticates with tofu login <host> or TF_TOKEN_<host>. A provider mirror is set in the user’s CLI configuration, never in the .tf files (skill_deployment → references/credentials.md).
Provider blocks
Section titled “Provider blocks”provider "azurerm" { subscription_id = var.subscription_id features {}}- A provider with no settings needs no block: a required provider without one is configured empty, as in Terraform. Providers that read credentials from the environment (AWS, Azure, GCP) work that way — the environment is the engine’s, with the variables this server’s provider environment names (
skill_deployment → references/credentials.md). - Every aliased instance needs its own block.
- A schema-sensitive attribute arrives as an expression (
var.token), never a literal. - Only the root module declares provider blocks. A module that declares its own is refused (a legacy shape): the module declares
configuration_aliasesin itsrequired_providers, and the caller passes configurations in the call’sproviders = { … }map.
Expressions in provider blocks
Section titled “Expressions in provider blocks”A block may reference resources, data sources and variables:
- An applied resource → its real value. Secrets read from state are sent to the plugin without being echoed back to you.
- A resource planned but not yet applied → unknown. What that provider serves and needs the value defers to the next round (
provider_config_unknown), andapplyplans it there by itself. Leave the block as written. - A provider that accepts unknowns is configured at apply instead, and what it serves may take several rounds.
- Something declared nowhere (a typo) → a plan error naming the address.
To put a literal ${ in a value, escape it as $${.
Aliases
Section titled “Aliases”provider "azurerm" { alias = "west" subscription_id = var.sub_west features {}}
resource "azurerm_resource_group" "west" { provider = azurerm.west name = "west-rg" location = "West US"}Without provider, a resource uses the default instance of its type prefix (aws_vpc → aws). A module declaring configuration_aliases needs each slot bound in the call’s providers map.
Destroying through the right provider
Section titled “Destroying through the right provider”A delete runs through the configuration the object was created behind — the block evaluated against prior state — not the one the plan is moving toward. When a provider is configured from a resource the plan replaces (a kubernetes provider reading kind_cluster.demo.endpoint while the cluster is rebuilt), the engine evaluates the block a second time against prior state and routes each delete through that. Nothing needs declaring for it. Whether the contents follow a replaced host does need declaring: see references/lifecycle.md.
Turf™ is a trademark of Turf LLC. Terraform® is a trademark of HashiCorp. Ansible® is a trademark of Red Hat, LLC, registered in the United States and other countries. Helm®, Kubernetes®, Prometheus® and OpenTelemetry® are registered trademarks, and Jaeger™ is a trademark, of the Linux Foundation. OpenTofu® and Model Context Protocol® are registered trademarks of LF Projects, LLC. All other trademarks are the property of their respective owners. Turf is not affiliated with, endorsed by, or sponsored by HashiCorp, IBM, Red Hat, the Linux Foundation, LF Projects or the OpenTofu project.
© 2026 Turf LLC. Free for individuals, education and small businesses within the Community limits, under the Turf Community Edition License 1.0. Government and larger organizations need a commerciallicense.turf.build · Discord ·GitHub