An ECS task definition is the configuration ECS uses to run a task. It specifies one or more containers, including their image URLs, CPU and memory settings, environment variables, and network configuration. Containers in the same task run on the same host, allowing them to share local resources such as networking. section 18.3
A task definition commonly describes:
- CPU and memory baselines and limits for the containers. section 18.3
- Environment variables and network settings required by the application. section 18.3
- IAM roles that separate execution permissions, such as downloading images and publishing logs, from application permissions, such as accessing S3. section 18.5
Web application on Fargate
A CloudFormation task definition can run an app image on port 3000, send logs through the AWS logs driver, and provide password, region, and bucket values as environment variables. Its task role can grant the container permission to list, read, write, and delete objects in an S3 bucket. An ECS service then launches tasks from the definition and registers them with a load balancer.
