Terraform ChatOps with StackStorm

In this post we’ll walk through configuring StackStorm to integrate with Terraform and leverage Slack to trigger Terraform actions in a ChatOps manner.

In a previous post I covered vRA7 ChatOps with StackStorm which covered integrating Slack, VMware vRealize Automation 7 and StackStorm to interact with vR7 from within Slack.

http://www.greenreedtech.com/vra7-chatops-with-stackstorm/

All the code for this post can be found in the stackstorm-terraform repo on github.

https://github.com/martezr/stackstorm-terraform

Setup

  • Terraform must be installed and in the system path.
  • Currently the Terraform plan must be local to the StackStorm instance.

Terraform Downloads
https://www.terraform.io/downloads.html

Install the Terraform StackStorm Pack
Run the following command on the StackStorm instance to install the Terraform pack.

st2 pack install https://github.com/martezr/stackstorm-terraform  

Supported Actions

The Terraform pack supports the following actions.

Apply
The terraform apply command is used to apply the changes required to reach the desired state of the configuration, or the pre-determined set of actions generated by a terraform plan execution plan.

! terraform apply "/plan/directory"

Destroy
The terraform destroy command is used to destroy the Terraform-managed infrastructure.

! terraform destroy "/plan/directory"

Show
The terraform show command is used to provide human-readable output from a state or plan file.

! terraform show "/plan/directory"

References

vRA7 ChatOps with StackStorm
http://www.greenreedtech.com/vra7-chatops-with-stackstorm/