github.com/sl1pm4t/terraform@v0.6.4-0.20170725213156-870617d22df3/website/docs/commands/init.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Command: init" 4 sidebar_current: "docs-commands-init" 5 description: |- 6 The `terraform init` command is used to initialize a Terraform configuration. This is the first command that should be run for any new or existing Terraform configuration. It is safe to run this command multiple times. 7 --- 8 9 # Command: init 10 11 The `terraform init` command is used to initialize a working directory 12 containing Terraform configuration files. This is the first command that should 13 be run after writing a new Terraform configuration or cloning an existing one 14 from version control. It is safe to run this command multiple times. 15 16 ## Usage 17 18 Usage: `terraform init [options] [DIR]` 19 20 This command performs several different initialization steps in order to 21 prepare a working directory for use. More details on these are in the 22 sections below, but in most cases it is not necessary to worry about these 23 individual steps. 24 25 This command is always safe to run multiple times, to bring the working 26 directory up to date with changes in the configuration. Though subsequent runs 27 may give errors, this command will never delete your existing configuration or 28 state. 29 30 If no arguments are given, the configuration in the current working directory 31 is initialized. It is recommended to run Terraform with the current working 32 directory set to the root directory of the configuration, and omit the `DIR` 33 argument. 34 35 ## General Options 36 37 The following options apply to all of (or several of) the initialization steps: 38 39 * `-input=true` Ask for input if necessary. If false, will error if 40 input was required. 41 42 * `-lock=false` Disable locking of state files during state-related operations. 43 44 * `-lock-timeout=<duration>` Override the time Terraform will wait to acquire 45 a state lock. The default is `0s` (zero seconds), which causes immediate 46 failure if the lock is already held by another process. 47 48 * `-no-color` Disable color codes in the command output. 49 50 * `-upgrade` Opt to upgrade modules and plugins as part of their respective 51 installation steps. See the seconds below for more details. 52 53 ## Backend Initialization 54 55 During init, the root configuration directory is consulted for 56 [backend configuration](/docs/backends/config.html) and the chosen backend 57 is initialized using the given configuration settings. 58 59 Re-running init with an already-initalized backend will update the working 60 directory to use the new backend settings. Depending on what changed, this 61 may result in interactive prompts to confirm migration of workspace states. 62 The `-force-copy` option suppresses these prompts and answers "yes" to the 63 migration questions. The `-reconfigure` option disregards any existing 64 configuration, preventing migration of any existing state. 65 66 To skip backend configuration, use `-backend=false`. Note that some other init 67 steps require an initialized backend, so it's recommended to use this flag only 68 when the working directory was already previously initialized for a particular 69 backend. 70 71 The `-backend-config=...` option can be used for 72 [partial backend configuration](/docs/backends/config.html#partial-configuration), 73 in situations where the backend settings are dynamic or sensitive and so cannot 74 be statically specified in the configuration file. 75 76 ## Child Module Installation 77 78 During init, the configuration is searched for `module` blocks, and the source 79 code for referenced [modules](/docs/modules/) is retrieved from the locations 80 given in their `source` arguments. 81 82 Re-running init with modules already installed will install the sources for 83 any modules that were added to configuration since the last init, but will not 84 change any already-installed modules. Use `-upgrade` to override this behavior, 85 updating all modules to the latest available source code. 86 87 To skip child module installation, use `-get=false`. Note that some other init 88 steps can complete only when the module tree is complete, so it's recommended 89 to use this flag only when the working directory was already previously 90 initialized with its child modules. 91 92 ## Plugin Installation 93 94 During init, the configuration is searched for both direct and indirect 95 references to [providers](/docs/configuration/providers.html), and the plugins 96 for the providers are retrieved from the plugin repository. The downloaded 97 plugins are installed to a subdirectory of the working directory, and are thus 98 local to that working directory. 99 100 Re-running init with plugins already installed will install plugins only for 101 any providers that were added to the configuration since the last init. Use 102 `-upgrade` to additionally update already-installed plugins to the latest 103 versions that comply with the version constraints given in configuration. 104 105 To skip plugin installation, use `-get-plugins=false`. 106 107 The automatic plugin installation behavior can be overridden by extracting 108 the desired providers into a local directory and using the additonal option 109 `-plugin-dir=PATH`. When this option is specified, _only_ the given directory 110 is consulted, which prevents Terraform from making requests to the plugin 111 repository or looking for plugins in other local directories. 112 113 When plugins are automatically downloaded and installed, by default the 114 contents are verified against an official HashiCorp release signature to 115 ensure that they were not corrupted or tampered with during download. It is 116 recommended to allow Terraform to make these checks, but if desired they may 117 be disabled using the option `-verify-plugins=false`. 118 119 ## Running `terraform init` in automation 120 121 For teams that use Terraform as a key part of a change management and 122 deployment pipeline, it can be desirable to orchestrate Terraform runs in some 123 sort of automation in order to ensure consistency between runs, and provide 124 other interesting features such as integration with version control hooks. 125 126 There are some special concerns when running `init` in such an environment, 127 including optionally making plugins available locally to avoid repeated 128 re-installation. For more information, see 129 [`Running Terraform in Automation`](/guides/running-terraform-in-automation.html).