Skip to main content

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 solution for free homelabs IAC.
The major constraint here is to find a free backend that I feel safe to use.
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
    

terraflex init

[!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

  • allow for multiple state files
  • 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

terraflex-0.1.3.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

terraflex-0.1.3-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file terraflex-0.1.3.tar.gz.

File metadata

  • Download URL: terraflex-0.1.3.tar.gz
  • Upload date:
  • Size: 15.7 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

Hashes for terraflex-0.1.3.tar.gz
Algorithm Hash digest
SHA256 cd6fa4abd00dc65f356a1e76d0da741c0e60a3a105ac7a921cbfd249a4dc279b
MD5 79dc72de181101b5dc783145d50e064d
BLAKE2b-256 9ebeaddac879dbfa041e324b9e2e1864194626f9471cceb79b43fad1a06f3b61

See more details on using hashes here.

File details

Details for the file terraflex-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: terraflex-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 23.4 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

Hashes for terraflex-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 de541fda74e6aec68b4e667954415249b17a2577e535ac80dab22f6343613f2a
MD5 07c96cb9836c28c2b479436d2a27f5ec
BLAKE2b-256 1c7eaa0c192b15e4a0a45bc1cf6e6155e687a73b628ccc23f998c6e1f2b8bcc9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page