Skip to content

rubberduckdevops/simple-terraform-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

This is a simple Terraform http backend built with FastAPI.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages