github.com/chalford/terraform@v0.3.7-0.20150113080010-a78c69a8c81f/website/source/docs/provisioners/file.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Provisioner: file"
     4  sidebar_current: "docs-provisioners-file"
     5  description: |-
     6    The `file` provisioner is used to copy files or directories from the machine executing Terraform to the newly created resource. The `file` provisioner only supports `ssh` type connections.
     7  ---
     8  
     9  # File Provisioner
    10  
    11  The `file` provisioner is used to copy files or directories from the machine
    12  executing Terraform to the newly created resource. The `file` provisioner only
    13  supports `ssh` type [connections](/docs/provisioners/connection.html).
    14  
    15  ## Example usage
    16  
    17  ```
    18  resource "aws_instance" "web" {
    19      ...
    20  
    21      # Copies the myapp.conf file to /etc/myapp.conf
    22      provisioner "file" {
    23          source = "conf/myapp.conf"
    24          destination = "/etc/myapp.conf"
    25      }
    26  
    27      # Copies the configs.d folder to /etc/configs.d
    28      provisioner "file" {
    29          source = "conf/configs.d"
    30          destination = "/etc"
    31      }
    32  }
    33  ```
    34  
    35  ## Argument Reference
    36  
    37  The following arguments are supported:
    38  
    39  * `source` - (Required) This is the source file or folder. It can be specified as relative
    40    to the current working directory or as an absolute path.
    41  
    42  * `destination` - (Required) This is the destination path. It must be specified as an
    43    absolute path.
    44  
    45  ## Directory Uploads
    46  
    47  The file provisioner is also able to upload a complete directory to the remote machine.
    48  When uploading a directory, there are a few important things you should know.
    49  
    50  First, the destination directory must already exist. If you need to create it,
    51  use a remote-exec provisioner just prior to the file provisioner in order to create the directory.
    52  
    53  Next, the existence of a trailing slash on the source path will determine whether the
    54  directory name will be embedded within the destination, or whether the destination will
    55  be created. An example explains this best:
    56  
    57  If the source is `/foo` (no trailing slash), and the destination is `/tmp`, then the contents
    58  of `/foo` on the local machine will be uploaded to `/tmp/foo` on the remote machine. The
    59  `foo` directory on the remote machine will be created by Terraform.
    60  
    61  If the source, however, is `/foo/` (a trailing slash is present), and the destination is
    62  `/tmp`, then the contents of `/foo` will be uploaded directly into `/tmp` directly.
    63  
    64  This behavior was adopted from the standard behavior of rsync. Note that under the covers,
    65  rsync may or may not be used.
    66