Task Defnitions

  • In Json form to tell ECS how to run a docker container
    • Contains things like
      • Image name
      • Port binding
      • memory, CPU required
      • Environment variables
      • Network information
      • IAM role, ...
  • Can define up to 10 container in task definition
  • For EC2 launch type
    • We get a Dynamic Host Port mapping if you define only the container port in the task definition
      • But the ALB knows how to find the right port automatically
      • You must allow all ports to ALB then because we don't know in advnace which port it's gonna use
  • For Fargate launch type
    • Each task has an unique private IP
    • You only define the container port (host port is not applicatble)
  • 1 IAM role per task definition
  • Environments variable
    • Hardcoded
    • SSM Parameter store
    • Secrets Manager
  • Or load environment files (bulk) - from Amazon S3 bucket
  • Data volumes (bind mounts):
    • Share data between multiple containers
    • Work for both ECS and Fargate