Supabase to AWS Migration

A comprehensive guide for migrating from Supabase to AWS Aurora, DynamoDB, and Cognito

11 Weeks
Timeline
7-10 People
Team Size
6 Phases
Migration Steps

Migration Overview

Current State

  • Supabase PostgreSQL (41 tables)
  • 5-6K active users
  • ECS Fargate (3 regions)
  • Aurora already deployed

Target State

  • Aurora PostgreSQL Global DB
  • DynamoDB Global Tables
  • AWS Cognito for auth
  • Multi-region (US, Mumbai, Singapore)

Key Principles

  • Zero-downtime migration
  • Dual-write pattern
  • Gradual user migration
  • Easy rollback at any phase

Migration Phases

Follow these 6 phases using AWS Console GUI

Phase 0

Complete AWS Services Setup

Week 1

Day 1: Aurora Validation

  1. Navigate to AWS Console → RDS
  2. Verify cluster helium-prod-aurora-cluster is available
  3. Check endpoint: helium-prod-aurora-cluster.cluster-ckfawcg4sknj.us-east-1.rds.amazonaws.com
  4. Verify Enhanced Monitoring and Performance Insights enabled
  5. Locate auto-created secret in Secrets Manager

Day 2-3: DynamoDB Setup

  1. Navigate to AWS Console → DynamoDB
  2. Click Create table
  3. Table name: helium-prod-data
  4. Partition key: PK (String), Sort key: SK (String)
  5. Capacity mode: On-demand
  6. Enable Deletion protection
  7. Create 3 Global Secondary Indexes:
    • message_id-index (PK: message_id, SK: PK)
    • user_id-created_at-index (PK: user_id, SK: created_at)
    • thread_id-type-index (PK: thread_id, SK: entity_type)
GSIs take 15-90 minutes to create. Create one at a time.

Day 4-5: Cognito Setup

  1. Navigate to AWS Console → Cognito
  2. Click Create user pool
  3. Enable Email and Username sign-in
  4. Set password policy (min 8 chars, uppercase, lowercase, numbers, symbols)
  5. User pool name: helium-prod-users
  6. Create app client: helium-web-client
  7. Enable authentication flows: USER_PASSWORD_AUTH, REFRESH_TOKEN_AUTH
  8. Store credentials in Secrets Manager

Day 6-7: Monitoring Setup

  1. Navigate to CloudWatch → Log groups
  2. Create log groups:
    • /aws/rds/cluster/helium-prod-aurora-cluster/postgresql
    • /helium/migration
    • /helium/dual-write
  3. Enable X-Ray for ECS tasks
  4. Create CloudWatch dashboard: helium-migration-dashboard
  5. Review CloudFront configuration
Phase 1

Infrastructure Validation

Week 2

Day 1-2: Schema Migration

  1. Export Supabase schema using pg_dump
  2. Connect to Aurora using database client
  3. Import schema to Aurora cluster
  4. Verify all tables, indexes, and constraints
  5. Check RLS policies migrated correctly

Day 3-4: Connection Testing

  1. Test Aurora connection from ECS tasks
  2. Test DynamoDB connection and operations
  3. Test Cognito integration
  4. Verify security groups and network connectivity
  5. Monitor CloudWatch logs for connection results

Day 5-7: Performance Baseline

  1. Navigate to RDS → Performance Insights
  2. Run test queries and measure performance
  3. Target: Simple queries < 10ms, Complex < 50ms
  4. Navigate to DynamoDB → Metrics
  5. Monitor read/write latency (Target: < 20ms)
Phase 2

Application Integration

Week 3-4

Day 1-10: Code Implementation

  1. Create database abstraction layer (database_manager.py)
  2. Implement base repository with dual-write logic
  3. Update agent repository for dual-write support
  4. Create DynamoDB repository for high-volume data
  5. Update FastAPI application with database manager

Day 11-14: Deploy with Feature Flags

  1. Navigate to AWS Console → ECS
  2. Update task definition with environment variables:
    • ENABLE_AURORA=true
    • ENABLE_DYNAMODB=true
    • WRITE_MODE=both
  3. Build and push new Docker image to ECR
  4. Update ECS service with new task definition
  5. Monitor dual-write operations in CloudWatch
Phase 3

Multi-Region Expansion

Week 5-6

Day 1-3: Mumbai Region Setup

  1. Switch to ap-south-1 region in AWS Console
  2. Navigate to VPC and create Mumbai VPC
  3. Create subnets, Internet Gateway, NAT Gateway
  4. Navigate to ECS and verify existing cluster
  5. Update existing services with new configurations

Day 4-6: Enable Aurora Global Database

  1. Navigate to RDS in us-east-1
  2. Select Aurora cluster helium-prod-aurora-cluster
  3. Click Actions → Add AWS Region
  4. Select Asia Pacific (Mumbai)
  5. Configure Serverless v2 with same ACU settings
  6. Repeat for Asia Pacific (Singapore)
  7. Monitor replication progress (~30 minutes per region)

Day 7-10: Enable DynamoDB Global Tables

  1. Navigate to DynamoDB in us-east-1
  2. Select table helium-prod-data
  3. Go to Global Tables tab
  4. Click Create replica
  5. Select Asia Pacific (Mumbai)
  6. Repeat for Asia Pacific (Singapore)
  7. Monitor replication status (~15 minutes per region)

Day 11-14: Update Regional Deployments

  1. Update Mumbai ECS services with new task definitions
  2. Update Singapore ECS services with new configurations
  3. Implement regional routing logic in application
  4. Verify cross-region replication working
  5. Check replication lag < 2 seconds
Phase 4

Data Validation & Testing

Week 7-8

Day 1-3: Data Consistency Validation

  1. Run validation scripts to compare Supabase vs Aurora
  2. Verify row counts match across all tables
  3. Check data integrity and constraints
  4. Validate DynamoDB data consistency
  5. Document any discrepancies found

Day 4-7: Performance Testing

  1. Monitor CloudWatch metrics for all services
  2. Use RDS Performance Insights for query analysis
  3. Check DynamoDB Metrics for throughput
  4. Run load testing with 100+ concurrent users
  5. Verify X-Ray traces for distributed requests

Day 8-14: Security & Compliance

  1. Review IAM permissions and roles
  2. Check CloudTrail audit logs
  3. Verify encryption at rest and in transit
  4. Review Security Hub findings
  5. Test backup and recovery procedures
Phase 5

User Migration

Week 9-10

Batch Migration Strategy

Batch 1: New/inactive users (500-1000)
Batch 2: Low-activity users (1000-1500)
Batch 3: Medium-activity users (1500-2000)
Batch 4: High-activity users (1000-1500)
Batch 5: Power users (500-1000)

Migration Process

  1. Identify users for current batch using SQL queries
  2. Navigate to Cognito → Users
  3. Create users in Cognito with temporary passwords
  4. Send migration notifications via SES
  5. Monitor user authentication success rate
  6. Collect user feedback and address issues
  7. Wait 2-3 days before next batch
Phase 6

Cutover & Cleanup

Week 11-12

Day 1-7: Application Cutover

  1. Run final data validation and sync
  2. Navigate to ECS and update task definitions
  3. Set environment variables:
    • WRITE_MODE=aws
    • ENABLE_COGNITO=true
  4. Deploy to all regions (US, Mumbai, Singapore)
  5. Monitor CloudWatch for 48 hours continuously
  6. Verify all services using AWS-only backend

Day 8-14: Supabase Deprecation

  1. Export final Supabase backup
  2. Upload backup to S3 for archival
  3. Navigate to Supabase Console
  4. Pause project (don't delete immediately)
  5. Keep paused for 30 days as safety net
  6. Remove Supabase environment variables from ECS
  7. Update documentation and celebrate! 🎉

Migration Timeline

Week 1

Complete AWS Services Setup

Week 2

Infrastructure Validation

Week 3-4

Application Integration

Week 5-6

Multi-Region Expansion

Week 7-8

Data Validation & Testing

Week 9-10

User Migration

Week 11-12

Cutover & Cleanup

Cost Analysis

Monthly cost estimate for 10K users

Infrastructure

ECS Fargate (3 regions) $285
Aurora Primary + Replicas $779
ElastiCache Redis $558
DynamoDB Global Tables $11

Services

AWS Bedrock (AI) $476
CloudFront CDN $66
Cognito Auth $50
Data Transfer $325

Monitoring & Other

NAT Gateway $120
Application Load Balancer $80
CloudWatch Logs $40
Total Monthly Cost $2,790
Cost per User $0.28

Comparison with Supabase

Current Supabase Cost
~$500-800/month
AWS Cost
~$2,790/month
Additional Cost
~$2,000-2,300/month

Benefits for Additional Cost:

  • Full infrastructure control
  • Multi-region performance (US, Mumbai, Singapore)
  • AWS Bedrock AI integration
  • Scalability to millions of users
  • Enterprise compliance and security