Run Terraform as a Go package

1,682 views
Skip to first unread message

Gustavo Carvalho

unread,
May 22, 2018, 8:21:38 PM5/22/18
to Terraform
Hi,

I'd like to know if it's possible to run Terraform as a Go package, and if it is, if there's any link on the doc or elsewhere pointing how to do it.
Basically, what I need is, through Go code, call the commands init, apply, and destroy.
I know I could just execute the commands directly via a system call, but I'll leave that as last option, only if I don't suceed in calling it as package.

Thank you in advance.

Brandon O'Connor

unread,
May 23, 2018, 2:28:44 AM5/23/18
to Terraform
Shell out in your go code ala: https://nathanleclaire.com/blog/2014/12/29/shelled-out-commands-in-golang/

For an example that runs terraform, peek at the terragrunt source code: https://github.com/gruntwork-io/terragrunt/blob/master/shell/run_shell_cmd.go#L30

- Brandon

Gustavo Carvalho

unread,
May 29, 2018, 11:17:48 AM5/29/18
to terrafo...@googlegroups.com
Thank you, I'll give it a try.

Att,

--
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 a topic in the Google Groups "Terraform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/terraform-tool/7clPX0J7FmU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/8cb1e794-267e-4106-973a-d4e3b1a25846%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Gustavo de Carvalho Sales
http://gtsalles.com.br/

'A Livre expressão é o que constrói uma nação independentemente da moeda e sua cotação'

Reply all
Reply to author
Forward
0 new messages