aws ecs register-task-definition
Registers a new task definition from the supplied family and containerDefinitions. AWS CLI reference
2 examples 19 options Its page in the AWS CLI reference
Examples
Example 1: To register a task definition with a JSON file
The following register-task-definition example registers a task definition to the specified family. The container definitions are saved in JSON format at the specified file location.
aws ecs register-task-definition --cli-input-json file://<path_to_json_file>/sleep360.jsonIdentifyContents of sleep360.json:
{
"containerDefinitions": [
{
"name": "sleep",
"image": "busybox",
"cpu": 10,
"command": [
"sleep",
"360"
],
"memory": 10,
"essential": true
}
],
"family": "sleep360"
}
Its output, shortened
{
"taskDefinition": {
"status": "ACTIVE",
"family": "sleep360",
"placementConstraints": [],
"compatibilities": [
"EXTERNAL",
"EC2"
],
"volumes": [],
"taskDefinitionArn": "arn:aws:ecs:us-west-2:123456789012:task-definition/sleep360:1",
"containerDefinitions": [
{
"environment": [],
"name": "sleep",
"mountPoints": [],
"image": "busybox",
"cpu": 10,
"portMappings": [],
"command": [
"sleep",
"360"
],
"memory": 10,
"essential": true,
"volumesFrom": []
}
],
"revision": 1
}
… 1 more lineFor more information, see Example Amazon ECS task definitions in the Amazon ECS Developer Guide.
Example 2: To register a task definition with a JSON string parameter
The following register-task-definition example registers a task definition using container definitions provided as a JSON string parameter with escaped double quotes.
aws ecs register-task-definition --family sleep360 --container-definitions "[{\"name\":\"sleep\",\"image\":\"busybox\",\"cpu\":10,\"command\":[\"sleep\",\"360\"],\"memory\":10,\"essential\":true}]"Identify--familyYou must specify a family for a task definition.--container-definitionsA list of container definitions in JSON format that describe the different containers that make up your task.Its output, shortened
{
"taskDefinition": {
"status": "ACTIVE",
"family": "sleep360",
"placementConstraints": [],
"compatibilities": [
"EXTERNAL",
"EC2"
],
"volumes": [],
"taskDefinitionArn": "arn:aws:ecs:us-west-2:123456789012:task-definition/sleep360:1",
"containerDefinitions": [
{
"environment": [],
"name": "sleep",
"mountPoints": [],
"image": "busybox",
"cpu": 10,
"portMappings": [],
"command": [
"sleep",
"360"
],
"memory": 10,
"essential": true,
"volumesFrom": []
}
],
"revision": 1
}
… 1 more lineFor more information, see Creating an Amazon ECS task definition using the console in the Amazon ECS Developer Guide.
Options
--container-definitionsA list of container definitions in JSON format that describe the different containers that make up your task.--cpuThe number of CPU units used by the task.--enable-fault-injectionEnables fault injection when you register your task definition and allows for fault injection requests to be accepted from the task's containers.--ephemeral-storageThe amount of ephemeral storage to allocate for the task.--execution-role-arnThe Amazon Resource Name (ARN) of the task execution role that grants the Amazon ECS container agent permission to make Amazon Web Services API calls on your behalf.--familyYou must specify a family for a task definition.--inference-acceleratorsThe Elastic Inference accelerators to use for the containers in the task.--ipc-modeThe IPC resource namespace to use for the containers in the task.--memoryThe amount of memory (in MiB) used by the task.--network-modeThe Docker networking mode to use for the containers in the task.--pid-modeThe process namespace to use for the containers in the task.--placement-constraintsAn array of placement constraint objects to use for the task.--proxy-configurationThe configuration details for the App Mesh proxy.--requires-compatibilitiesThe task launch type that Amazon ECS validates the task definition against.--runtime-platformThe operating system that your tasks definitions run on.--tagsThe metadata that you apply to the task definition to help you categorize and organize them.--task-role-arnThe short name or full Amazon Resource Name (ARN) of the IAM role that containers in this task can assume.--trusted-execution-configurationThe trusted execution configuration for tasks that use this task definition, including the isolation mode and, if configured, an attestation policy.--volumesA list of volume definitions in JSON format that containers in your task might use.