Heroku to AWS Migration Guide¶
A complete walkthrough for migrating from Heroku to AWS.
Overview¶
This guide covers migrating a typical Heroku application to AWS, including:
- Web dynos → ECS Fargate
- Postgres → Aurora
- Redis → ElastiCache
- Environment variables → Secrets Manager
Estimated time: 2-4 hours (vs. 2-3 months manually)
Prerequisites¶
- AWS CLI configured
- Heroku CLI logged in
- Terraform installed
- InfraIQ installed
Step 1: Scan Heroku¶
Review the scan results:
Step 2: Map to AWS¶
Review service mappings:
Step 3: Generate Terraform¶
Step 4: Configure Variables¶
Edit terraform/terraform.tfvars:
# Database
db_password = "your-secure-password"
# Application secrets
environment_variables = {
SECRET_KEY_BASE = "your-secret-key"
# Copy from Heroku config vars
}
Step 5: Deploy Infrastructure¶
Step 6: Migrate Database¶
Use DataIQ for zero-downtime migration:
infraiq dataiq migrate \
--source $HEROKU_DATABASE_URL \
--target $AWS_DATABASE_URL \
--strategy blue-green
Step 7: Deploy Application¶
# Build and push Docker image
docker build -t my-app .
docker tag my-app:latest $ECR_REPO:latest
docker push $ECR_REPO:latest
# Update ECS service
aws ecs update-service --cluster my-cluster --service my-service --force-new-deployment
Step 8: DNS Cutover¶
- Update DNS to point to AWS load balancer
- Monitor for errors
- Scale down Heroku after validation
Step 9: Validate¶
infraiq verify scan --provider aws --output post-migration.json
infraiq verify analyze post-migration.json
Rollback Plan¶
If issues occur:
- Switch DNS back to Heroku
- Heroku app should still be running
- Investigate and fix AWS issues
- Retry cutover
Cost Comparison¶
| Component | Heroku | AWS |
|---|---|---|
| 2x Standard-2X | $100/mo | ~$50/mo (Fargate) |
| Postgres Standard | $50/mo | ~$30/mo (RDS) |
| Redis Premium | $30/mo | ~$15/mo (ElastiCache) |
| Total | $180/mo | ~$95/mo |