Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.
/ terraformjs Public archive

A HashiCorp Terraform JS wrapper

License

Notifications You must be signed in to change notification settings

strigo/terraformjs

Repository files navigation

terraformjs

Note: This isn't maintained any longer, as it's not used within Strigo

Travis Build Status AppVeyor Build Status Code Coverage Code Climate Dependency Status Dependency Status Known Vulnerabilities

terraformjs is a javascript wrapper for terraform, which aims to provide an simple API to execute terraform commands from a nodejs app.

Alternatives

There don't appear to be any.

Installation

$ npm install [-g] terraformjs

Usage

var terraform = require('terraformjs')

console.log(terraform.version())
// 0.8.5

# The constructor receives the following three arguments:
# workDir = process.cwd(), silent = false, noColor = false
let tf = new terraform.Terraform(workDir, silent, noColor);
let outcome = tf.apply()
console.log(outcome.stdout)

// To pass options:
let outcome = tf.apply(
    {
        'state': 'my-state-file.tfstate',
        'var': {'foo': 'bar', 'bah': 'boo'},
        'vars_file': ['x.tfvars', 'y.tfvars']
    }
)

// A commands positional arguments will be passed alongside an object of options:
let outcome = tf.apply({}, process.cwd())

Command positional arguments and options

  • Optional positional arguments can be passed as null to the function if not required.
  • Option names are normalized (e.g. vars_file is really --vars-file).
  • Strings are simple options (e.g. -state=my-state-file.tfstate)
  • Objects are converted to (multiple) key=values (e.g. -var 'foo=bar' -var 'bah=boo')
  • Arrays are converted to multi-usage options (e.g. --vars-file=x --vars-file=y)

Supported subcommands

As of now, the supported subcommands are:

  • apply
  • destroy
  • console
  • fmt
  • get
  • graph
  • import
  • init
  • output
  • plan
  • push
  • refresh
  • show
  • taint
  • untaint
  • validate

Contributions..

See CONTRIBUTIONS

Pull requests are always welcome..

Releases

No releases published

Packages

No packages published