github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/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 committed 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=value` - Value can be a path to an HCL file or a string
    48    in the format of 'key=value'. This specifies additional configuration to merge
    49    for the backend. This can be specified multiple times. Flags specified
    50    later in the line override those specified earlier if they conflict.
    51  
    52  * `-force-copy` -  Suppress prompts about copying state data. This is equivalent
    53    to providing a "yes" to all confirmation prompts.
    54  
    55  * `-get=true` - Download any modules for this configuration.
    56  
    57  * `-input=true` - Ask for input interactively if necessary. If this is false
    58    and input is required, `init` will error.
    59  
    60  * `-lock=true` - Lock the state file when locking is supported.
    61  
    62  * `-lock-timeout=0s` - Duration to retry a state lock.
    63  
    64  * `-no-color` - If specified, output won't contain any color.
    65  
    66  * `-reconfigure` - Reconfigure the backend, ignoring any saved configuration.
    67  
    68  ## Backend Config
    69  
    70  The `-backend-config` can take a path or `key=value` pair to specify additional
    71  backend configuration when [initializing a backend](/docs/backends/init.html).
    72  
    73  This is particularly useful for
    74  [partial configuration of backends](/docs/backends/config.html). Partial
    75  configuration lets you keep sensitive information out of your Terraform
    76  configuration.
    77  
    78  For path values, the backend configuration file is a basic HCL file with key/value pairs.
    79  The keys are configuration keys for your backend. You do not need to wrap it
    80  in a `terraform` block. For example, the following file is a valid backend
    81  configuration file for the Consul backend type:
    82  
    83  ```hcl
    84  address = "demo.consul.io"
    85  path    = "newpath"
    86  ```
    87  
    88  If the value contains an equal sign (`=`), it is parsed as a `key=value` pair.
    89  The format of this flag is identical to the `-var` flag for plan, apply,
    90  etc. but applies to configuration keys for backends. For example:
    91  
    92  ```shell
    93  $ terraform init \
    94    -backend-config 'address=demo.consul.io' \
    95    -backend-config 'path=newpath'
    96  ```
    97  
    98  These two formats can be mixed. In this case, the values will be merged by
    99  key with keys specified later in the command-line overriding conflicting
   100  keys specified earlier.