Terraform: Copy files from Remote to Local?

Created on 1 Oct 2015  路  25Comments  路  Source: hashicorp/terraform

Guys, Hi. Thanks again for this formidable tool. I am doing a PoC as we speak. In this context, is it possible to copy file resources from a remote server instance to a local folder? If not, should it be an enhancement request? Opinions? Votes?

Regards, Andrei

enhancement provisionefile

Most helpful comment

馃憤

All 25 comments

Support for this was recently added in Packer, but Terraform's file provisioner doesn't support it yet. I think a PR would be welcomed to allow similar sorts of use-cases as the Packer feature, and I think I have some use-cases that could benefit from it.

Does anyone have an opinion how this should be implemented? Was wondering if this feature should be implemented in the file provisioner ( and add a variable that specifies the direction of the transfer ) or should this be another provisioner ( file-remote maybe? )

Any progress on this issue?
Our use case involves configuration of freIPA cluster where a "replica" seed file is created on the master and then moved to the replica machine and executed there. So I need a way to copy something from one remote machine to the local machine and then I need to push this to another remote machine.

@igormoochnick you could use regular SCP. See this for an example.

Really looking for such feature. Direction functionality would make it even better.

I'd also like this. My use case is a terraform that could run on Windows or Linux, so just using SCP is complicated on the windows side.

Any update on this? It would simplify and remove a lot of workarounds we all have at the moment to solve the lack of this issue.

I implemented this a while back but did not get around to do a pull request since I had not done a proper testing on it and it was good enough for my use case at the time. Here is the branch https://github.com/HX-Rd/terraform/tree/file-provisioner-remote-to-local
Can't really take much credit for this one though since its basically just the packer implementation.

This is a must-have for me. When setting up tinc, public keys are generated on remote machines as part of the provisioning process, which need to be downloaded locally and then distributed to all remote machines.

I really need this feature.
I need to copy K8s client auth certificates stored on bastion to my host.

I'm finding way to copy chef's user cert when bootstraping chef-server.

I'd like this feature as well.

I also need this feature

+1

+1
My use-case is downloading lambda zip files from Artifactory before including them in the aws_lambda_function resource. It is more appealing than installing them is an S3 bucket during build and referencing that URL by some convention

local-exec and scp alone should be able to get a file. OpenStack example:

provisioner "local-exec" {
  command = "scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${var.openstack_keypair} ubuntu@${openstack_networking_floatingip_v2.wr_manager_fip.address}:~/client.token ."
}

+1. Similar use case as @okgolove - copy Kube serviceaccount token from remote to local.

I would support this existing. I can hack it up with Bash, but this would still be super useful.

Hi all! Posting a :+1: reaction on the original comment for this issue is the best way to indicate support for it, since we use reaction counts as an input to prioritization. Posting "+1" comments does not have that effect, and also creates notification noise for the many people already following this issue.

馃憤

any updates on this ?

I also need this feature.

we're working with atlantis here.
this is a must feature for dynamically updating lambdas from artifactory.

Hi folks,
As @apparentlymart said earlier, +1 comments do not help us prioritize issues, but they do create noise for everyone watching the issue. We've already agreed that this is a solid feature request and will review a PR. Since there hasn't been any new information in the +1 comments,
I am going to lock this issue.

You can still add 馃憤 to the original issue comment to add your support to this enhancement request.

Was this page helpful?
0 / 5 - 0 ratings