github.com/loicalbertin/terraform@v0.6.15-0.20170626182346-8e2583055467/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  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
    30  state. Even so, if you have important information, please back it up prior
    31  to running this command, just in case.
    32  
    33  If no arguments are given, the configuration in this working directory
    34  is initialized.
    35  
    36  The command-line flags are all optional. The list of available flags are:
    37  
    38  * `-backend=true` - Initialize the [backend](/docs/backends) for this configuration.
    39  
    40  * `-backend-config=path` This can be either a path to an HCL file with key/value
    41    assignments (same format as terraform.tfvars) or a 'key=value' format. This is
    42    merged with what is in the configuration file. This can be specified multiple
    43    times. The backend type must be in the configuration itself.
    44  
    45  * `-force-copy`          Suppress prompts about copying state data. This is
    46    equivalent to providing a "yes" to all confirmation prompts.
    47  
    48  * `-get=true`            Download any modules for this configuration.
    49  
    50  * `-get-plugins=true`    Download any missing plugins for this configuration.
    51  
    52  * `-input=true`          Ask for input if necessary. If false, will error if
    53    input was required.
    54  
    55  * `-lock=true`           Lock the state file when locking is supported.
    56  
    57  * `-lock-timeout=0s`     Duration to retry a state lock.
    58  
    59  * `-no-color`            If specified, output won't contain any color.
    60  
    61  * `-plugin-dir`          Directory containing plugin binaries. This overrides all
    62    default search paths for plugins, and prevents the automatic installation of
    63    plugins. This flag can be used multiple times.
    64  
    65  * `-reconfigure`         Reconfigure the backend, ignoring any saved configuration.
    66  
    67  * `-upgrade=false`       If installing modules (-get) or plugins (-get-plugins),
    68    ignore previously-downloaded objects and install the latest version allowed
    69    within configured constraints.
    70  
    71  * `-verify-plugins=true` Verify the authenticity and integrity of automatically
    72    downloaded plugins.
    73  
    74  ## Backend Config
    75  
    76  The `-backend-config` can take a path or `key=value` pair to specify additional
    77  backend configuration when [initializing a backend](/docs/backends/init.html).
    78  
    79  This is particularly useful for
    80  [partial configuration of backends](/docs/backends/config.html). Partial
    81  configuration lets you keep sensitive information out of your Terraform
    82  configuration.
    83  
    84  For path values, the backend configuration file is a basic HCL file with key/value pairs.
    85  The keys are configuration keys for your backend. You do not need to wrap it
    86  in a `terraform` block. For example, the following file is a valid backend
    87  configuration file for the Consul backend type:
    88  
    89  ```hcl
    90  address = "demo.consul.io"
    91  path    = "newpath"
    92  ```
    93  
    94  If the value contains an equal sign (`=`), it is parsed as a `key=value` pair.
    95  The format of this flag is identical to the `-var` flag for plan, apply,
    96  etc. but applies to configuration keys for backends. For example:
    97  
    98  ```shell
    99  $ terraform init \
   100    -backend-config 'address=demo.consul.io' \
   101    -backend-config 'path=newpath'
   102  ```
   103  
   104  These two formats can be mixed. In this case, the values will be merged by
   105  key with keys specified later in the command-line overriding conflicting
   106  keys specified earlier.