AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

EcsEc2ContainerDefinition

A container orchestrated by ECS that uses EC2 resources.

Import

import { EcsEc2ContainerDefinition } from 'aws-cdk-lib/aws-batch';

Or use the module namespace:

import * as batch from 'aws-cdk-lib/aws-batch';
// batch.EcsEc2ContainerDefinition

Properties

Configuration passed to the constructor as EcsEc2ContainerDefinitionProps.

gpuOptional
number

The number of physical GPUs to reserve for the container. Make sure that the number of GPUs reserved for all containers in a job doesn't exceed the number of available GPUs on the compute resource that the job is launched on.

Default: - no gpus

privilegedOptional
boolean

When this parameter is true, the container is given elevated permissions on the host container instance (similar to the root user).

Default: false

ulimitsOptional
Ulimit[]

Limits to set for the user this docker container will run as.

Default: - no ulimits

14 properties inherited from EcsContainerDefinitionProps
cpuRequiredinherited from EcsContainerDefinitionProps
number

The number of vCPUs reserved for the container. Each vCPU is equivalent to 1,024 CPU shares. For containers running on EC2 resources, you must specify at least one vCPU.

imageRequiredinherited from EcsContainerDefinitionProps
ContainerImage

The image that this container will run.

memoryRequiredinherited from EcsContainerDefinitionProps
Size

The memory hard limit present to the container. If your container attempts to exceed the memory specified, the container is terminated. You must specify at least 4 MiB of memory for a job.

commandOptionalinherited from EcsContainerDefinitionProps
string[]

The command that's passed to the container.

Default: - no command

enableExecuteCommandOptionalinherited from EcsContainerDefinitionProps
boolean

Determines whether execute command functionality is turned on for this task. If true, execute command functionality is turned on all the containers in the task. This allows you to use ECS Exec to access containers interactively. When enabled, a job role with required SSM permissions will be created automatically if no job role is provided. If a job role is alreadyprovided, the required permissions will be added to it.

Default: undefined - AWS Batch default is false

environmentOptionalinherited from EcsContainerDefinitionProps
{ [key: string]: string }

The environment variables to pass to a container. Cannot start with `AWS_BATCH`. We don't recommend using plaintext environment variables for sensitive information, such as credential data.

Default: - no environment variables

executionRoleOptionalinherited from EcsContainerDefinitionProps
IRole

The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.

Default: - a Role will be created

jobRoleOptionalinherited from EcsContainerDefinitionProps
IRole

The role that the container can assume.

Default: - no job role

linuxParametersOptionalinherited from EcsContainerDefinitionProps
LinuxParameters

Linux-specific modifications that are applied to the container, such as details for device mappings.

Default: none

loggingOptionalinherited from EcsContainerDefinitionProps
LogDriver

The loging configuration for this Job.

Default: - the log configuration of the Docker daemon

readonlyRootFilesystemOptionalinherited from EcsContainerDefinitionProps
boolean

Gives the container readonly access to its root filesystem.

Default: false

secretsOptionalinherited from EcsContainerDefinitionProps
{ [key: string]: Secret }

A map from environment variable names to the secrets for the container. Allows your job definitions to reference the secret by the environment variable name defined in this property.

Default: - no secrets

userOptionalinherited from EcsContainerDefinitionProps
string

The user name to use inside the container.

Default: - no user

volumesOptionalinherited from EcsContainerDefinitionProps
EcsVolume[]

The volumes to mount to this container. Automatically added to the job definition.

Default: - no volumes

Learn AWS the Practical Way

Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.

Subscribe to Newsletter