interface Ec2TaskDefinitionProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ECS.Ec2TaskDefinitionProps |
Java | software.amazon.awscdk.services.ecs.Ec2TaskDefinitionProps |
Python | aws_cdk.aws_ecs.Ec2TaskDefinitionProps |
TypeScript (source) | @aws-cdk/aws-ecs » Ec2TaskDefinitionProps |
The properties for a task definition run on an EC2 cluster.
Example
const ec2TaskDefinition = new ecs.Ec2TaskDefinition(this, 'TaskDef', {
networkMode: ecs.NetworkMode.BRIDGE,
});
const container = ec2TaskDefinition.addContainer("WebContainer", {
// Use an image from DockerHub
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
memoryLimitMiB: 1024,
// ... other options here ...
});
Properties
Name | Type | Description |
---|---|---|
execution | IRole | The name of the IAM task execution role that grants the ECS agent permission to call AWS APIs on your behalf. |
family? | string | The name of a family that this task definition is registered to. |
inference | Inference [] | The inference accelerators to use for the containers in the task. |
ipc | Ipc | The IPC resource namespace to use for the containers in the task. |
network | Network | The Docker networking mode to use for the containers in the task. |
pid | Pid | The process namespace to use for the containers in the task. |
placement | Placement [] | An array of placement constraint objects to use for the task. |
proxy | Proxy | The configuration details for the App Mesh proxy. |
task | IRole | The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf. |
volumes? | Volume [] | The list of volume definitions for the task. |
executionRole?
Type:
IRole
(optional, default: An execution role will be automatically created if you use ECR images in your task definition.)
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.
family?
Type:
string
(optional, default: Automatically generated name.)
The name of a family that this task definition is registered to.
A family groups multiple versions of a task definition.
inferenceAccelerators?
Type:
Inference
[]
(optional, default: No inference accelerators.)
The inference accelerators to use for the containers in the task.
Not supported in Fargate.
ipcMode?
Type:
Ipc
(optional, default: IpcMode used by the task is not specified)
The IPC resource namespace to use for the containers in the task.
Not supported in Fargate and Windows containers.
networkMode?
Type:
Network
(optional, default: NetworkMode.BRIDGE for EC2 tasks, AWS_VPC for Fargate tasks.)
The Docker networking mode to use for the containers in the task.
The valid values are NONE, BRIDGE, AWS_VPC, and HOST.
pidMode?
Type:
Pid
(optional, default: PidMode used by the task is not specified)
The process namespace to use for the containers in the task.
Not supported in Fargate and Windows containers.
placementConstraints?
Type:
Placement
[]
(optional, default: No placement constraints.)
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).
proxyConfiguration?
Type:
Proxy
(optional, default: No proxy configuration.)
The configuration details for the App Mesh proxy.
taskRole?
Type:
IRole
(optional, default: A task role is automatically created for you.)
The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.
volumes?
Type:
Volume
[]
(optional, default: No volumes are passed to the Docker daemon on a container instance.)
The list of volume definitions for the task.
For more information, see Task Definition Parameter Volumes.