Skip to content

Files

Latest commit

 

History

History
63 lines (40 loc) · 1.41 KB

README.md

File metadata and controls

63 lines (40 loc) · 1.41 KB

Terraform FastAPI Backend

This project implements a custom HTTP backend for Terraform using FastAPI. It provides endpoints for state management and locking, allowing Terraform to store and retrieve state information, as well as implement state locking for concurrent operations.

Features

  • Store and retrieve Terraform state
  • Implement state locking mechanism
  • Compatible with Terraform's HTTP backend

Requirements

see requirements.txt

Installation

  1. Clone this repository:
git clone git@github.com:mikelv702/simple-terraform-backend.git
  1. Install the required packages:
uv pip install -r requirements.txt

Usage

  1. Start the FastAPI server:
cd src/
fastapi dev main.py
  1. Configure Terraform to use this backend:
terraform {
  backend "http" {
    address = "http://localhost:8000/tfstate/${PROJECT_ID}"
    lock_address = "http://localhost:8000/tfstate/${PROJECT_ID}/lock"
    unlock_address = "http://localhost:8000/tfstate/${PROJECT_ID}/lock"
  }
}
  1. Use Terraform as normal. The state will be stored and retrieved from your FastAPI backend.

Note

This is a basic implementation and should not be used in production without further security measures and persistent storage solutions.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.