Deploy a Containerised App on ECS Fargate
Part of the AWS Roadmap
In short
This project is a small version of how many Indian startups actually run in production: a container image in ECR, Fargate tasks across AZs, an ALB in front, logs in CloudWatch and secrets kept out of the image.
A project that containerises a web app, pushes the image to ECR and runs it as an ECS Fargate service behind an ALB, with logs in CloudWatch and secrets from Secrets Manager or Parameter Store.

Think of it like this
Packing for a food truck festival
You pack your kitchen into a standard container that fits any truck. At the festival in Pune, the organiser gives you a stall slot, power and water, and the entrance gate sends customers to whichever stall has the shortest queue. Your gas cylinder's lock code arrives in a sealed envelope, not written on the truck. Container image, Fargate, ALB and Secrets Manager.
Watch it happen
Project build order
1/5Containerise a small Node or Python API with a /health route. Run it locally with docker run first.
The big ideas
What you need to know
Network layout
ALB in public subnets. Tasks in private subnets with no public IP. The task security group only allows the app port from the ALB's security group.
Secrets at runtime
Use the secrets field in the container definition with a Secrets Manager or Parameter Store ARN. ECS injects it as an environment variable.
Logs and health
awslogs sends output to a log group. Target group health checks and container health checks show problems early.
Service auto scaling
Add target tracking on average CPU or ALB requests per target to scale the number of tasks.
See it in code
Walk through the code
1aws ecs create-service \2 --cluster shop \3 --service-name shop-api \4 --task-definition shop-api:7 \5 --desired-count 2 \6 --launch-type FARGATE \7 --network-configuration "awsvpcConfiguration={subnets=[subnet-0priv1a,subnet-0priv1b],securityGroups=[sg-0task123],assignPublicIp=DISABLED}" \8 --load-balancers "targetGroupArn=arn:aws:elasticloadbalancing:ap-south-1:111122223333:targetgroup/shop-api-tg/abc,containerName=api,containerPort=8080" \9 --deployment-configuration "deploymentCircuitBreaker={enable=true,rollback=true}" \10 --health-check-grace-period-seconds 6011 12# In the container definition, inject the secret like this:13# "secrets": [{ "name": "DB_PASSWORD",14# "valueFrom": "arn:aws:secretsmanager:ap-south-1:111122223333:secret:shop/db-AbCdEf" }]1/5Run two copies of revision 7 of the task definition on Fargate.
AWS CLI v2. Once it's running, a new deploy is just a new task definition revision followed by aws ecs update-service.
Save yourself the pain
Common mistakes
Oops
Baking the .env file with real passwords into the Docker image.
Do this instead
Anyone who can pull the image can read it. Inject secrets at runtime from Secrets Manager or Parameter Store.
Oops
Using an instance-type target group for Fargate.
Do this instead
Fargate tasks register by IP, so create the target group with target type ip.
Oops
Leaving a NAT gateway and ALB running for weeks after the demo.
Do this instead
Both are billed by the hour. Tear down with IaC or a script and keep the diagram and README as your proof.
Your mission
Deploy, update, roll back
Quick check
Your service shows tasks starting and then stopping repeatedly, and the ALB reports them unhealthy. What's a likely first fix to check?
Go deeper
- 1Define the whole setup with CDK or Terraform so it can be recreated with one command.
- 2Add a GitHub Actions workflow that deploys a new image on every push to main.
- 3Destroy the stack after recording a demo to avoid ongoing charges.
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.