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:
- Infrastructure is managed by DevOps - You don't need to touch Terraform usually
- Three environments available - Development, Staging, Production
- Everything is set up for you - Cloud Run, databases, networking, security
- 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
| File | Purpose | When to modify |
|---|---|---|
development.tfvars | Dev environment config | Testing infrastructure changes |
staging.tfvars | Staging environment config | Pre-production validation |
production.tfvars | Production environment config | Live environment (careful!) |
main.tf | Root Terraform module | Adding 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
| Component | Development | Staging | Production |
|---|---|---|---|
| Instance Size | e2-micro | e2-standard | e2-standard-4 |
| Database | db-f1-micro | db-custom-2-8192 | db-custom-4-16384 |
| Monitoring | Basic | Full | Full + Alerts |
| Backups | Daily | Daily | Hourly |
Getting Help
For Infrastructure Issues:
- Check the DevOps Overview for architecture understanding
- Contact DevOps team for infrastructure changes
- Use BigQuery Access guide for data permissions
For Application Deployment:
- Your GitHub Actions handle deployment automatically
- Check Cloud Run logs in GCP Console
- Use
gcloud run deployfor manual deployments
Related Documentation
- DevOps Overview - Complete DevOps architecture
- BigQuery Access - Managing data warehouse permissions
- Data Pipeline - Infrastructure for data processing