github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/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 Terraform configuration.
    12  This is the first command that should be run for any new or existing
    13  Terraform configuration. It is safe to run this command multiple times.
    14  
    15  ## Usage
    16  
    17  Usage: `terraform init [options] [SOURCE] [PATH]`
    18  
    19  Initialize a new or existing Terraform environment by creating
    20  initial files, loading any remote state, downloading modules, etc.
    21  
    22  This is the first command that should be run for any new or existing
    23  Terraform configuration per machine. This sets up all the local data
    24  necessary to run Terraform that is typically not comitted to version
    25  control.
    26  
    27  This command is always safe to run multiple times. Though subsequent runs
    28  may give errors, this command will never blow away your environment or state.
    29  Even so, if you have important information, please back it up prior to
    30  running this command just in case.
    31  
    32  If no arguments are given, the configuration in this working directory
    33  is initialized.
    34  
    35  If one or two arguments are given, the first is a SOURCE of a module to
    36  download to the second argument PATH. After downloading the module to PATH,
    37  the configuration will be initialized as if this command were called pointing
    38  only to that PATH. PATH must be empty of any Terraform files. Any
    39  conflicting non-Terraform files will be overwritten. The module download
    40  is a copy. If you're downloading a module from Git, it will not preserve
    41  Git history.
    42  
    43  The command-line flags are all optional. The list of available flags are:
    44  
    45  * `-backend=true` - Initialize the [backend](/docs/backends) for this environment.
    46  
    47  * `-backend-config=path` - Path to an HCL file with additional configuration
    48    for the backend. This is merged with the backend in the Terraform configuration.
    49  
    50  * `-get=true` - Download any modules for this configuration.
    51  
    52  * `-input=true` - Ask for input interactively if necessary. If this is false
    53    and input is required, `init` will error.
    54  
    55  ## Backend Config File
    56  
    57  The `-backend-config` path can be used to specify additional
    58  backend configuration when [initialize a backend](/docs/backends/init.html).
    59  
    60  This is particularly useful for
    61  [partial configuration of backends](/docs/backends/config.html). Partial
    62  configuration lets you keep sensitive information out of your Terraform
    63  configuration.
    64  
    65  The backend configuration file is a basic HCL file with key/value pairs.
    66  The keys are configuration keys for your backend. You do not need to wrap it
    67  in a `terraform` block. For example, the following file is a valid backend
    68  configuration file for the Consul backend type:
    69  
    70  ```hcl
    71  address = "demo.consul.io"
    72  path    = "newpath"
    73  ```