ECS Deployment Guide
This document describes the ECS deployment configuration for the Sundial API.
Overview
The Sundial API is deployed to AWS ECS using Pulumi infrastructure as code. The deployment includes:
- ECS Fargate service
- Application Load Balancer with health checks
- ECR container registry
- VPC with public subnets
Health Checks
The ECS deployment includes a health check endpoint at /health that returns:
{
"status": "ok",
"timestamp": "2025-06-15T04:10:39.000Z"
}
Health Check Configuration
- Path:
/health - Port: 8080
- Protocol: HTTP
- Healthy threshold: 2 consecutive successes
- Unhealthy threshold: 3 consecutive failures
- Interval: 30 seconds
- Timeout: 5 seconds
- Grace period: 300 seconds
Deployment Commands
Local Development with Docker Compose and Localstack
-
Build and start all services (localstack + API):
bash npm run deploy:localstack -
Check service status:
bash docker compose -f docker-compose.localstack.yml ps -
Test the deployment:
bash npm run test:health npm run test:e2e:localstack -
View logs:
bash docker compose -f docker-compose.localstack.yml logs sundial-api docker compose -f docker-compose.localstack.yml logs localstack -
Stop all services:
bash npm run localstack:down
Docker Compose Configuration
The docker-compose.localstack.yml includes:
- Localstack: Simulates AWS services (ECS, ECR, EC2, ELBv2, etc.)
- Sundial API: Built from local Dockerfile and connected to localstack
- Health Checks: Both services have health checks configured
- Networking: Shared network for service communication
- Environment Variables: Configured for localstack endpoints
Production Deployment
-
Build and push Docker image:
bash docker build -t sundial-api . docker tag sundial-api:latest <ECR_REPOSITORY_URL>:latest docker push <ECR_REPOSITORY_URL>:latest -
Deploy infrastructure using Pulumi:
bash pulumi up --stack production
Troubleshooting
Local Docker Compose Issues
-
Check service health:
bash docker compose -f docker-compose.localstack.yml ps -
View service logs:
bash docker compose -f docker-compose.localstack.yml logs sundial-api docker compose -f docker-compose.localstack.yml logs localstack -
Test localstack connectivity:
bash curl http://localhost:4566/health -
Test API health endpoint:
bash curl http://localhost:8080/health
Health Check Failures
If health checks are failing:
- Check that the application is listening on port 8080
- Verify the
/healthendpoint is accessible - Check ECS service logs for startup errors
- Ensure security groups allow traffic on port 8080
- Verify Docker networking allows service communication
- Wait for localstack health check to pass before testing API
High AWS Config Charges
The previous ECS deployment was disabled due to high AWS Config charges from failing health checks. This has been resolved by:
- Adding a proper health check endpoint
- Configuring appropriate health check timeouts and thresholds
- Setting a health check grace period of 300 seconds
- Using Docker Compose for reliable local testing before production deployment