0.7.4
In version 0.7.0 works fine. The key is valid - I can connect to EC2 instance using this key.
connection {
user = "ubuntu"
key_file = "~/.ssh/lx-eu-west-1.pem"
}
I create AWS key pair and pass it terraform remote provisioner. I expect provisioner to login to the AWS instance and run commands.
I get an error
* Failed to read key "~/.ssh/lx-eu-west-1.pem": no key found
terraform applyI see the same thing with openstack when using file provisioner "uploading file" so not specific to aws or openstack I dont believe
key_file has been deprecated. https://www.terraform.io/docs/provisioners/connection.html#key_file
You should use https://www.terraform.io/docs/provisioners/connection.html#private_key with file() interpolation going forward.
Here is the relevant commit: https://github.com/hashicorp/terraform/commit/7ffa66d1a536428dcdf16e68c32ff7ca2b83674a
Given your example, this would be something like: private_key = "${file("~/.ssh/lx-eu-west-1.pem")}"
Thank you for help!
Maybe this should be added to https://www.terraform.io/upgrade-guides/0-7.html
The key_file is not just deprecated, it doesn't work anymore at all (because pathorcontents.Read isn't applied anymore). The docs say it "may be removed in a future version", which leaves the impression that it might still work.
At some point (< 0.7.4?) this stopped working:
private_key = "${"~/.ssh/lx-eu-west-1.pem"}"
With v0.7.4, as @mootpt says, we must tell it to read the file:
private_key = "${file("~/.ssh/lx-eu-west-1.pem")}"
@mmell I found moving to 0.7.7 and using private_key = "${file("~/.ssh/lx-eu-west-1.pem")}"
fixed the issue
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
At some point (< 0.7.4?) this stopped working:
With
v0.7.4, as @mootpt says, we must tell it to read the file: