TerraChicken (Terra🐓)
Terrachicken is a cli tool for interacting with Terraform Cloud Workspaces. Terra🐓 allows users to create, list, and delete TFC Workspaces. Terra🐓 supports configuring VCS backed workspaces for Github and Gitlab (Future Version). Terra🐓 was developed to help solve the 🐓 and 🥚 problem with Terraform Cloud automation. Allowing developers and practitioners an easy way to create and destroy workspaces from the command line. Terra🐓 even generates Terraform Backend configurations. This project was created to help solve problems but more so to learn Python and CLI development
Prerequisites
Python 3.6+- Terraform Cloud Account Here - Free Account Works
- Github Account
Installation
To install Terra🐓 you can pull the package down for PyPi with the pip using the command below
Note Terra🐓 uses libraries that have a hard dependency on Python 3.6+. You will need to have that version or newer
pip install terrachicken
Configuration
TerraChicken only supports Environment Variables currently. Future versions will have built in functionality to support initial configuration.
Environment Variables
Environment Variables
TFC_TOKEN- API Token generated from Terraform Cloud Settings.TFC_URL- Terraform Cloud URL (app.terraform.io) unless using Terraform EnterpriseTFC_ORG- Terraform Cloud Organiztion NameGIT_TOKEN- Github Developer Access Token (Repo CRUD Perms at minimum)
To set an environment token use the following export TFC_URL='app.terraform.io'
Hint: After you set your tokens. You can install the built in auto completion with the terrachicken --install-completion command.
Using Terra🐓
Creating Workspaces
Terra🐓 supports creating Local and VCS or Version Control System (Github/Gitlab) workspaces.
Local Workspaces
Example:
terrachicken create workspace local
You will be prompted to enter a name for your workspace. After a successful completion your new Workspace ID will be printed to the terminal.
VCS Workspace
terrachicken create workspace vcs
Note: The Github OAuth provider must be configured in Terraform Cloud prior to building VCS workspaces.
Creating a VCS backed workspace requires you to either create a repo or link and existing repo to the workspace. The default is to create a Github Repo along side the workspace.
Generating Terraform Block Configurations
Example:
terrachicken create workspace vcs --name TerrachickenTest1 --generate
Example rendered_main.tf:
terraform {
cloud {
organization = "aBakersDozen"
workspaces {
name = "TerrachickenTest1"
}
}
}
Both create workspace local and create workspace vcs support generating a Terraform Block configuration to be implemented inside of your Terraform code. To read more about the Terraform Block Syntax click here. Using the --generate or -g option at the end of the command will output a rendered_main.tf file to your current working directory.
The Terraform Block settings will differ based on your workspace type. If you are creating a local workspace. The configuration sets backend with your workspace name. If you are creating a vcs workspace the configuration sets the cloud block. To use the VCS generated main.tf file, you will need to run the terraform login command if you want to execute cli commands for terraform. Click here to read about cloud block and terraform login.
Create Workspace VCS Options
--name: Name of Workspace--generate: Generate Terraform Block Configuration--out: Exports TFC Configuration viapayload.json--tfversion: Set Terraform Version in Workspace--create_repo: Create Repo or nah--private: Set Github Repo to Private--public: Set Github Repo to Public
TO-DO
terrachicken initcommand allows you to add your tokens. Note If you are using an Env Var labeledTFC_TOKEN,TFC_URLorGIT_TOKEN. Those ENV Vars will take priority
TO-DO: Add TC backstory TO-DO: Add init configurations to set default OAuth Client TO-DO: Add --repo flag to copy --name flag TO-DO: Add Gitlab VCS Options TO-DO: Remove the utils.bcolors class, sub for the rich library TO-DO: Add option to delete workspace and repo at same time. TO-DO: Add more options to the TF Workspace Configuration.
Metadata
Release files for terrachicken 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| terrachicken-0.1.1.tar.gz | 9.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| terrachicken-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.7 kB
Release files / terrachicken-0.1.1.tar.gz
| Download URL | terrachicken-0.1.1.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ba04d32a824d2c703a54fc581ba68aba7c3c63eaf484292f71932fa8c764090
|
|
BLAKE2b-256 checksum How to use checksums |
666b3d11e1ec64e0dab02dd56c0a7f8b0fcee5000361af9988c84f342830b1a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.10 Darwin/21.3.0
|
Release files / terrachicken-0.1.1-py3-none-any.whl
| Download URL | terrachicken-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81b4d6379698bbd5caabb4c59f79cb486d415a92c8c2596698f449a1458a45ad
|
|
BLAKE2b-256 checksum How to use checksums |
0e99b409c8397c1adfdfb3dd4385079ea676733f57612b41e52735e3856f8788
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.10 Darwin/21.3.0
|