Sub topic 3
What Fargate manages and what you still own
This chapter assumes you know how to build and run a Docker image. It also assumes you know basic IAM, VPC, subnets, and security groups. You should have seen the ECS terms cluster, task, and service in the previous chapter.
The serverless compute model
Fargate is the compute engine that runs ECS tasks without servers you manage. You don't create EC2 instances, patch an operating system, or join machines to a cluster. You describe a task with a CPU and memory size, and ECS asks Fargate to find capacity for it.
Each Fargate task runs in its own isolated environment. It has its own kernel, CPU, memory, and network interface. Tasks do not share a host with other customers' tasks, and they do not share one with your other tasks.
The responsibility split
AWS runs the infrastructure under your containers. You still own everything from the container image upward.
| Area | AWS manages | You own |
|---|---|---|
| Hosts | Provisioning, patching, and scaling the underlying compute | Nothing at the host level |
| Operating system | Host OS and kernel | Packages and libraries inside your image |
| Container runtime | Runtime and ECS agent | Image contents and the process it starts |
| Capacity | Finding room for each task | Task size and the number of tasks |
| Networking | The task's network interface (ENI) | Subnets, security groups, and load balancer settings |
| Security | Isolation between tasks | IAM roles, secrets, and image vulnerabilities |
| Operations | Task placement | Logging, health checks, deployments, and scaling rules |
A common mistake is to assume "serverless" means "no security work." Fargate patches the host. It does not patch the base image you chose, so a vulnerable library in your image stays vulnerable until you rebuild and redeploy.
How a request becomes a running task
Two consequences follow from this flow:
- The task gets an elastic network interface (ENI) in your subnet. Your VPC settings decide whether it can reach ECR, CloudWatch Logs, and the internet.
- The image pull happens on every task start. There is no warm host cache between tasks, so large images start more slowly.
Constraints that come with the model
- Fargate requires the
awsvpcnetwork mode. Each task gets its own ENI and private IP address. - CPU and memory are set for the whole task, and only certain combinations are valid. The next chapters cover this.
- You can't SSH into a host, because there is no host you can reach. ECS Exec is how you get a shell in a running container.
- Privileged containers and access to host devices are not available.
- Storage is ephemeral by default. Data written inside the task is lost when the task stops.
Checking what Fargate is running
You can read a task's platform details with the CLI:
aws ecs describe-tasks \
--cluster demo \
--tasks <task-id> \
--query "tasks[0].{launchType:launchType,platform:platformVersion,cpu:cpu,memory:memory}"The output shows the launch type, the platform version, and the task-level CPU and memory. Replace <task-id> with a task ID from aws ecs list-tasks.
Exercise
Your security scanner reports a vulnerable OpenSSL library in a container running on Fargate. Who is responsible for fixing it, and what do you do?
Show answer
You are. Fargate patches the host, not the contents of your image. Update the base image or package, rebuild, push the new image to ECR, and deploy a new task definition revision so that new tasks replace the old ones.
Exercise
Why can't you SSH into the machine running your Fargate task, and what do you use instead?
Show answer
There is no host you can reach. AWS manages the underlying compute. Use ECS Exec to open a shell in a running container, and use CloudWatch Logs to read its output.