I woke up ready, locked in with my coffee, and spent hours moving around pods, nodes, deployments, ingress controllers and all the other moving parts. Hours later, I was asking myself: "Am I solving an infrastructure problem, or creating one?"
That experience reminded me that good engineering isn't always about choosing the most powerful or sophisticated technology. It's about choosing the right tool for the problem you're trying to solve, without introducing unnecessary complexity.
Why ECS?
Let's be clear: Kubernetes (EKS) is an excellent container orchestration platform, but excellent doesn't mean necessary.
If you're already building your apps with Docker and deploying them on AWS, ECS gives you most of what many startups need without managing an entire Kubernetes ecosystem. It abstracts away much of Kubernetes' complexity while still providing powerful features to run and scale containers in production.
The deployment walkthrough
Think of ECS like running a restaurant. Here is the kitchen, step by step:
1. VPC and networking setup
A VPC is your private network on AWS, like the building your restaurant sits in.
I used two Availability Zones with public subnets for both the load balancer and my containers. The security groups do the protecting: only the load balancer can reach the containers.
Gotcha: public subnets avoid the cost of a NAT Gateway, but your Fargate tasks then need a public IP to pull images and send logs. For stricter isolation, use private subnets with a NAT Gateway or VPC endpoints.
2. Elastic Container Registry (ECR)
Before we can deploy any containers, we need somewhere to store their images. These images must be available at all times, because containers are regularly replaced and may need to pull a fresh copy of the software.
ECR is like Docker Hub, but integrated with AWS services.
Gotcha: if you build on an Apple Silicon Mac, your image is ARM by default. Build for
linux/amd64or set the task to ARM, or it will crash on startup with a confusing error. Also tag images with versions, not justlatest, so you can roll back.
3. ECS cluster
A cluster is the logical group that holds your workloads, like the restaurant's floor plan. With Fargate, it's just a name. There's nothing to size or patch. I created it in under a minute.
4. ECS permissions
ECS uses two IAM roles, and mixing them up is the most common beginner mistake:
- Task execution role: what ECS itself needs (pull from ECR, write logs, read secrets). Think of it as the delivery driver's access badge.
- Task role: what your code is allowed to do (read S3, call other AWS services). Think of it as the chef's key to the pantry.
Tip: start with the AWS-managed execution role policy, then give your task role only the permissions your app actually uses.
5. Task definition
Fargate is particularly interesting because AWS manages the underlying server infrastructure. You tell AWS how much CPU and memory your container needs, and it handles the rest.
What ports should it expose? How much memory does it need? What permissions should it have? We answer all of these with the task definition, a JSON file that describes everything ECS needs to know about running our container.
{
"family": "my-app",
"cpu": "256",
"memory": "512",
"networkMode": "awsvpc",
"executionRoleArn": "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/ecsTaskExecutionRole",
"taskRoleArn": "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/my-app-task-role",
"runtimePlatform": {
"operatingSystemFamily": "LINUX",
"cpuArchitecture": "X86_64"
},
"requiresCompatibilities": ["FARGATE"],
"volumes": [],
"containerDefinitions": [
{
"name": "my-app",
"image": "<YOUR_ACCOUNT_ID>.dkr.ecr.<YOUR_REGION>.amazonaws.com/my-app:v1",
"portMappings": [
{
"containerPort": 3000,
"hostPort": 3000
}
],
"essential": true,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/my-app",
"awslogs-region": "<YOUR_REGION>",
"awslogs-stream-prefix": "ecs"
}
}
}
]
}
6. Security groups
Security groups are bouncers at the door of each resource.
- Load balancer group (external): allows internet traffic on ports 80 and 443.
- ECS task group (internal): allows traffic only from the load balancer's group, on the app's port.
Tip: reference the load balancer's security group instead of IP addresses. It stays correct even when IPs change.
Even though the tasks sit in public subnets, the task group blocks everything except the load balancer.
7. Application Load Balancer and target groups
The Application Load Balancer (ALB) is the receptionist who sends each visitor to a free table. The target group is the list of tables, meaning your running containers.
For Fargate, set the target type to ip. Point the health check at a lightweight endpoint like /health that returns a 200.
Gotcha: if the health check path is wrong, the ALB marks every task unhealthy and ECS keeps killing and restarting them. When your deployment loops forever, check this first.
8. CloudWatch log groups
CloudWatch Logs is like your application's security camera footage. It captures what happens inside your containers, including application logs, errors, and messages written to stdout and stderr.
I created a log group for the service and configured the task definition to send logs using the awslogs driver. During deployment, an incorrect AWS region in the logging configuration prevented ECS from creating the log stream, and the container failed to start.
My tip: always double-check your log group, region, and IAM permissions.
9. ECS service
The service is the manager who keeps exactly N copies of your container running and replaces any that fail. It also connects them to the load balancer.
I set the desired count to 2 across two Availability Zones. I also enabled the deployment circuit breaker, so a bad release rolls back automatically instead of taking you down.
Tip: set a health check grace period so slow-starting apps don't get killed before they're ready.
The full picture
User → ALB → Target Group → ECS Service → CloudWatch Logs
Nine building blocks, and every one of them has a clear job.
When Kubernetes is still the right call
ECS isn't always the answer. Kubernetes makes more sense when:
- You need to run across multiple clouds or on-premises, with one consistent platform.
- Your team already has strong Kubernetes expertise.
- You depend on the huge Kubernetes ecosystem (service meshes, operators, advanced scheduling).
- You operate at a scale where that flexibility pays for the complexity.
If none of that sounds like you, you may be paying a complexity tax for features you'll never use.
What this taught me
- ECS with Fargate gets small and mid-size teams to production faster, with far less to maintain.
- Most of the pain is in the details: IAM roles, security groups, health checks and regions. Get those right and everything else is smooth.
- Choose Kubernetes for a reason you can name, not because it's the default.
A big thank you to Boot.dev for making this learning path so easy to follow.
ECS or Kubernetes: what are you running in production, and why? I'd love to hear your story in the comments.



Top comments (0)