github.com/adamar/terraform@v0.2.2-0.20141016210445-2e703afdad0e/website/source/docs/provisioners/file.html.markdown (about)

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