npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kennship/gulp-terraform

v0.1.1-develop

Published

Run Terraform from Gulp

Downloads

4

Readme

@kennship/gulp-terraform

Run Terraform from Gulp.

Usage

const terraform = require('@kennship/gulp-terraform');

gulp.task('terraform.apply', () => terraform.apply({
  args: {
    state: '/path/to/terraform.tfstate',
    varFile: '.env/production.tfvars',
  }
})
)

Each method returns a Promise.

If you have a more complex use case, and you are using Node 8 (or a Babel transform), you may use async/await to work with Terraform:

// Please note that you will need special setup for async/await
async function attemptToDeploy() {
  try {
    await terraform.apply('path/to/config');
  } catch (error) {
    console.error('Problem running Terraform!');
    console.error(error);
  }
}

Methods

terraform.apply(positionalArgs, options);
terraform.destroy(positionalArgs, options);
terraform.get(positionalArgs, options);
terraform.import(positionalArgs, options);
terraform.init(positionalArgs, options);
terraform.output(positionalArgs, options);
terraform.plan(positionalArgs, options);
terraform.push(positionalArgs, options);
terraform.refresh(positionalArgs, options);
terraform.show(positionalArgs, options);
terraform.taint(positionalArgs, options);
terraform.untaint(positionalArgs, options);
terraform.validate(positionalArgs, options);
terraform.version(positionalArgs, options);

Each of these methods takes an optional array of positional arguments, and an options object. Each method returns a Promise that resolves when the Terraform run has completed, or rejects if there is an issue.

positionalArgs is either a string or an array of strings used to supply positional arguments at the end of the call. For example, terraform.apply('path/to/config') would be run as terraform apply path/to/config.

options is an object allowing further configuration:

  • args is a map of CLI argument names to their values. Array values are split into multiple arguments. Arguments passed in camel-case will be converted to the hyphenated form expected by Terraform; for example, {stateOut: 'some/value'} would get passed as -state-out=some/value. Also, to specify a flag with no value, set its value to true.
  • vars is a map of Terraform variable names to their values. These are set by manipulating the environment variables used for the Terraform call.
  • cwd is the working directory to call Terraform from. This will make a difference if the configuration is specified as a relative path. The default behavior is to use process.cwd().
  • terraformPath may be used to provide a path to a Terraform binary. This is useful if your system does not have Terraform in its PATH variable.
terraform.runCommand(commandName, positionalArgs, options);

This method is used to implement the named commands. terraform.runCommand('apply', opts) is the same as terraform.apply(opts).

Examples

terraform.apply('path/to/config', {
  args: {
    varFile: '.env/production.tfvars',
  },
  vars: {
    site_domain_name: 'gulpjs.com',
  }
});
// > terraform apply -var-file=.env/production.tfvars path/to/config
// This will also set the Terraform variable "site_domain_name" to the
// value "gulpjs.com".


terraform.validate('path/to/config' {args: {color: false}});
// > terraform validate -no-color path/to/config
// Makes sure that the Terraform files in the given directory are valid, but
// don't show color in the output.

License

MIT