I seem to be confused about how external works. I tried:
data "external" "local_key" {
program = [
"ssh-keygen", "-y", "-f ~/.ssh/id_rsa"
]
}
This gives me:
failed to execute "ssh-keygen": ~/.ssh/id_rsa: No such file or directory
Which presumably happens because ~ expansion doesn't. ssh-keygen -y -f ~/.ssh/id_rsa works normally. So instead I tried invoking bash like:
data "external" "local_key" {
program = [
"bash"
]
query {
"-c" = "ssh-keygen -y -f ~/.ssh/id_rsa"
}
}
I'm still getting the same issue. I realize I can just pass the output as a var to terraform from the outside, but I'm still curious what the solution is.
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.puboutside of terraform and using this .pub file in terraform would be far easier IMHO. – Tensibai Feb 22 '18 at 08:46