# Amar Mascotas Infrastructure as Code Pulumi configurations for deploying the Amar Mascotas backend to different cloud providers. ## Structure ``` infra/ ├── digitalocean/ # DigitalOcean configuration ├── aws/ # AWS configuration ├── gcp/ # Google Cloud configuration └── shared/ # Shared Python utilities ``` ## Prerequisites ```bash # Install Pulumi curl -fsSL https://get.pulumi.com | sh # Install Python dependencies pip install pulumi pulumi-digitalocean pulumi-aws pulumi-gcp # Login to Pulumi (free tier, or use local state) pulumi login --local # Local state (no account needed) # OR pulumi login # Pulumi Cloud (free tier available) ``` ## Cloud Provider Setup ### DigitalOcean ```bash export DIGITALOCEAN_TOKEN="your-api-token" ``` ### AWS ```bash aws configure # Or set environment variables: export AWS_ACCESS_KEY_ID="xxx" export AWS_SECRET_ACCESS_KEY="xxx" export AWS_REGION="us-east-1" ``` ### GCP ```bash gcloud auth application-default login export GOOGLE_PROJECT="your-project-id" ``` ## Usage ```bash cd infra/digitalocean # or aws, gcp # Preview changes pulumi preview # Deploy pulumi up # Destroy pulumi destroy ``` ## Cost Comparison (Estimated Monthly) | Resource | DigitalOcean | AWS | GCP | |----------|--------------|-----|-----| | Compute (4GB RAM) | $24 | $35 | $30 | | Managed Postgres | $15 | $25 | $25 | | Managed Redis | $15 | $15 | $20 | | Load Balancer | $12 | $18 | $18 | | **Total** | **~$66** | **~$93** | **~$93** | ## Architecture All configurations deploy: - 1x App server (Django + Gunicorn + Celery) - 1x Managed PostgreSQL with PostGIS - 1x Managed Redis - VPC/Network isolation - Firewall rules (SSH, HTTP, HTTPS) ## Provider Comparison ### Code Complexity | Aspect | DigitalOcean | AWS | GCP | |--------|--------------|-----|-----| | Lines of code | ~180 | ~280 | ~260 | | Resources created | 8 | 15 | 14 | | Networking setup | Simple (VPC only) | Complex (VPC + subnets + IGW + routes) | Medium (VPC + subnet + peering) | | Learning curve | Low | High | Medium | ### Feature Comparison | Feature | DigitalOcean | AWS | GCP | |---------|--------------|-----|-----| | **Managed Postgres** | Yes (DO Database) | Yes (RDS) | Yes (Cloud SQL) | | **PostGIS** | Via extension | Via extension | Via flags | | **Managed Redis** | Yes (DO Database) | Yes (ElastiCache) | Yes (Memorystore) | | **Private networking** | VPC | VPC + subnets | VPC + peering | | **Load balancer** | $12/mo | $18/mo | $18/mo | | **Auto-scaling** | Limited | Full (ASG) | Full (MIG) | | **Regions** | 15 | 30+ | 35+ | | **Free tier** | None | 12 months | $300 credit | ### When to Choose Each **DigitalOcean:** - Simple deployments - Cost-sensitive - Small teams - Latin America (São Paulo region) **AWS:** - Enterprise requirements - Need advanced services (Lambda, SQS, etc.) - Complex networking needs - Compliance requirements (HIPAA, PCI) **GCP:** - Machine learning integration - Kubernetes-first approach - Good free credits to start - BigQuery/analytics needs ### Real Cost Breakdown (Your App) ``` DigitalOcean (~$66/mo): ├── Droplet 4GB $24 ├── Managed Postgres $15 ├── Managed Redis $15 └── Load Balancer $12 (optional) AWS (~$93/mo): ├── EC2 t3.medium $35 ├── RDS db.t3.micro $25 ├── ElastiCache $15 └── ALB $18 (optional) GCP (~$93/mo): ├── e2-medium $30 ├── Cloud SQL $25 ├── Memorystore $20 └── Load Balancer $18 (optional) ``` ### Migration Effort If you ever need to switch providers: | From → To | Effort | Notes | |-----------|--------|-------| | DO → AWS | Medium | Postgres dump/restore, reconfigure Redis | | DO → GCP | Medium | Same as above | | AWS → GCP | Medium | Similar services, different APIs | | Any → Kubernetes | High | Need to containerize everything | The Pulumi code is portable - only the provider-specific resources change.