Git Product home page Git Product logo

tfctl's Introduction

tfctl

Purpose

This CLI tool is used to orchestrate Terraform Cloud runs. Its goal is not to cover the entire administation of Terraform Cloud, but instead to solve a very simple workflow.

That workflow is to trigger common actions against workspaces by referencing tags only.

For example, I would like to create a destroy run on all workspace that match the tag 'demo', or I would like to cancel all runs on workspaces that match the tags 'dev'.

If you are looking for a complete CLI tool that orchestrates with Terraform Cloud, I'd recommend that you check out tecli and tfx.

Requirements

Required environment variables

Env Description
TFC_ORGANIZATION The name of your Terraform Cloud organization
TFC_TEAM_TOKEN Terraform Cloud team token

Example Usage

List all workspaces that match the tag test.

$ tfctl search -t test
Searching organization: devopstower
tfc-aws-network-dev
tfc-aws-virtual-machine-dev
tfc-aws-virtual-machine-prod
tfc-aws-network-prod

Run a plan on all workspaces that match the tag test.

$ tfctl plan -t test
Searching organization: devopstower
Targeting the following workspaces [tfc-aws-network-dev]
Plan only started: ws-BvDUwoSB4cELmfmc - run-pt5NodM5GTckfMor

Run a destroy on all workspaces that match the tag test.

$ tfctl destroy -t test
Searching organization: devopstower
Targeting the following workspaces [tfc-aws-network-dev]
Destroy run started: ws-BvDUwoSB4cELmfmc - run-kF62JTa21eqQUdjt

Cancel (or discard) all runs on all workspaces that match both tags azure and demo.

$ tfctl cancel -t azure,demo
Searching organization: devopstower
Targeting the following workspaces [tfc-azure-webapp]
Run cancelled: run-Z7kVEntjzwz3ddMw
Run discarded: run-KUyRJxwJE5fWxEWX

Help Menu

$ tfctl --help
Usage:
  tfctl [command]

Available Commands:
  apply       Start an apply run, this run will automatically apply.
  cancel      Cancel all run on any workspace that matches the supplied tag.
  completion  Generate the autocompletion script for the specified shell
  destroy     Start a destroy run, auto-apply disable by default.
  help        Help about any command
  plan        Start a plan only run, auto-apply disable by default.
  search      List workspaces that match the supplied tags.

Build

go build -o tfctl .

Todo

  • Add support for user customizatible API endpoints for use with private TFE instance.

tfctl's People

Contributors

jamiewri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

gitrgoliveira

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.