Deploys AWS infrastructure with research-first approach. Uses AWS MCP tools for documentation, regional availability, and resource management. ALWAYS searches AWS documentation before writing code, explains services and abbreviations, considers alternatives, maintains organized aws/ folder, and CRITICALLY offers to destroy resources after testing. Use PROACTIVELY for any AWS deployment, Terraform, ECS, Fargate, Lambda, S3, RDS, or cloud infrastructure tasks. MUST BE USED for prototype/learning projects to avoid unexpected costs. (project)
Deploy and destroy pharma-test-gen ECS/Fargate infrastructure.
| Key | Value |
|---|---|
| Project | pharma-test-gen |
| Region | eu-west-2 |
| Account | 275333454012 |
| ECR | 275333454012.dkr.ecr.eu-west-2.amazonaws.com |
Full commands: reference/quick-commands.md
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin 275333454012.dkr.ecr.eu-west-2.amazonaws.com
# API
docker buildx build --platform linux/amd64 -f Dockerfile.api.pip -t 275333454012.dkr.ecr.eu-west-2.amazonaws.com/pharma-test-gen-api:staging-latest --push .
# Worker
docker buildx build --platform linux/amd64 -f Dockerfile.worker.pip -t 275333454012.dkr.ecr.eu-west-2.amazonaws.com/pharma-test-gen-worker:staging-latest --push .
# Frontend (needs CLERK key)
docker buildx build --platform linux/amd64 -f Dockerfile.frontend --build-arg NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxx -t 275333454012.dkr.ecr.eu-west-2.amazonaws.com/pharma-test-gen-frontend:staging-latest --push .
cd aws/terraform && terraform apply -var-file=environments/staging.tfvars -auto-approve
tar -czvf /tmp/chroma_db.tar.gz -C main chroma_db
aws s3 cp /tmp/chroma_db.tar.gz s3://pharma-test-gen-vectors-staging/chroma_db.tar.gz --region eu-west-2
aws ecs update-service --cluster pharma-test-gen-cluster --service pharma-test-gen-api --force-new-deployment --region eu-west-2
aws ecs update-service --cluster pharma-test-gen-cluster --service pharma-test-gen-worker --force-new-deployment --desired-count 1 --region eu-west-2
aws ecs update-service --cluster pharma-test-gen-cluster --service pharma-test-gen-frontend --force-new-deployment --region eu-west-2
aws ecs describe-services --cluster pharma-test-gen-cluster --services pharma-test-gen-api pharma-test-gen-worker pharma-test-gen-frontend --region eu-west-2 --query 'services[].{name:serviceName,desired:desiredCount,running:runningCount}' --output table
python aws/scripts/destroy.py --yes --skip-ecr
cd aws/terraform && terraform destroy -var-file=environments/staging.tfvars -auto-approve
aws configservice stop-configuration-recorder --configuration-recorder-name pharma --region eu-west-2
Full guide: reference/troubleshooting.md
| Symptom | Cause | Fix |
|---|---|---|
| Worker S3 403 Forbidden | ChromaDB tarball deleted | Re-upload: aws s3 cp chroma_db.tar.gz s3://pharma-test-gen-vectors-staging/ |
| Worker desiredCount=0 | Scaled down during destroy | Scale up: aws ecs update-service --desired-count 1 |
uv: command not found in WSL | uv not in Ubuntu | Use python3 directly |
| Terraform state locked | Previous run crashed | terraform force-unlock <LOCK_ID> |
| ECR login failed | Token expired | Re-run ECR login command |
| Docker buildx not found | buildx not installed | docker buildx create --use |
| Service | Endpoint |
|---|---|
| Production (Route 53) | https://csvgeneration.com/ |
| API Health | https://csvgeneration.com/health |
| Frontend | https://csvgeneration.com/generate |
aws elbv2 describe-load-balancers --names pharma-test-gen-api-alb pharma-test-gen-frontend-alb --region eu-west-2 --query 'LoadBalancers[].{name:LoadBalancerName,dns:DNSName}' --output table
| Service | Log Group |
|---|---|
| API | /ecs/pharma-test-gen/api |
| Worker | /ecs/pharma-test-gen/worker |
| Frontend | /ecs/pharma-test-gen/frontend |
aws logs filter-log-events --log-group-name /ecs/pharma-test-gen/worker --start-time $(date -d '5 minutes ago' +%s000) --region eu-west-2 --query 'events[-10:].message' --output text
All commands need WSL wrapper on Windows:
wsl -d Ubuntu -e bash -c "cd /mnt/c/Users/.../thesis_project && <command>"
| Script | Purpose |
|---|---|
aws/scripts/deploy.py | Full deployment orchestrator |
aws/scripts/destroy.py | Clean teardown with S3 emptying |
aws/scripts/1_upload_chroma_to_s3.py | ChromaDB S3 upload (requires boto3) |
Estimated costs while running:
ALWAYS offer to destroy after testing to avoid unexpected charges.