github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/cli/init/index.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Initializing Working Directories - Terraform CLI" 4 description: "Working directories contain configurations, settings, cached plugins and modules, and state data. Learn how to initialize and manage working directories." 5 --- 6 7 # Initializing Working Directories 8 9 Terraform expects to be invoked from a working directory that contains 10 configuration files written in 11 [the Terraform language](/docs/language/index.html). Terraform uses 12 configuration content from this directory, and also uses the directory to store 13 settings, cached plugins and modules, and sometimes state data. 14 15 A working directory must be initialized before Terraform can perform any 16 operations in it (like provisioning infrastructure or modifying state). 17 18 ## Working Directory Contents 19 20 A Terraform working directory typically contains: 21 22 - A Terraform configuration describing resources Terraform should manage. This 23 configuration is expected to change over time. 24 - A hidden `.terraform` directory, which Terraform uses to manage cached 25 provider plugins and modules, record which 26 [workspace](/docs/cli/workspaces/index.html) is currently active, and 27 record the last known backend configuration in case it needs to migrate state 28 on the next run. This directory is automatically managed by Terraform, and is 29 created during initialization. 30 - State data, if the configuration uses the default `local` backend. This is 31 managed by Terraform in a `terraform.tfstate` file (if the directory only uses 32 the default workspace) or a `terraform.tfstate.d` directory (if the directory 33 uses multiple workspaces). 34 35 ## Initialization 36 37 Run the `terraform init` command to initialize a working directory that contains 38 a Terraform configuration. After initialization, you will be able to perform 39 other commands, like `terraform plan` and `terraform apply`. 40 41 If you try to run a command that relies on initialization without first 42 initializing, the command will fail with an error and explain that you need to 43 run init. 44 45 Initialization performs several tasks to prepare a directory, including 46 accessing state in the configured backend, downloading and installing provider 47 plugins, and downloading modules. Under some conditions (usually when changing 48 from one backend to another), it might ask the user for guidance or 49 confirmation. 50 51 For details, see [the `terraform init` command](/docs/cli/commands/init.html). 52 53 ## Reinitialization 54 55 Certain types of changes to a Terraform configuration can require 56 reinitialization before normal operations can continue. This includes changes to 57 provider requirements, module sources or version constraints, and backend 58 configurations. 59 60 You can reinitialize a directory by running `terraform init` again. In fact, you 61 can reinitialize at any time; the init command is idempotent, and will have no 62 effect if no changes are required. 63 64 If reinitialization is required, any commands that rely on initialization will 65 fail with an error and tell you so. 66 67 ## Reinitializing Only Modules 68 69 The `terraform get` command will download modules referenced in the 70 configuration, but will not perform the other required initialization tasks. 71 This command is only useful for niche workflows, and most Terraform users can 72 ignore it in favor of `terraform init`.