This guide will help you get the Terraform Data Upload Backend Service running in minutes.
- Go 1.25 or higher installed
- Basic familiarity with Terraform
# Build the binary
make build
# Or manually
go build -o terraform-backend-service ./cmd/server# Run the service (defaults to port 7777 with CSV storage)
./terraform-backend-serviceYou should see output like:
2025/10/12 14:45:11 Starting Terraform Backend Service v1.0.0
2025/10/12 14:45:11 Server will listen on 127.0.0.1:7777
2025/10/12 14:45:11 Using CSV storage at: ./data
2025/10/12 14:45:11 Demo credentials added: OrgID=11111111-2222-3333-4444-555555555555, APIKey=demo-api-key-12345
2025/10/12 14:45:11 Server started successfully
2025/10/12 14:45:11 Press Ctrl+C to stop
Open a new terminal and test the health endpoint:
curl http://127.0.0.1:7777/healthExpected output:
{
"status": "healthy",
"version": "1.0.0",
"service": "terraform-backend-service"
}Test data upload:
curl -X POST "http://127.0.0.1:7777/api/v1/upload" \
-H "X-Org-ID: 11111111-2222-3333-4444-555555555555" \
-H "X-API-Key: demo-api-key-12345" \
-H "Content-Type: application/json" \
-d '{"resource_type": "vm_instance", "resource_name": "web-server-01", "status": "running", "region": "us-east-1"}'Expected output:
{
"status": "success",
"message": "Data uploaded successfully",
"org_id": "11111111-2222-3333-4444-555555555555"
}Check the CSV file:
cat data/11111111-2222-3333-4444-555555555555.csvRetrieve all uploaded data:
curl "http://127.0.0.1:7777/api/v1/data" \
-H "X-Org-ID: 11111111-2222-3333-4444-555555555555" \
-H "X-API-Key: demo-api-key-12345"In your Terraform provider configuration:
provider "your_provider" {
url = "http://127.0.0.1:7777"
org_id = "11111111-2222-3333-4444-555555555555"
apikey = "demo-api-key-12345"
}The provider should send POST requests to http://127.0.0.1:7777/api/v1/upload with:
- Header:
X-Org-ID: 11111111-2222-3333-4444-555555555555 - Header:
X-API-Key: demo-api-key-12345 - Body: JSON data to be stored
You can customize the service using environment variables:
# Change the port
export PORT=8080
./terraform-backend-service
# Change storage location
export STORAGE_PATH=/var/data/terraform
./terraform-backend-service
# Use memory storage for state backend (instead of CSV)
export STORAGE_TYPE=memory
export PORT=8080
./terraform-backend-serviceSee README.md for complete configuration options.
Data is stored in CSV files with the following format:
- Filename:
{org_id}.csv - Location:
./data/(configurable viaSTORAGE_PATH) - Format:
timestamp,org_id,data(JSON data column) - All uploads are appended to maintain historical order
Make sure the service is running:
curl http://127.0.0.1:7777/healthVerify you're using the correct credentials:
- Org ID:
11111111-2222-3333-4444-555555555555 - API Key:
demo-api-key-12345
Check the headers:
curl -v \
-H "X-Org-ID: 11111111-2222-3333-4444-555555555555" \
-H "X-API-Key: demo-api-key-12345" \
http://127.0.0.1:7777/api/v1/dataEnsure the data directory exists and is writable:
mkdir -p ./data
ls -la ./data- Read the README.md for detailed API documentation
- Add your own organization credentials in
cmd/server/main.go - Configure your Terraform provider to upload data
- Set up proper authentication in production
Press Ctrl+C in the terminal where the service is running. The service will perform a graceful shutdown.