RubyTerraform
A simple wrapper around the Terraform binary to allow execution from within a Ruby program, RSpec test or Rakefile.
Installation
Add this line to your application's Gemfile:
gem 'ruby-terraform'And then execute:
$ bundle
Or install it yourself as:
$ gem install ruby-terraform
Usage
To require RubyTerraform:
require 'ruby-terraform'Supported versions and commands
RubyTerraform supports all commands and options up to Terraform 1.5.7, except terraform console, terraform test and terraform version.
Getting started
There are a couple of ways to call Terraform using RubyTerraform.
Firstly, the RubyTerraform module includes class methods for each of the supported Terraform commands. Each class method takes a parameter hash containing options to pass to Terraform.
For example, to save the plan of changes for a Terraform configuration located under infra/network to a file called network.tfplan whilst providing some vars: