All projects
  • AWS
  • Terraform
  • ECS Fargate
  • Secure CI/CD

Cloud-Native Task Manager on AWS

A production-inspired FastAPI workload that shows the full cloud engineering lifecycle: app development, containerization, Infrastructure as Code, secure delivery, database migrations, observability, reliability controls and cost-aware operations.

The API docs are online only while the cost-controlled AWS environment is running. Try the start/stop switch further down to see how that works.

Terraform modules
6
Availability Zone
1
CloudWatch alarms
4
deployment stages
7

Project summary

A small task-management API is the workload. The real subject is the platform that deploys and operates it securely and repeatably.

role
Independent cloud and DevOps engineering project
runtime
Amazon ECS Fargate behind an Application Load Balancer
data
Private Amazon RDS PostgreSQL with SQLAlchemy and Alembic
delivery
GitHub Actions with short-lived AWS OIDC sessions
infrastructure
Six reusable Terraform modules with encrypted S3 remote state

Architecture

HTTPS terminates at the load balancer. ECS tasks accept traffic only from the ALB security group, and PostgreSQL accepts traffic only from the ECS security group.

Request path

Delivery path

Provisioning path

What I built

I designed and implemented the application, the cloud infrastructure, the secure deployment workflow, the operational controls and the documentation.

Application

FastAPI REST API with typed Pydantic models, SQLAlchemy persistence, CRUD endpoints, process health checks, database readiness checks, Swagger and ReDoc.

Container platform

A Python 3.12 slim image with dependency-layer caching, a non-root runtime user, container health checks and Amazon ECR image storage.

Infrastructure

Reusable Terraform modules for networking, security, database, load balancing, ECS and monitoring, composed per environment with remote state.

CI/CD deployment flow

No persistent AWS access keys, and a traceable application revision for every commit. Replay the run below.

passed aws-ecs-terraform-task-manager main
  1. test
    • ruff
    • pytest
  2. build
    • docker build
  3. auth
    • aws oidc
  4. publish
    • push ECR
  5. release
    • task def
    • migrate
  6. deploy
    • update
    • wait stable
  7. verify
    • smoke test
  8. environmentAPI docs

Security and reliability

Controls cover identity, network isolation, secrets, encrypted transport, safe container execution and automated deployment checks.

Security controls

  • GitHub Actions OIDC trust restricted by repository and branch
  • Separate ECS task role and execution role
  • Private, non-public RDS PostgreSQL
  • Security groups chained ALB to ECS to RDS
  • Database credentials in AWS Secrets Manager
  • HTTPS with ACM certificates and HTTP-to-HTTPS redirect
  • Encrypted, versioned Terraform state
  • Non-root application container

Reliability controls

  • Process health and database readiness endpoints
  • Container and ALB target-group health checks
  • ECS deployment circuit breaker with rollback
  • One-off migration task with exit-code check
  • Service-stability waiter before smoke testing
  • HTTPS smoke test with retries
  • CloudWatch logs and four health alarms
  • Documented recovery and rollback procedures

Engineering decisions and trade-offs

No NAT Gateway
ECS tasks run in public subnets with public IPs to avoid NAT Gateway cost. They still aren't directly reachable, because inbound access is limited to the ALB security group.
Who owns the task definition
Terraform manages persistent infrastructure and the baseline task definition. GitHub Actions handles later application revisions, so an infrastructure apply never rolls the service back to the bootstrap image.
Backward-compatible migrations
Alembic migrations run before the rolling ECS update, so every schema change has to stay compatible with the running app until the rollout finishes.

Cost-controlled operations

The AWS runtime starts for demos and stops afterwards without destroying persistent infrastructure. Flip the switch to see what changes.

Environment

Two PowerShell scripts, one for each direction.

ECS service1 task running
RDS PostgreSQLavailable
ALB and networkingprovisioned
ECR imageskept
IAM roleskept
CloudWatch logskept
Terraform statekept
Database storagekept

✓ environment running. The API docs are online.

Start workflow

Starts RDS, waits until the database is available, then scales the ECS service to one running task.

Stop workflow

Scales ECS compute to zero and temporarily stops RDS. Networking, ALB, ECR, IAM, logs, Terraform state and database storage stay provisioned.

Limitations and roadmap

Production-inspired, not fully production-ready. The gaps are listed as explicit next steps.

Current limitations

  • Single-AZ RDS and a single ECS task
  • No application authentication or authorization
  • No WAF, autoscaling, rate limiting or pagination
  • No separate production environment
  • No published coverage threshold or integrated image and IaC scanner

Planned improvements

  • Terraform validation plus dependency, image and IaC security scanning
  • API authentication, authorization, rate limiting and pagination
  • Published test coverage with an enforced minimum
  • Private ECS subnets, autoscaling, WAF and a production environment
  • Structured logs, correlation IDs, metrics and alert notifications