ECS (Elastic Container Service) is AWS's service for running Docker containers in the cloud.
Running a Docker container on AWS = running an ECS Task inside an ECS Cluster.
ECS gives you two ways to run containers:

You provision and maintain EC2 instances. ECS places and runs containers on those instances.
Use when: You need full control over your servers or specific hardware.

No EC2 instances to provision or manage. AWS handles all infrastructure.
You define a task (CPU + RAM needed)
|
v
AWS automatically finds resources and runs your container
|
v
To scale: just increase number of tasks
Use when: You want zero infrastructure management. Preferred for most use cases.
| EC2 Launch Type | Fargate | |
|---|---|---|
| Infrastructure | You manage EC2 instances | AWS manages everything |
| Serverless | No | Yes |
| Scaling | Add EC2 instances | Increase number of tasks |
| Control | Full server access | No server access |
| Best for | Specific hardware needs | Simplicity, no management |

This role is attached to the EC2 instance itself. It is used by the ECS Agent to interact with AWS services.
EC2 Instance Profile --> used by ECS Agent to talk to:
- ECS (register instance, report task status)
- ECR (pull Docker images)
- CloudWatch Logs (send container logs)
- Secrets Manager / SSM Parameter Store (optional, for secrets)
This role is only for the ECS Agent (infrastructure level). It has nothing to do with what the containers themselves can access.
Each individual task (container) gets its own role with its own permissions.