init
The first command of every workflow, as tofu init: registers a configuration directory under config_alias, installs its modules and its providers, and reports what it declares — backend (defaulted:true marks the synthesized local default), workspace name (from the data directory’s environment file), variables, outputs, import blocks (the objects up adopts into state), and README.md (capped at 32 KiB). data_dir is where init installs modules, as tofu’s: TF_DATA_DIR from the server’s environment, relative to the configuration, or its .terraform; the engine installs under a data directory of its own, never in the configuration. A configuration directory nothing may write plans when this server’s TF_DATA_DIR names one that can be, given its lock file committed complete and its state elsewhere (a remote backend, or a statefile outside it). providers[] lists every provider any module requires, as the lock file records it — provider (its address), version, constraints (none: nothing pins it), hashes — plus its package_dir; built-in providers are never listed. Hand them to a provider-scanning tool before the first up if you have one; init does not scan. The selections are recorded in the dependency lock file (.terraform.lock.hcl, lock_file), which every plan honours; upgrade moves a locked version. An absent directory is created with a .gitignore (how a new configuration starts); omit path for a scratch directory. Re-run it after adding a module or a provider (an overlay’s action’s provider included). It reports declarations, never resolved values: no TF_VAR_ environment, .tfvars or variable value reaches the report. variables[].required means the declaration has no default, not that no value exists. A module source or version may read a variable: give it with var (this init only), or the user is asked for it when nothing supplies it (never a sensitive one). init does not open the backend or read the state; open takes the values the backend block and the state encryption read, and keeps them for the workspace.
Tiers: read · plan · apply · full
Annotations
Section titled “Annotations”| Annotation | Value |
|---|---|
title |
Initialize configuration |
readOnlyHint |
false |
destructiveHint |
false |
idempotentHint |
false |
openWorldHint |
true |
Arguments
Section titled “Arguments”| Name | Type | Required | Description |
|---|---|---|---|
path |
string | no | Path to the configuration directory. An absent directory is created (with a .gitignore covering .terraform/ and statefiles) — this is how a new configuration starts. Omit to run init again on the directory config_alias already names; with nothing registered under it, omitting allocates a scratch directory (throwaway work). A new configuration needs an explicit, absolute path; never rely on the server’s working directory. |
config_alias |
string | no | Alias to register this configuration under (omit for the unnamed ‘default’). Later tools name the configuration by it; give each configuration a distinct alias when you work with more than one. |
install_providers |
boolean | no | Install the providers the configuration requires into the shared plugin cache, and report each one’s version, package directory and checksums (default true), recording the selections in the dependency lock file. Pass false for a quick look at a configuration whose providers you do not need yet. |
upgrade |
boolean | no | As tofu init -upgrade: select the newest version each provider’s constraints admit, past what the dependency lock file (.terraform.lock.hcl) selects, and record the new selections. |
var |
object | no | Root input variable values for this init only — ‘tofu init -var’: what a module’s source or version reads (or a const variable). Not kept: every plan installs the modules again with the values it plans with, so give such a value to open as well. A string is the raw text a -var carries; any other JSON value is passed as its HCL literal. |
var_file |
array of string | no | Variables files for this init only — ‘tofu init -var-file’, in order, below var. A relative path is relative to the configuration directory. |
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