A task definition is like a recipe that tells AWS ECS how to run a container. It includes details like which container image to use, how much CPU and memory to give, and what ports to open.
Click to reveal answer
beginner
Name three key parts of a task definition.
1. Container definitions (which containers to run) 2. CPU and memory settings 3. Networking and port mappings
Click to reveal answer
intermediate
Why do you need to register a new task definition revision in ECS?
Because each change to how your container runs (like updating the image or resources) needs a new version. ECS uses these versions to know which setup to use when starting tasks.
Click to reveal answer
beginner
How does a task definition relate to running tasks in ECS?
A task is an instance of a task definition. When you run a task, ECS uses the task definition to know what containers to start and how to configure them.
Click to reveal answer
intermediate
What happens if you update a task definition but don’t update your service to use the new revision?
Your service will keep running tasks with the old task definition version until you tell it to use the new one. So changes won’t take effect automatically.
Click to reveal answer
What does a task definition specify in AWS ECS?
AThe user permissions for AWS console
BHow to run containers including image, CPU, and ports
CThe billing details for ECS usage
DThe physical server where containers run
✗ Incorrect
A task definition tells ECS how to run containers, including which image to use, CPU, memory, and ports.
What must you do after changing a task definition to apply updates to a running ECS service?
AUpdate the service to use the new task definition revision
BDelete the old task definition
CRestart the AWS account
DNothing, changes apply automatically
✗ Incorrect
You must update the ECS service to use the new task definition revision for changes to take effect.
Which of these is NOT part of a task definition?
AAWS billing plan
BCPU and memory settings
CNetwork port mappings
DContainer image
✗ Incorrect
AWS billing plans are not part of task definitions.
What is a task in ECS?
AA billing invoice
BA user role in AWS
CA physical server
DA running instance of a task definition
✗ Incorrect
A task is a running instance of a task definition in ECS.
Why do task definitions have revisions?
ATo increase billing
BTo assign user permissions
CTo track changes and allow rollback
DTo change AWS regions
✗ Incorrect
Revisions track changes to task definitions and allow you to roll back if needed.
Explain what a task definition is and why it is important in AWS ECS.
Think about how you tell ECS what containers to run and how.
You got /4 concepts.
Describe the process and reason for updating a task definition revision in ECS.
Consider what happens when you want to change how your app runs.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of an AWS ECS task definition?
easy
A. To specify how to run a containerized application including resources and settings
B. To create a virtual machine in AWS
C. To store data in AWS S3
D. To manage user permissions in AWS IAM
Solution
Step 1: Understand what a task definition is
A task definition tells AWS ECS how to run your containerized app, including details like CPU, memory, and ports.
Step 2: Compare options to the definition
Only To specify how to run a containerized application including resources and settings correctly describes this purpose. Other options describe unrelated AWS services.
Final Answer:
To specify how to run a containerized application including resources and settings -> Option A
Quick Check:
Task definition = container run instructions [OK]
Hint: Task definitions describe container setup and resources [OK]
Common Mistakes:
Confusing task definitions with EC2 instances
Thinking task definitions manage storage or permissions
Mixing up ECS with other AWS services
2. Which of the following is the correct JSON snippet to define a container image in an ECS task definition?
easy
A. "docker_image": "myrepo/myapp:latest"
B. "image": "myrepo/myapp:latest"
C. "img": "myrepo/myapp:latest"
D. "container_image": "myrepo/myapp:latest"
Solution
Step 1: Recall ECS task definition JSON format
The correct key for specifying the container image is "image" inside the container definitions.
Step 2: Check each option's key
Only "image": "myrepo/myapp:latest" uses the correct key "image". Others use incorrect keys not recognized by ECS.
Final Answer:
"image": "myrepo/myapp:latest" -> Option B
Quick Check:
Container image key = "image" [OK]
Hint: Use "image" key exactly for container images in task definitions [OK]
Common Mistakes:
Using incorrect keys like "container_image" or "img"
Confusing task definition keys with Dockerfile syntax
Misspelling the key name
3. Given this partial ECS task definition snippet:
When you try to run this task, it fails with an error about missing port mappings. What is the likely fix?
medium
A. Add a portMappings section specifying containerPort and hostPort
B. Remove the cpu and memory fields
C. Change the image name to include a registry URL
D. Rename the container from 'app' to 'web'
Solution
Step 1: Understand the error about missing port mappings
If the app requires network access, port mappings must be defined to expose ports.
Step 2: Identify the fix
Adding a portMappings section with containerPort and hostPort will resolve the error by exposing the needed ports.
Final Answer:
Add a portMappings section specifying containerPort and hostPort -> Option A
Quick Check:
Missing ports error = add portMappings [OK]
Hint: Add portMappings to expose container ports when needed [OK]
Common Mistakes:
Removing CPU or memory which are unrelated to port errors
Changing image name unnecessarily
Renaming container without fixing ports
5. You want to update your ECS service to run a new version of your app with environment variables and increased memory. Which part of the task definition should you modify?
hard
A. Change the taskRoleArn to a new IAM role
B. Modify the family name of the task definition
C. Update the containerDefinitions section to include new environment variables and increase the memory value
D. Add a new volume definition without changing container settings
Solution
Step 1: Identify where environment variables and memory are set
Environment variables and memory limits are set inside the containerDefinitions section of the task definition.
Step 2: Understand the update process
To update the app version and resources, modify containerDefinitions with new environment variables and increased memory.
Final Answer:
Update the containerDefinitions section to include new environment variables and increase the memory value -> Option C
Quick Check:
Env vars and memory updated in containerDefinitions [OK]
Hint: Change containerDefinitions to update app settings and resources [OK]
Common Mistakes:
Changing taskRoleArn which controls permissions, not env or memory
Modifying family name which identifies task definition versions
Adding volumes without updating container environment or memory
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.