0
0
AWScloud~10 mins

Task definitions in AWS - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Task definitions
Write Task Definition JSON
Register Task Definition in ECS
ECS stores Task Definition
Use Task Definition to Run Tasks or Services
ECS launches containers as defined
Tasks run with specified settings
Monitor & Update
You create a task definition JSON, register it with ECS, then ECS uses it to run containers with the settings you defined.
Execution Sample
AWS
{
  "family": "my-task",
  "containerDefinitions": [
    {
      "name": "app",
      "image": "nginx",
      "memory": 128
    }
  ]
}
Defines a task with one container named 'app' using the nginx image and 128 MB memory.
Process Table
StepActionInput/StateResult/Output
1Write task definition JSONDefine family 'my-task', container 'app', image 'nginx', memory 128JSON ready to register
2Register task definitionSend JSON to ECSECS stores task definition with revision 1
3Run task using definitionRequest ECS to run 'my-task:1'ECS launches container 'app' with nginx image
4Container startsContainer runs with 128 MB memoryApp container running
5Update task definitionChange memory to 256New revision 2 registered
6Run new taskRequest ECS to run 'my-task:2'ECS launches container with updated memory
7Stop tasksRequest ECS to stop running tasksContainers stopped
8ExitNo more tasks to runExecution ends
💡 No more tasks requested, ECS stops containers and ends execution
Status Tracker
VariableStartAfter Step 2After Step 5Final
Task Definition RevisionNone122
Container Memory (MB)128 (initial JSON)128256 (updated)256
Task Running StateNoYes (step 3)Yes (step 6)No (step 7)
Key Moments - 3 Insights
Why do we need to register a task definition before running tasks?
Because ECS needs a stored definition to know what containers to launch and how. See execution_table step 2 where registration stores the definition.
What happens if you update the task definition JSON but don't register it?
ECS will still use the old registered version. Only registered revisions are used to run tasks, as shown in steps 5 and 6.
Can you run tasks with different settings without changing the original task definition?
No, you must register a new revision with updated settings. ECS runs tasks only from registered revisions (step 5 and 6).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the task definition revision after step 2?
ARevision 0
BRevision 1
CRevision 2
DNo revision yet
💡 Hint
Check the 'Result/Output' column at step 2 in execution_table
At which step does ECS launch the container with updated memory?
AStep 6
BStep 5
CStep 3
DStep 7
💡 Hint
Look for when the task definition revision changes and a new task runs in execution_table
If you stop tasks at step 7, what is the running state after that?
AYes, tasks still running
BUnknown
CNo, tasks stopped
DTasks paused
💡 Hint
Check 'Task Running State' in variable_tracker after step 7
Concept Snapshot
Task definitions are JSON files describing containers to run.
You register them with ECS to create revisions.
ECS uses these revisions to launch containers.
Update by registering new revisions.
Run tasks by specifying revision.
Stop tasks to end containers.
Full Transcript
Task definitions in AWS ECS are JSON documents that describe how to run one or more containers. You write the JSON with container details like image and memory. Then you register this JSON with ECS, which stores it as a revision. When you want to run containers, you tell ECS which task definition revision to use. ECS launches containers based on that definition. If you want to change settings, you update the JSON and register a new revision. Running tasks always use a registered revision. You can stop running tasks to end containers. This flow ensures ECS knows exactly what to run and how.