Copy
Copy
The copy resource allows files and directories to be copied from one location to another.
resource "copy" "name" {
...
}
Attributes
Source source
required
type: string
Source file, folder, url, git repo, etc
source = "http://example.com/archive.zip"
source = "./files/config.cfg"
source = "github.com/jumppad-labs/jumppad//examples?ref=main"
Destination destination
required
type: string
Destination file or directory to write file or files to.
destination = "${data("copied")}/files"
Permissions permissions
type: string
default: 0777
Unix file permissions to apply to coppied files and direcories.
permissions = "0644"
Computed Attributes
These attributes are computed when the config is parsed and applied, and are therefore only known at parsetime or runtime.
Meta ID meta.id
string
The full ID of the resource e.g. resource.type.name
.
This is computed from the full resource path:
// given the following resource
resource "container" "ubuntu" {
...
}
// the resulting id will be resource.container.ubuntu | |
Meta Type meta.type
string
|
The type of the resource. This taken from the type label of the resource definition.
// given the following resource
resource "container" "ubuntu" {
...
}
// the resulting type will be
container
| |
Meta Name meta.name
string
|
The name of the resource. This taken from the name label of the resource definition.
// given the following resource
resource "container" "ubuntu" {
...
}
// the resulting name will be
ubuntu
| |
CopiedFiles copied_files
type: []string
| List of the full paths of copied files. |
Examples
Copy local files
resource "copy" "local" {
source = "${dir()}/files/foo"
destination = "${data("copy")}/local/foo"
}
Copy local files with relative path
resource "copy" "local_relative" {
source = "./files/foo"
destination = "${data("copy")}/local_relative"
}
Copy from url
resource "copy" "http" {
source = "https://www.foundanimals.org/wp-content/uploads/2023/02/twenty20_b4e89a76-af70-4567-b92a-9c3bbf335cb3.jpg"
destination = "${data("copy")}/http"
}
Copy from git
resource "copy" "git" {
source = "github.com/jumppad-labs/examples"
destination = "${data("copy")}/git"
}
Copy zip from url and automatically extract it
resource "copy" "zip" {
source = "https://releases.hashicorp.com/nomad/1.6.3/nomad_1.6.3_linux_amd64.zip"
destination = "${data("copy")}/zip"
}
Last updated