Terraform: Terraform 0.7.4 fails to read AWS key

Created on 21 Sep 2016  ยท  9Comments  ยท  Source: hashicorp/terraform

Terraform Version

0.7.4
In version 0.7.0 works fine. The key is valid - I can connect to EC2 instance using this key.

Affected Resource(s)

  • aws_instance

    Terraform Configuration Files

connection {
      user = "ubuntu"
      key_file = "~/.ssh/lx-eu-west-1.pem"
}

Expected Behavior

I create AWS key pair and pass it terraform remote provisioner. I expect provisioner to login to the AWS instance and run commands.

Actual Behavior

I get an error

* Failed to read key "~/.ssh/lx-eu-west-1.pem": no key found

Steps to Reproduce

  1. Create new AWS EC2 key pair
  2. Create config file with remote provisioner
  3. terraform apply
bug provideaws

Most helpful comment

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")}"

All 9 comments

I see the same thing with openstack when using file provisioner "uploading file" so not specific to aws or openstack I dont believe

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

franklinwise picture franklinwise  ยท  3Comments

carl-youngblood picture carl-youngblood  ยท  3Comments

ronnix picture ronnix  ยท  3Comments

thebenwaters picture thebenwaters  ยท  3Comments

rnowosielski picture rnowosielski  ยท  3Comments