Skip to main content

Terraform Infrastructure

Eli Health uses Terraform for Infrastructure as Code to manage all cloud resources across environments. This document explains how our infrastructure is organized.

What Terraform Does for Us

Terraform sets up all the foundational cloud infrastructure that our applications run on:

Environment Setup

We have three identical environments, each with their own infrastructure:

How It's Organized

Our Terraform code is organized into reusable modules in the eli-devops repository:

For Backend Developers

What You Need to Know:

  1. Infrastructure is managed by DevOps - You don't need to touch Terraform usually
  2. Three environments available - Development, Staging, Production
  3. Everything is set up for you - Cloud Run, databases, networking, security
  4. Focus on your application code - Infrastructure changes are rare and handled by DevOps

When You Might Need Terraform:

  • Adding a new environment variable to Cloud Run
  • Changing resource limits (memory, CPU)
  • Adding a new service
  • Setting up BigQuery permissions

Common Operations:

# Check what would change
cd eli-devops/tf
TMPDIR=~/terraform_tmp terraform plan -var-file=development.tfvars

# Apply infrastructure changes
TMPDIR=~/terraform_tmp terraform apply -var-file=development.tfvars -auto-approve

Key Files

FilePurposeWhen to modify
development.tfvarsDev environment configTesting infrastructure changes
staging.tfvarsStaging environment configPre-production validation
production.tfvarsProduction environment configLive environment (careful!)
main.tfRoot Terraform moduleAdding new modules or services

Infrastructure Components

What Gets Created:

🏃 Cloud Run Services

  • Container platform for all our APIs
  • Auto-scaling based on traffic
  • HTTPS endpoints with SSL certificates

🗄️ PostgreSQL Database

  • Managed Cloud SQL instance
  • Automatic backups and high availability
  • Secure connection via Cloud SQL Proxy

📊 BigQuery Data Warehouse

  • Analytics and reporting database
  • Real-time data pipeline from PostgreSQL
  • User access management via IAM

🌐 Networking & Security

  • VPC with proper firewall rules
  • IAM roles and service accounts
  • SSL certificates and load balancing

Environment Differences

ComponentDevelopmentStagingProduction
Instance Sizee2-microe2-standarde2-standard-4
Databasedb-f1-microdb-custom-2-8192db-custom-4-16384
MonitoringBasicFullFull + Alerts
BackupsDailyDailyHourly

Getting Help

For Infrastructure Issues:

  1. Check the DevOps Overview for architecture understanding
  2. Contact DevOps team for infrastructure changes
  3. Use BigQuery Access guide for data permissions

For Application Deployment:

  1. Your GitHub Actions handle deployment automatically
  2. Check Cloud Run logs in GCP Console
  3. Use gcloud run deploy for manual deployments