No project description provided
Project description
terraflex
Construct custom backends for your terraform project!
[!NOTE]
This project is still WIP in early stages - there might be some bugs - you are welcome to open issues when any encounted
why?
I started this project to provide a free solution for homelabs IAC.
The major constraint here is to find a free backend that I feel safe to use and to have a 0 bootstrap layer if possible.
I found several solutions around this - but most were using a 3rd party hosted http backend servers.
Those backends were problematic for me because I had issues trusting them to store my sensitive state files - and the fact that I didn't own the storage location - made me afraid that I might lose those state files - and we all know how bad it is to lose your state files :P.
The closest solution I found was terraform-backend-git - which this project was heavily influenced on - so go check it out as well!
Eventually I had the idea of creating an extendable modular terraform http backend - which allows customizing the state using transformations
(like encryption), and getting starting with it will be as simple as running single command.
Installation
Recommended apporach is using pipx:
pipx install terraflex
Upgrade using:
pipx upgrade terraflex
Getting started
Git backends preparation
- Create new repository to store your state at
- Make sure the repository is initialized with primary branch (
main
)
Common
- To start - cd to your IAC repo, for example:
~/git/iac
- Run:
terraflex init
Follow the wizard - Update your backend:
backend "http" { address = "http://localhost:8600/state" lock_address = "http://localhost:8600/lock" lock_method = "PUT" unlock_address = "http://localhost:8600/lock" unlock_method = "DELETE" }
- Run any terraform command using
terraform wrap -- <command>
- for example:terraflex wrap -- terraform init
- You can also create a full shell with the context of the backend:
terraflex wrap -- $SHELL
[!WARNING]
Make sure to not lose your encryption key - back it up! If you lose this key you wont be able to reopen the terraform state at all!
TODO
- git - have a support for different branches
- onepassword store for encryption key
- bundle standalone binary using PyInstaller
- CI/CD flow
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file terraflex-0.2.1.tar.gz
.
File metadata
- Download URL: terraflex-0.2.1.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | acc38c0db5a2e3779ea8d35f5333ab1b5a23cf29d7e0a8ae4aea615bcdc99993 |
|
MD5 | a34416b34c30ee240b5c4bd19471f470 |
|
BLAKE2b-256 | c3ee94c7a6d947b175755ae420f9774116e50b5b036bcaddec7678346412f886 |
File details
Details for the file terraflex-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: terraflex-0.2.1-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c48b4aef5062274a7231d0941257e608b7b6b053e4c84811337297e1118e998d |
|
MD5 | 550d7579bf96f98098cf2d9f28a35de1 |
|
BLAKE2b-256 | 571c65e1615b13945edc9d9497c6ec57e52f7ecbad62216afdbe51c4721a4204 |