Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform apply fails when supplying aws_instance connection key_file #179

Closed
tonyjchong opened this issue Aug 11, 2014 · 3 comments
Closed
Labels

Comments

@tonyjchong
Copy link

Here is an excerpt from my tf file.

resource "aws_instance" "linux" {
    ami = "${lookup(var.amis, var.region)}"
    instance_type = "t1.micro"
    count = 1
    key_name = "dev"
    connection {
        user = "core"
        key_file = "~/.ssh/dev.pem"
    }
}

Error applying plan:

1 error(s) occurred:

  • Failed to read key file '~/.ssh/dev.pem': open ~/.ssh/dev.pem: no such file or directory.

Is there something I am doing incorrectly? I have been able to launch machines and now I'm testing out the different provisioners. Thanks!

@alex
Copy link
Contributor

alex commented Aug 11, 2014

The problem here is that terraform isn't expanding the tilde to your home directory.

key, err := ioutil.ReadFile(conf.KeyFile)
specifically needs some code added.

In the short term you can work around it by expanding it to an absolute path yourself.

@tonyjchong
Copy link
Author

Thanks. Just for others to see, the tilde would be perfect so everyone on my team can develop and test out terraform since we all have the pem.

@mitchellh mitchellh added the bug label Aug 11, 2014
@mitchellh
Copy link
Contributor

Thanks, this is a bug.

@ghost ghost locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants