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