AWS ECS Task Definition template
This post is to briefly describe the task definition template parameters of ECS
you can use below command in aws cli to generate the template
aws ecs register-task-definition —generate-cli-skeleton |
Below are the detailed descriptions for each task definition parameter.
Family
When you register a task definition, you give it a family, which is similar to a name for multiple versions of the task definition, specified with a revision number. The first task definition that’s registered into a particular family is given a revision of 1, and any task definitions registered after that are given a sequential revision number.
taskRoleArn
(Required: no) to describe the arn of the iam role that allows the containers in task to the aws api’s in its associated policies on your behalf
This becomes a required field when you use windows server AMI
When you launch the Amazon ECS-optimized Windows Server AMI, IAM roles for tasks on Windows require that the -EnableTaskIAMRole option is set. Your containers must also run some configuration code to use the feature
executionRoleArn
The Amazon Resource Name (ARN) of the task execution role that grants the Amazon ECS container agent permission to make AWS API calls on your behalf.
networkMode
The Docker networking mode to use for the containers in the task. For Amazon ECS tasks that are hosted on Amazon EC2 Linux instances, the valid values are none, bridge, awsvpc, and host. If no network mode is specified, the default network mode is bridge. For Amazon ECS tasks hosted on Amazon EC2 Windows instances, the valid values are default, and awsvpc. If no network mode is specified, the default network mode is used.
containerDefinitions
When you register a task definition, you must specify a list of container definitions that are passed to the Docker daemon on a container instance.
Has definitions relating to name, memory, size, port mapping etc.
Task definition parameters
Task definitions are split into separate parts: the task family, the IAM task role, the network mode, container… docs.aws.amazon.com
volumes
When you register a task definition, you can optionally specify a list of volumes to be passed to the Docker daemon on a container instance, which then becomes available for access by other containers on the same container instance.
placementConstraints
When you register a task definition, you can provide task placement constraints that customize how Amazon ECS places tasks.
If you’re using the Fargate launch type, task placement constraints aren’t supported. By default Fargate tasks are spread across Availability Zones.
requiresCompatibilities
This is to describe the launch type of the ecs task is itEC2 | FARGATE | EXTERNAL
Cpu & memory:
“cpu”: “”, “memory”: “”,
When registering a task definition, you can specify the amount of CPU and memory required for the task as a whole, separate from the values for each individual container. These fields are optional for tasks run on Amazon EC2, but mandatory for tasks run on Fargate, with specific value ranges for both CPU and memory.
pidMode
“pidMode”: “task”, When creating a task, you can specify the process namespace to be used for its containers. The options are “host” or “task”. If “host” is selected, all containers within the task will share the same process namespace as the host Amazon EC2 instance. If “task” is chosen, all containers within the task will share the same process namespace. If no value is specified, a private namespace is used by default.
ipcMode
“ipcMode”: “task”, When creating a task, you can specify the IPC resource namespace to be used for its containers. The options are “host”, “task” or “none”. If “host” is selected, all containers within the task will share the same IPC resources as the host Amazon EC2 instance. If “task” is chosen, all containers within the task will share the same IPC resources. If “none” is chosen the IPC resources within the containers of a task will be private and not shared with other containers in a task or on the container instance. If no value is specified, the default is “shareable”. This setting determines how processes within the container communicate with each other using Inter-Process Communication (IPC) mechanisms. For more information, refer to the Docker documentation on IPC settings.
Tags
“tags”: [{ “key”: “”, “value”: “” } When creating a task definition, you can add metadata tags to help you organize and categorize the task definition. Each tag is made up of a key and an optional value. You can define both the key and value for the tag.