AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

Ec2TaskDefinition

The details of a task definition run on an EC2 cluster.

Import

import { Ec2TaskDefinition } from 'aws-cdk-lib/aws-ecs';

Or use the module namespace:

import * as ecs from 'aws-cdk-lib/aws-ecs';
// ecs.Ec2TaskDefinition

Properties

Configuration passed to the constructor as Ec2TaskDefinitionProps.

inferenceAcceleratorsOptional
InferenceAccelerator[]

The inference accelerators to use for the containers in the task. Not supported in Fargate.

Default: - No inference accelerators.

ipcModeOptional
IpcMode

The IPC resource namespace to use for the containers in the task. Not supported in Fargate and Windows containers.

Default: - IpcMode used by the task is not specified

networkModeOptional
NetworkMode

The Docker networking mode to use for the containers in the task. The valid values are NONE, BRIDGE, AWS_VPC, and HOST.

Default: - NetworkMode.BRIDGE for EC2 tasks, AWS_VPC for Fargate tasks.

pidModeOptional
PidMode

The process namespace to use for the containers in the task. Not supported in Windows containers.

Default: - PidMode used by the task is not specified

placementConstraintsOptional
PlacementConstraint[]

An array of placement constraint objects to use for the task. You can specify a maximum of 10 constraints per task (this limit includes constraints in the task definition and those specified at run time).

Default: - No placement constraints.

6 properties inherited from CommonTaskDefinitionProps
enableFaultInjectionOptionalinherited from CommonTaskDefinitionProps
boolean

Enables fault injection and allows for fault injection requests to be accepted from the task's containers. Fault injection only works with tasks using the {@link NetworkMode.AWS_VPC} or {@link NetworkMode.HOST} network modes.

Default: undefined - ECS default setting is false

executionRoleOptionalinherited from CommonTaskDefinitionProps
IRole

The name of the IAM task execution role that grants the ECS agent permission to call AWS APIs on your behalf. The role will be used to retrieve container images from ECR and create CloudWatch log groups.

Default: - An execution role will be automatically created if you use ECR images in your task definition.

familyOptionalinherited from CommonTaskDefinitionProps
string

The name of a family that this task definition is registered to. A family groups multiple versions of a task definition.

Default: - Automatically generated name.

proxyConfigurationOptionalinherited from CommonTaskDefinitionProps
ProxyConfiguration

The configuration details for the App Mesh proxy.

Default: - No proxy configuration.

taskRoleOptionalinherited from CommonTaskDefinitionProps
IRole

The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.

Default: - A task role is automatically created for you.

volumesOptionalinherited from CommonTaskDefinitionProps
Volume[]

The list of volume definitions for the task. For more information, see [Task Definition Parameter Volumes](https://docs.aws.amazon.com/AmazonECS/latest/developerguide//task_definition_parameters.html#volumes).

Default: - No volumes are passed to the Docker daemon on a container instance.

Get the Amazon ECS Cheat Sheet

Everything you need to know about Amazon ECS on one page. HD quality, print-friendly.

Download Free Infographic