Skip to content

AWS ECS & Fargate — Container Services

Amazon Elastic Container Service (ECS) is a fully managed container orchestration service. Fargate is a serverless compute engine for containers that removes the need to manage EC2 servers.

In Azure terms: ECS ≈ Azure Container Apps (Fargate) / Azure Container Instances (ACI) / VMSS-backed container hosting

ConceptDescription
ClusterLogical grouping of compute resources for running tasks and services
Task DefinitionBlueprint for your container(s) — image, CPU, memory, ports, env vars, IAM role
TaskA running instance of a Task Definition (one-off execution)
ServiceMaintains a desired count of running tasks, integrates with load balancers
ContainerThe individual Docker container within a task
ECRElastic Container Registry — private Docker image registry
Launch TypeDescriptionAzure Equivalent
FargateServerless — AWS manages the underlying EC2 serversAzure Container Apps / ACI
EC2You manage a fleet of EC2 instances for ECS to place containers onAzure Container Instances on VMSS
External (ECS Anywhere)Run ECS on your own on-prem or edge serversAzure Arc

With Fargate you only specify CPU and memory — no server management:

You define: AWS manages:
- Task Definition - EC2 hosts
- CPU/Memory - Patching
- Container image - Scaling compute
- VPC/Security Group

Supported CPU/Memory combinations:

vCPUMemory Options
0.25 vCPU0.5, 1, 2 GB
0.5 vCPU1, 2, 3, 4 GB
1 vCPU2–8 GB
2 vCPU4–16 GB
4 vCPU8–30 GB
8 vCPU16–60 GB
16 vCPU32–120 GB
{
"family": "my-web-app",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "512",
"memory": "1024",
"executionRoleArn": "arn:aws:iam::123456789:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"name": "web",
"image": "123456789.dkr.ecr.us-east-1.amazonaws.com/my-app:latest",
"portMappings": [{ "containerPort": 8080, "protocol": "tcp" }],
"environment": [
{ "name": "ENV", "value": "production" }
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/my-web-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}
]
}

ECR is AWS’s private Docker container registry — equivalent to Azure Container Registry (ACR):

Terminal window
# Authenticate Docker to ECR
aws ecr get-login-password --region us-east-1 | \
docker login --username AWS --password-stdin 123456789.dkr.ecr.us-east-1.amazonaws.com
# Create a repository
aws ecr create-repository --repository-name my-app
# Build and push
docker build -t my-app .
docker tag my-app:latest 123456789.dkr.ecr.us-east-1.amazonaws.com/my-app:latest
docker push 123456789.dkr.ecr.us-east-1.amazonaws.com/my-app:latest

A standard production deployment:

Internet → ALB (Application Load Balancer)
Target Group
ECS Fargate Service (desired count: 3)
├── Task 1 (container: my-app)
├── Task 2 (container: my-app)
└── Task 3 (container: my-app)

ECS handles:

  • Health checks and task replacement
  • Rolling deployments (or blue/green via CodeDeploy)
  • Auto-scaling based on CPU/memory/custom metrics
FactorECSEKS (Kubernetes)
SimplicitySimpler AWS-native APIMore complex but industry-standard
AWS integrationDeep (IAM, ALB, CloudWatch)Good (but requires more config)
PortabilityAWS-onlyKubernetes — portable across clouds
Learning curveLowerHigher
Community ecosystemAWS-specificMassive Kubernetes ecosystem

Rule of thumb: Use ECS (Fargate) if you want simplicity and stay AWS-native. Use EKS if you need Kubernetes compatibility, advanced scheduling, or portability.

Terminal window
# Register a task definition
aws ecs register-task-definition --cli-input-json file://task-def.json
# Create a cluster
aws ecs create-cluster --cluster-name my-cluster
# Run a one-off task
aws ecs run-task \
--cluster my-cluster \
--task-definition my-web-app \
--launch-type FARGATE \
--network-configuration "awsvpcConfiguration={subnets=[subnet-abc],securityGroups=[sg-abc],assignPublicIp=ENABLED}"
# List running tasks
aws ecs list-tasks --cluster my-cluster
# Describe a service
aws ecs describe-services \
--cluster my-cluster \
--services my-service