@jahed/terraform

Manage Terraform executables via Yarn / NPM.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
44Jun 8, 2021Jul 23, 2018Minified + gzip package size for @jahed/terraform in KB

Readme

@jahed/terraform

npm author

A wrapper which downloads and runs Terraform locally via Yarn or NPM.

  • Automates and manages your Terraform setup like all your other NPM/Yarn dependencies.
  • Downloads the correct version of Terraform regardless of which Operating System you're using.
  • Checks downloads against Hashicorp's signed checksums to avoid malicious executables.
  • Decouples your project's Terraform version from your system installation.
  • New releases are semi-automated to stay in sync with official Terraform releases.

Useful Links

Installation

Install the right version for your project.

# Latest
npm install @jahed/terraform

# Specific version
npm install @jahed/terraform@0.12.29

Note: If you use required_version in your Terraform configuration, make sure it matches the version in your package.json. In the future, this may be automated for you.

Configuration

To fully automate your Terraform installation including plugins, you can add the following to your package.json.

{
  "scripts": {
    "postinstall": "terraform init && terraform get"
  }
}

Now every time you run npm install it will also setup and update Terraform.

Usage

You can run any terraform command by prefixing it with npx.

npx terraform --help

FAQ & Troubleshooting

How is this package versioned?

For consistency, the version of every release matches the version of Terraform. There are some downsides to this. If I improve the package and add more features, I can't bump the package version using Semantic Version (SemVer) like most packages.

For now, I'm using pre-release versions as a workaround. For example v0.11.7-1.0.0 is for Terraform 0.11.7 and package's 1.0.0 release. So if you want the latest version, use the latest pre-release, which is versioned using SemVer.

This also allows the package to release new package changes for older Terraform versions.

How does this package use Terraform?

The package essentially wraps a Terraform executable. The executable is downloaded when the package is first installed. Every time you run yarn terraform it runs a NodeJS script which launches Terraform in a child process, forwarding arguments, stdin, stdout, etc.

The terraform version isn't available

Submit an issue ticket and I'll publish a new version.

The terraform executable is corrupt

Remove the package and reinstall it. If that doesn't work, submit an issue ticket and I'll look into it.

License

MIT.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.