TerraHub CLI is Open Source and Free Forever
September 4th, 2018 / 3 min read
TerraHub is a terraform centric devops tool that simplifies provisioning and management at scale of cloud resources and cloud services across multiple cloud accounts. The core and fundamental component of newly introduced TerraHub.io ecosystem is TerraHub CLI. Developed in Node.js and published on npmjs.com, I thought this tool deserves a special treatment and in depth explanations.
In this article, I'll try to explain what TerraHub CLI is and what it isn't, how does it work with terraform and what kind of effort it requires to start using it in existing environment(s). And, the most important, TerraHub CLI is Open Source and Free Forever!
What Is TerraHub CLI?
TerraHub CLI is the central piece that puts terraform automation in motion. The main goal is to simplify and make it easier to create and execute terraform. Commands are group in three categories:
- TerraHub Management — manages all devops aspects related to terraform configurations like projects, components, templates and
- Terraform Execution — manages all devops aspects related to distributed execution of terraform configurations like init, plan, apply or destroy
- Cloud Automation — manages all devops aspects related to automation and testing, as well as visualization of resources and automated processes
TerraHub CLI works overall as a management layer on top of terraform. If existing terraform code is functional in manual mode, TerraHub CLI will make it operational and functional in automated mode. Current users of TerraHub CLI use it as part of their existing GitHub and Jenkins pipelines.
What TerraHub CLI Is NOT?
TerraHub CLI is ...
- NOT a replacement of terraform commands and terraform configurations
- NOT a development tool that helps create terraform modules and artifacts
- NOT a testing framework that overwrites existing terraform testing capabilities
- NOT altering existing terraform code for the benefit of automation
- NOT sending any data to TerraHub API or any other APIs by default
If, sometimes in the future, terraform will provide native capabilities for distributed execution and/or automation with built-in continuous delivery, simply remove .terrahub.yml config files from your codebase and never worry about TerraHub CLI ever again.
How Does TerraHub CLI Work with Terraform?
Basically, TerraHub CLI generates .terrahub.yml configuration files across existing terraform codebase that allows specific terrahub commands to properly form corresponding terraform commands and execute them. For example, terrahub init will find all .terrahub.yml files, create the list of components and for each component will execute terraform init with corresponding options and variables defined in each config file.
One of the challenges that kept us busy for a while is tfstate management, specifically local vs remote. Another challenge worth mentioning is credentials injection for each component execution. Last, but not the least, log streaming and consolidation can be improved, but is fully functional and pretty useful when something goes wrong.
What Kind of Effort TerraHub CLI Requires?
I would argue that TerraHub CLI doesn't require ANY effort to get started. Below, in three steps, you can see all basic capabilities:
Step 1: Define New Project
For the purpose of this article, I took my Security_Terraform repository (which is private for obvious reasons) and kept only 3 terraform folders:
Step 2: Map All Components
After mapping Security_Terraform folder as TerraHub project, next step is to map all terraform configurations as TerraHub components:
Step 3: Run Automation
Finally, when all .terrahub.yml files are in place, I can run my automation as simple as this:
And that's pretty much it.