github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/website/source/docs/provisioners/connection.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Provisioner Connections"
     4  sidebar_current: "docs-provisioners-connection"
     5  description: |-
     6    Managing connection defaults for SSH and WinRM using the `connection` block.
     7  ---
     8  
     9  # Provisioner Connections
    10  
    11  Many provisioners require access to the remote resource. For example,
    12  a provisioner may need to use SSH or WinRM to connect to the resource.
    13  
    14  Terraform uses a number of defaults when connecting to a resource, but these
    15  can be overridden using a `connection` block in either a `resource` or `provisioner`.
    16  Any `connection` information provided in a `resource` will apply to all the
    17  provisioners, but it can be scoped to a single provisioner as well. One use case
    18  is to have an initial provisioner connect as the `root` user to setup user accounts, and have
    19  subsequent provisioners connect as a user with more limited permissions.
    20  
    21  ## Example usage
    22  
    23  ```
    24  # Copies the file as the root user using SSH
    25  provisioner "file" {
    26      source = "conf/myapp.conf"
    27      destination = "/etc/myapp.conf"
    28      connection {
    29          type = "ssh"
    30          user = "root"
    31          password = "${var.root_password}"
    32      }
    33  }
    34  
    35  # Copies the file as the Administrator user using WinRM
    36  provisioner "file" {
    37      source = "conf/myapp.conf"
    38      destination = "C:/App/myapp.conf"
    39      connection {
    40          type = "winrm"
    41          user = "Administrator"
    42          password = "${var.admin_password}"
    43      }
    44  }
    45  ```
    46  
    47  ## Argument Reference
    48  
    49  **The following arguments are supported by all connection types:**
    50  
    51  * `type` - The connection type that should be used. Valid types are `ssh` and `winrm`
    52    Defaults to `ssh`.
    53  
    54  * `user` - The user that we should use for the connection. Defaults to `root` when
    55    using type `ssh` and defaults to `Administrator` when using type `winrm`.
    56  
    57  * `password` - The password we should use for the connection. In some cases this is
    58    specified by the provider.
    59  
    60  * `host` - The address of the resource to connect to. This is usually specified by the provider.
    61  
    62  * `port` - The port to connect to. Defaults to `22` when using type `ssh` and defaults
    63    to `5985` when using type `winrm`.
    64  
    65  * `timeout` - The timeout to wait for the connection to become available. This defaults
    66    to 5 minutes. Should be provided as a string like `30s` or `5m`.
    67  
    68  * `script_path` - The path used to copy scripts meant for remote execution.
    69  
    70  **Additional arguments only supported by the `ssh` connection type:**
    71  
    72  * `private_key` - The contents of an SSH key to use for the connection. These can
    73    be loaded from a file on disk using the [`file()` interpolation
    74    function](/docs/configuration/interpolation.html#file_path_). This takes
    75    preference over the password if provided.
    76  
    77  * `agent` - Set to `false` to disable using `ssh-agent` to authenticate. On Windows the
    78    only supported SSH authentication agent is
    79    [Pageant](http://the.earth.li/~sgtatham/putty/0.66/htmldoc/Chapter9.html#pageant).
    80  
    81  **Additional arguments only supported by the `winrm` connection type:**
    82  
    83  * `https` - Set to `true` to connect using HTTPS instead of HTTP.
    84  
    85  * `insecure` - Set to `true` to not validate the HTTPS certificate chain.
    86  
    87  * `cacert` - The CA certificate to validate against.
    88  
    89  <a id="bastion"></a>
    90  ## Connecting through a Bastion Host with SSH
    91  
    92  The `ssh` connection also supports the following fields to facilitate connnections via a
    93  [bastion host](https://en.wikipedia.org/wiki/Bastion_host).
    94  
    95  * `bastion_host` - Setting this enables the bastion Host connection. This host
    96    will be connected to first, and then the `host` connection will be made from there.
    97  
    98  * `bastion_port` - The port to use connect to the bastion host. Defaults to the
    99    value of the `port` field.
   100  
   101  * `bastion_user` - The user for the connection to the bastion host. Defaults to
   102    the value of the `user` field.
   103  
   104  * `bastion_password` - The password we should use for the bastion host.
   105    Defaults to the value of the `password` field.
   106  
   107  * `bastion_private_key` - The contents of an SSH key file to use for the bastion
   108    host. These can be loaded from a file on disk using the [`file()`
   109    interpolation function](/docs/configuration/interpolation.html#file_path_).
   110    Defaults to the value of the `private_key` field.