The local-exec provisioner invokes a local executable after a resource is created. This invokes a process on the machine running Terraform, not on the resource.
provider "aws" {
region = "ca-central-1"
}
resource "null_resource" "echo" {
provisioner "local-exec" {
command = "echo Hello World: $(date) >> log.txt"
}
}
The file provisioner is used to copy files or directories from the machine executing Terraform to the newly created resource.
The remote-exec provisioner invokes a script on a remote resource after it is created.
resource "aws_instance" "web" {
# ...
provisioner "file" {
source = "script.sh"
destination = "/tmp/script.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/script.sh",
"/tmp/script.sh args",
]
}
}
Link: https://www.terraform.io/docs/language/resources/provisioners/index.html