multiple commands in local-exec provisioner

18,369 views
Skip to first unread message

sar.h...@gmail.com

unread,
Nov 14, 2016, 11:05:07 PM11/14/16
to Terraform
I'm trying to execute multiple command while using the local-exec provisioner, however it only seems to execute the last command. For example I have the following:

provisioner "local-exec" {
    command = "echo Host ${aws_instance.bastion.public_ip} >> ${var.local_ssh_config}"
    command = ""echo IdentityFile ${var.local_identity_file} >> ${var.local_ssh_config}"
}

At the end of the terraform run, it only see the second entry (IdentifyFile ... ) added to the file. What am I doing wrong or missing and how can I fix it?

Mitchell Hashimoto

unread,
Nov 14, 2016, 11:12:24 PM11/14/16
to <terraform-tool@googlegroups.com>
Hello,

That's an issue with our validation but you should specify multiple provisioner blocks to make this work.

Best,
Mitchell

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/322d4bc4-35d6-441a-9cee-280fefd65b2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Taras Fog

unread,
Sep 7, 2018, 4:13:09 PM9/7/18
to Terraform
Or just like that:

provisioner "local-exec" {
    command = <<EOT
      echo Host ${aws_instance.bastion.public_ip} >> ${var.local_ssh_config};
      echo IdentityFile ${var.local_identity_file} >> ${var.local_ssh_config}
   EOT

Taras Fog

unread,
Sep 7, 2018, 4:14:12 PM9/7/18
to Terraform
Which actually works just fine.
Reply all
Reply to author
Forward
0 new messages