github.com/paybyphone/terraform@v0.9.5-0.20170613192930-9706042ddd51/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] [SOURCE] [PATH]`
    19  
    20  Initialize a new or existing Terraform working directory by creating
    21  initial files, loading any remote state, downloading modules, etc.
    22  
    23  This is the first command that should be run for any new or existing
    24  Terraform configuration per machine. This sets up all the local data
    25  necessary to run Terraform that is typically not committed to version
    26  control.
    27  
    28  This command is always safe to run multiple times. Though subsequent runs
    29  may give errors, this command will never delete your configuration or state.
    30  Even so, if you have important information, please back it up prior to
    31  running this command just in case.
    32  
    33  If no arguments are given, the configuration in the current working directory
    34  is initialized.
    35  
    36  If one or two arguments are given, the first is a SOURCE of a module to
    37  download to the second argument PATH. After downloading the module to PATH,
    38  the configuration will be initialized as if this command were called pointing
    39  only to that PATH. PATH must be empty of any Terraform files. Any
    40  conflicting non-Terraform files will be overwritten. The module download
    41  is a copy. If you're downloading a module from Git, it will not preserve
    42  Git history.
    43  
    44  The command-line flags are all optional. The list of available flags are:
    45  
    46  * `-backend=true` - Initialize the [backend](/docs/backends) for this configuration.
    47  
    48  * `-backend-config=value` - Value can be a path to an HCL file or a string
    49    in the format of 'key=value'. This specifies additional configuration to merge
    50    for the backend. This can be specified multiple times. Flags specified
    51    later in the line override those specified earlier if they conflict.
    52  
    53  * `-force-copy` -  Suppress prompts about copying state data. This is equivalent
    54    to providing a "yes" to all confirmation prompts.
    55  
    56  * `-get=true` - Download any modules for this configuration.
    57  
    58  * `-input=true` - Ask for input interactively if necessary. If this is false
    59    and input is required, `init` will error.
    60  
    61  * `-lock=true` - Lock the state file when locking is supported.
    62  
    63  * `-lock-timeout=0s` - Duration to retry a state lock.
    64  
    65  * `-no-color` - If specified, output won't contain any color.
    66  
    67  * `-reconfigure` - Reconfigure the backend, ignoring any saved configuration.
    68  
    69  ## Backend Config
    70  
    71  The `-backend-config` can take a path or `key=value` pair to specify additional
    72  backend configuration when [initializing a backend](/docs/backends/init.html).
    73  
    74  This is particularly useful for
    75  [partial configuration of backends](/docs/backends/config.html). Partial
    76  configuration lets you keep sensitive information out of your Terraform
    77  configuration.
    78  
    79  For path values, the backend configuration file is a basic HCL file with key/value pairs.
    80  The keys are configuration keys for your backend. You do not need to wrap it
    81  in a `terraform` block. For example, the following file is a valid backend
    82  configuration file for the Consul backend type:
    83  
    84  ```hcl
    85  address = "demo.consul.io"
    86  path    = "newpath"
    87  ```
    88  
    89  If the value contains an equal sign (`=`), it is parsed as a `key=value` pair.
    90  The format of this flag is identical to the `-var` flag for plan, apply,
    91  etc. but applies to configuration keys for backends. For example:
    92  
    93  ```shell
    94  $ terraform init \
    95    -backend-config 'address=demo.consul.io' \
    96    -backend-config 'path=newpath'
    97  ```
    98  
    99  These two formats can be mixed. In this case, the values will be merged by
   100  key with keys specified later in the command-line overriding conflicting
   101  keys specified earlier.