DevOps Hub for Terraform Automation
Clone or download
avozicov Merge pull request #373 from TerraHubCorp/stage
Add configure command and new google cloud templates
Latest commit 04af4db Oct 11, 2018

README.md

TerraHub

DevOps Hub for Terraform Automation

TerraHub is a terraform centric devops tool that simplifies provisioning and management at scale of cloud resources and cloud services across multiple cloud accounts. For example: Serverless on Amazon AWS, or Kubernetes on Google Cloud, or VMs on Microsoft Azure.

TerraHub CLI and TerraHub Console in Action

Features

  1. Make it easier and faster to create reusable terraform configuration
  2. Simplify and distribute the way terraform configuration is executed
  3. Accelerate and automate the testing of terraform commands
  4. Integrate and manage any existing terraform configuration
  5. Centralize cloud resources management through realtime dashboards
  6. Streamline integration and deployment with built-in CI and CD processes
  7. NO NEED to expose your private network to outside world at all

Commands

TerraHub CLI is built using nodejs and published using npm. Quick steps to get started:

$ node -v
v6.10.0
$ npm -v
v3.10.0
$ npm install -g terrahub
~/.nvm/versions/node/v6.10.0/lib
└── terrahub@0.0.1
$ terrahub --help

NOTE: TerraHub CLI doesn't magically collect your data and upload to TerraHub API, which is visualized in TerraHub Console. In order to do that, please sign up for a free account at console.terrahub.io and navigate to Settings > Access to copy TerraHub token. Next, you can setup THUB_TOKEN environmental variable or update token value in $HOME/.terrahub/.terrahub.json global config file.

When running terrahub --help, you will get a list of commands, summarized below:

Command Description Status
# terrahub management
project create new or define existing folder as project that manages terraform configuration ✔️
component create new or include existing terraform configuration into current terrahub project ✔️
graph show dependencies graph for terraform configuration mapped as terrahub components ✔️
# terraform execution
apply run terraform apply across multiple terrahub components ✔️
destroy run terraform destroy across multiple terrahub components ✔️
init run terraform init across multiple terrahub components ✔️
output run terraform output across multiple terrahub components ✔️
plan run terraform plan across multiple terrahub components ✔️
refresh run terraform refresh across multiple terrahub components ✔️
show run terraform show across multiple terrahub components
workspace run terraform workspace across multiple terrahub components ✔️
# cloud automation
build build code used by terraform configuration (e.g. AWS Lambda, Google Functions) ✔️
run execute automated workflow terraform init > workspace > plan > apply ✔️
list list cloud resources by projects > accounts > regions > services > resources ✔️

Structure

You can use whatever structure you want, but we recommend you follow this one:

your-project
├─ .terrahub
│  ├─ s3
│  │  ├── .terrahub.yml
│  │  ├── README.md
│  │  ├── default.tfvars
│  │  ├── main.tf
│  │  ├── output.tf
│  │  ├── provider.tf
│  │  └── variables.tf
│  ├─ cloudfront
│  │  ├── .terrahub.yml
│  │  ├── README.md
│  │  ├── default.tfvars
│  │  ├── main.tf
│  │  ├── output.tf
│  │  ├── provider.tf
│  │  └── variables.tf
├─ .terrahub.yml
├─ src
└─ ...

One exception: No terraform scripts in root of your project!

Hooks

In order to provide you the best experience we have implemented hooks functionality for following actions:

  • terraform init
  • terraform workspace
  • terraform plan
  • terraform apply
  • terraform output
  • terraform destroy

All the hooks should return a Promise and look like:

  • before hook:
/**
 * @param {Object} moduleConfig
 * @returns {Promise}
 */
function hook(moduleConfig) {
  return Promise.resolve();
}

module.exports = hook;
  • after hook:
/**
 * @param {Object} moduleConfig
 * @param {Buffer} cmdResult
 * @returns {Promise}
 */
function hook(moduleConfig, cmdResult) {
  return Promise.resolve();
}

module.exports = hook;

Configuration example for plan (.terrahub.json):

"hooks": {
    "plan": {
        "before": "./hooks/plan/before.js",
        "after": "./hooks/plan/after.js"
    }
}

@todo

  • Get rid of download npm module