Lesson 20 of 30Modern AWS
Choosing Container Compute: ECS, Fargate, EKS and Lambda
Go past ECS basics to capacity providers, Service Connect, blue/green and Express Mode, weigh EKS honestly, and pick a platform you can defend.
A new engineering manager joins and asks in their first week: "Why aren't we on Kubernetes? Everyone is on Kubernetes." The team runs twelve services on ECS with Fargate and nobody has been paged for the platform in a year. The question deserves a real answer, not a shrug or a migration. To give one, you need to know what each option makes you own, where each one is weak, and how the trade-offs change at 2 services, 20 and 200.
Containers on AWS covered ECR, task definitions, services, Fargate sizing and the standard ALB architecture. This lesson goes deeper into ECS, then puts EKS and Lambda next to it.
What you actually choose: who operates which layer
Every container platform has the same layers. The options differ in how many of them land on your team.
ECS on Fargate or ECS Express Mode: you own only the top two layers. There is no cluster software to upgrade and no machine to patch.
Keep this picture in mind. Most "ECS vs EKS" debates are really "how many of these layers do we want to staff?"
ECS in more depth
The two roles, one level down
You know the rule: the execution role is for ECS to start the task (pull the image, fetch secrets, create log streams), and the task role is for your code. What seniors also know is how the task role reaches your code. ECS sets AWS_CONTAINER_CREDENTIALS_RELATIVE_URI in the container, and every AWS SDK's default credential chain calls a local endpoint (169.254.170.2) to get short-lived credentials for the task role. Nothing is baked into the image, and credentials rotate on their own.
The classic bug on the EC2 launch type: you forget the task role, and the SDK walks further down the credential chain to the instance profile of the host. The code works, but with the permissions of the whole node, which every task on it shares. Block containers from the instance metadata service on EC2 hosts so a missing task role fails loudly instead. Fargate has no instance profile, so this cannot happen there.
ecsInstanceRole. What is wrong?Capacity providers
A capacity provider tells ECS where tasks run. A service uses a capacity provider strategy: a list of providers with a base (minimum tasks placed on that provider first) and a weight (how to split the rest).
FARGATE: serverless, per-task sizing.FARGATE_SPOT: spare capacity at a steep discount, which AWS can reclaim with a two-minute warning. Your container getsSIGTERM, so it must drain within its stop timeout. Good for queue workers and batch, risky alone for an API.- EC2 Auto Scaling group providers: ECS managed scaling grows and shrinks the group based on what tasks need, and managed termination protection stops it from killing an instance that still runs tasks.
- ECS Managed Instances (launched in late 2025): ECS chooses, launches, patches and replaces EC2 instances in your account for you. You get EC2 features such as GPUs and specific instance families without running the fleet, for a management charge on top of EC2.
A common production strategy for an API: base: 2 on FARGATE so the minimum is always on stable capacity, then weight 1 on FARGATE and weight 3 on FARGATE_SPOT for everything above it.
Service Connect
Services need to call each other. You can put an internal ALB in front of every service, but that adds cost and a hop per service. Service Connect gives each service a short name in a namespace (for example http://orders:8080) and runs a managed proxy next to each task. You get client-side load balancing, retries, outlier detection, and per-service request metrics in CloudWatch without changing code. It is ECS's answer to a service mesh, at much lower complexity. VPC Lattice is the alternative when callers span accounts or mix ECS, EKS and Lambda.
Safer deployments
Rolling updates with the deployment circuit breaker (rollback when new tasks keep failing to start or to pass health checks) are the baseline. Two additions matter:
- CloudWatch alarms on the deployment: tie the deployment to an alarm on error rate or latency, so a release that starts fine but misbehaves under real traffic rolls back automatically.
- Native blue/green (added in 2025): ECS itself runs the new revision ("green") beside the old ("blue"), can send test traffic to green first, shifts production traffic, then keeps blue alive for a bake time so rollback is instant. Lifecycle hooks (Lambda functions or pauses) let you run smoke tests at each stage. Before this, blue/green on ECS required CodeDeploy; for new services, the native version is simpler.
Blue/green temporarily runs both revisions, so it can double your task count during a deploy. Budget for that.
ECS Express Mode, and the end of App Runner for new users
App Runner used to be the "give AWS an image, get an HTTPS URL" option. AWS closed it to new customers on 30 April 2026. Existing customers keep using it, but it gets no new features, and AWS points everyone to ECS Express Mode instead.
Express Mode (announced at re:Invent 2025) creates a production-shaped ECS stack from three inputs: an image, a task execution role and an infrastructure role. In one call it provisions a Fargate service, an ALB with HTTPS and health checks, auto scaling, security groups, logging and a URL. Everything is created in your account as ordinary resources, so you can tune them later with the full ECS feature set, and Express services with the same network setup share an ALB. There is no extra charge beyond the resources it creates.
aws ecs create-express-gateway-service \ --service-name orders-api \ --execution-role-arn arn:aws:iam::123456789012:role/ecsTaskExecutionRole \ --infrastructure-role-arn arn:aws:iam::123456789012:role/ecsInfrastructureRoleForExpressServices \ --primary-container file://container.json \ --health-check-path /health \ --scaling-target file://scaling.jsonHere container.json holds the image and port ({"image": ".../orders-api:4f2c1e9", "containerPort": 8000}) and scaling.json holds {"minTaskCount": 2, "maxTaskCount": 10}. The service is ready in a few minutes. For CI, AWS publishes a GitHub Action that deploys to an Express service. Express Mode is new, so check the ECS docs for the current flags before you script it.
When to use it: a team's first container service, internal tools, prototypes that may grow up, and anyone migrating off App Runner. When to step past it: you need custom networking, several containers per task, or a deployment strategy it does not configure. At that point you manage the created resources directly, or move the service into your infrastructure-as-code.
EKS: what you take on
Amazon EKS runs the Kubernetes control plane for you across multiple AZs. You pay an hourly fee per cluster for it, on top of compute. Everything above the control plane is a set of decisions:
Nodes.
- Managed node groups: EC2 Auto Scaling groups that EKS can update in a rolling way. You choose instance types per group.
- Karpenter: an open-source autoscaler that watches pending pods and launches right-sized instances directly, mixes Spot and On-Demand, and consolidates by replacing under-used nodes. It usually beats node groups on utilization at scale.
- EKS Auto Mode: AWS runs Karpenter-style node management, the core networking, DNS, storage and load-balancer components, and node OS patching. It removes most of the node work for an extra management charge per instance.
- Fargate profiles: each pod gets its own isolated micro-VM. No nodes, but no DaemonSets, no GPUs, and some features do not work there.
Pod permissions.
- IRSA (IAM roles for service accounts) uses an OIDC provider per cluster, and each role's trust policy must name that cluster's provider. It works everywhere, including Fargate.
- EKS Pod Identity is the newer, simpler option: a node agent hands out credentials, the role trusts one service principal (
pods.eks.amazonaws.com), and you map roles to service accounts with an EKS API call. The same role works in many clusters without editing its trust policy. It does not work for pods on Fargate, which still need IRSA.
Add-ons. A working cluster needs the VPC CNI (pods get real VPC IPs, so plan subnet sizes or enable prefix delegation), CoreDNS and kube-proxy, plus usually the AWS Load Balancer Controller, ExternalDNS, cert-manager, a metrics stack and a policy engine. Each one has versions that must match your Kubernetes version.
Upgrades never stop. Kubernetes ships a minor version roughly every four months. On EKS each version gets 14 months of standard support, then 12 months of extended support at an extra per-cluster hourly charge. At the end of extended support, EKS upgrades the control plane for you, but not your nodes or add-ons, and not on a date you choose. To stay in standard support, a team upgrades about once or twice a year, per cluster.
Aug 2025
Upstream release
Kubernetes 1.34 ships upstream. EKS qualifies it before offering it.
Oct 2025
Available on EKS
Standard support starts: 14 months of patches at the normal control plane rate.
Dec 2026
End of standard support
The cluster moves to extended support automatically and the per-cluster hourly charge goes up.
Dec 2027
End of extended support
EKS auto-upgrades the control plane at a time it picks. Nodes and add-ons stay old until you act.
Order a safe EKS minor version upgrade.
- Tap the steps below in the right order.
Lambda as a container platform
Lambda accepts container images up to 10 GB, so "we ship containers" does not rule it out. It suits request-driven or event-driven work that finishes within 15 minutes and is idle much of the time, because it scales to zero. It suits poorly anything long-running, connection-heavy (WebSockets held open, large connection pools) or steady and busy, where per-request billing adds up.
Lambda Managed Instances (launched in late 2025) narrows that last gap: functions run on EC2 instances that Lambda manages in your account, each execution environment handles many concurrent requests, and you can choose instance types. It is aimed at steady, high-volume functions where EC2 pricing models beat per-invocation compute. You keep the Lambda programming model and give up scale-to-zero on that capacity.
Cost at three scales, without guessing prices
Prices change; the shape of the cost does not. Look at three scales.
- 2 to 3 services. The EKS control plane fee is a fixed cost that can rival the compute of a few small tasks, and someone has to learn and run Kubernetes. Fargate or Express Mode wins clearly.
- About 20 services. Compute dominates the bill and the control plane fee becomes noise. The real cost is people: a Kubernetes platform needs real engineering time for upgrades, add-ons and on-call. ECS still costs less to operate unless you already have that expertise.
- About 200 services. Utilization dominates. Fargate charges for the size you reserve, rounded up to a valid CPU and memory combination. EC2-based options (ECS on EC2, ECS Managed Instances, EKS with Karpenter) let you bin-pack many tasks onto large instances, use Spot widely and pick Graviton. Savings Plans apply to Fargate and Lambda as well as EC2, so commitments help either way.
This simulation shows the utilization effect. It sizes each task for Fargate and also packs the same tasks onto 4 vCPU, 16 GB nodes.
Press Run (⌘ Enter) to see what happens.Read the output carefully. At 3 tasks, one EC2 node is mostly empty, so Fargate's per-task sizing wastes less. At 200, packing gets close to what the tasks need, while Fargate rounds the 1.2 vCPU worker up to 2 vCPU every time. The cheapest fix is often not a platform migration: change the worker to request exactly 1 vCPU and Fargate's waste shrinks. A vCPU-hour does not cost the same on Fargate and EC2, so plug in current prices from the pricing pages before drawing a conclusion.
What does this print?
FARGATE = [(0.25, [0.5, 1, 2]), (0.5, range(1, 5)), (1, range(2, 9)),
(2, range(4, 17)), (4, range(8, 31))]
def fargate_size(cpu, mem):
for vcpu, mems in FARGATE:
if vcpu >= cpu:
for m in mems:
if m >= mem:
return vcpu, m
print(fargate_size(1.2, 2.5))The decision
| ECS on Fargate / Express | ECS on EC2 or Managed Instances | EKS (Auto Mode or Karpenter) | Lambda | |
|---|---|---|---|---|
| Team skill needed | ECS concepts | Plus EC2 fleet basics | Kubernetes, deeply | Lambda model |
| Ops burden | Lowest | Low to medium | Highest | Lowest |
| Portability | AWS only | AWS only | Any Kubernetes | AWS only |
| Ecosystem | AWS integrations | AWS integrations | Helm, operators, CNCF tools | AWS integrations |
| Utilization at scale | Rounded per task | Bin-packing | Bin-packing, consolidation | Per request, or Managed Instances |
| Fits best | Most services on AWS | GPUs, large steady fleets | Teams that already run Kubernetes | Spiky, event-driven, short work |
Reasons that genuinely justify EKS: the company already runs Kubernetes elsewhere and wants one platform and one skill set; you depend on Kubernetes-native tools (operators for databases or Kafka, Argo CD, service meshes, Kubeflow-style ML tooling); you need real multi-cloud or on-premises portability; or a platform team exists to run it and offers it as an internal product. Reasons that do not: "it's the industry standard", résumé building, or portability nobody has a plan to use.
Most teams on AWS without a Kubernetes need are happier on ECS. That is not a knock on Kubernetes. It is a statement about which layers you want to staff.
Match each situation to the best-fitting compute choice.
- capacity provider strategy
- The list of capacity providers an ECS service uses, with a base count and weights that decide where tasks are placed.
- Fargate Spot
- Interruptible Fargate capacity at a large discount, reclaimed with a two-minute warning and SIGTERM.
- ECS Managed Instances
- An ECS capacity option where AWS provisions, patches and replaces the EC2 instances that run your tasks.
- Service Connect
- ECS service-to-service networking with short names, a managed proxy, retries and per-service metrics.
- ECS Express Mode
- Creates a full ECS Fargate service with ALB, HTTPS, scaling and networking from an image and two roles; AWS's replacement path for App Runner.
- EKS Pod Identity
- Maps IAM roles to Kubernetes service accounts through an EKS API and node agent, without a per-cluster OIDC provider. Not for Fargate pods.
- Karpenter
- Open-source Kubernetes node autoscaler that launches right-sized instances for pending pods and consolidates under-used nodes.