Files
hapi/infra
Bobby 494f38c1f3 01a: update Linode Terraform for provider v2
- Update all modules to use Linode provider v2 (linode/linode ~> 2.0)
- Replace deprecated cluster attribute with region in all modules
- Update firewall to use ipv4/ipv6 instead of cidrs (TCP/UDP protocols)
- Update LKE endpoint output to use api_endpoints[0] instead of deprecated hostname
- Add OBJECT_STORAGE_CLUSTER variable for object storage configuration
- Update Makefile with new variables and validate target
- Add storage/outputs.tf for standardized object storage outputs
- Update .env and .env.example with clean format (no inline comments)
- Update all terraform.tfvars.example files for consistency
2026-11-17 22:09:31 -05:00
..
2026-11-17 14:39:40 -05:00
2026-11-17 14:39:40 -05:00
2026-11-17 14:39:40 -05:00
2026-11-17 14:39:40 -05:00
2026-11-17 14:39:40 -05:00

HAPI Infrastructure with Terraform

This directory contains Terraform configurations for provisioning HAPI infrastructure on Linode.

Directory Structure

infra/
├── backend/          # Terraform state backend configuration
├── postgres/         # PostgreSQL database instances
├── storage/          # Object Storage buckets
├── network/          # Firewall rules
├── main.tf           # Main orchestration file
├── variables.tf      # Common variables
├── outputs.tf        # Common outputs
└── README.md         # This file

Prerequisites

  • Linode account with API access
  • Linode CLI (linode-cli) or direct API access for Object Storage credentials
  • Terraform 1.9.0 or higher

Setup

1. Configure Linode API Token

export LINODE_TOKEN="your-linode-api-token"
export LINODE_REGION="us-east"

2. Create Object Storage Credentials

# Create access keys
linode-object-storage keys create

# Set environment variables
export OBJECT_STORAGE_ACCESS_KEY="your-access-key"
export OBJECT_STORAGE_SECRET_KEY="your-secret-key"

3. Initialize Terraform

cd infra
terraform init

4. Apply Infrastructure

# For staging
terraform apply -var="environment=staging"

# For production
terraform apply -var="environment=production"

Resources Provisioned

PostgreSQL

  • Database instance (staging and production)
  • Connection pooling configuration
  • Automated backups

Object Storage

  • Upload buckets for staging and production
  • Terraform state storage
  • S3-compatible API

Networking

  • Firewall rules for:
    • API (port 8000)
    • PostgreSQL (port 5432)
    • Adminer (port 8080)
  • Inbound and outbound rules

Outputs

  • PostgreSQL endpoint, port, database name, credentials
  • Object Storage endpoint, access keys
  • Firewall configuration
  • Terraform backend configuration

Environment-Specific Configuration

See backend/example.tfvars for example configuration values.

Deployment

Staging

  • Deployed automatically on main branch pushes
  • Uses staging Object Storage bucket
  • Lower resource allocation

Production

  • Deployed on version tags
  • Uses production Object Storage bucket
  • Higher resource allocation and HA configuration

Maintenance

Updating Terraform State

Terraform state is automatically stored in Linode Object Storage under the configured bucket and key path.

Adding New Resources

Add modules to main.tf and create corresponding directories under infra/ following the established pattern.