interface EcsEc2ContainerDefinitionProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Batch.EcsEc2ContainerDefinitionProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsbatch#EcsEc2ContainerDefinitionProps |
Java | software.amazon.awscdk.services.batch.EcsEc2ContainerDefinitionProps |
Python | aws_cdk.aws_batch.EcsEc2ContainerDefinitionProps |
TypeScript (source) | aws-cdk-lib » aws_batch » EcsEc2ContainerDefinitionProps |
Props to configure an EcsEc2ContainerDefinition.
Example
declare const vpc: ec2.IVpc;
const ecsJob = new batch.EcsJobDefinition(this, 'JobDefn', {
container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
memory: cdk.Size.mebibytes(2048),
cpu: 256,
}),
});
const queue = new batch.JobQueue(this, 'JobQueue', {
computeEnvironments: [{
computeEnvironment: new batch.ManagedEc2EcsComputeEnvironment(this, 'managedEc2CE', {
vpc,
}),
order: 1,
}],
priority: 10,
});
const user = new iam.User(this, 'MyUser');
ecsJob.grantSubmitJob(user, queue);
Properties
Name | Type | Description |
---|---|---|
cpu | number | The number of vCPUs reserved for the container. |
image | Container | The image that this container will run. |
memory | Size | The memory hard limit present to the container. |
command? | string[] | The command that's passed to the container. |
environment? | { [string]: string } | The environment variables to pass to a container. |
execution | IRole | The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf. |
gpu? | number | The number of physical GPUs to reserve for the container. |
job | IRole | The role that the container can assume. |
linux | Linux | Linux-specific modifications that are applied to the container, such as details for device mappings. |
logging? | Log | The loging configuration for this Job. |
privileged? | boolean | When this parameter is true, the container is given elevated permissions on the host container instance (similar to the root user). |
readonly | boolean | Gives the container readonly access to its root filesystem. |
secrets? | { [string]: Secret } | A map from environment variable names to the secrets for the container. |
ulimits? | Ulimit [] | Limits to set for the user this docker container will run as. |
user? | string | The user name to use inside the container. |
volumes? | Ecs [] | The volumes to mount to this container. |
cpu
Type:
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.
image
Type:
Container
The image that this container will run.
memory
Type:
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.
command?
Type:
string[]
(optional, default: no command)
The command that's passed to the container.
See also: https://docs.docker.com/engine/reference/builder/#cmd
environment?
Type:
{ [string]: string }
(optional, default: no environment variables)
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.
executionRole?
Type:
IRole
(optional, default: a Role will be created)
The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.
See also: https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html
gpu?
Type:
number
(optional, default: no gpus)
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.
jobRole?
Type:
IRole
(optional, default: no job role)
The role that the container can assume.
See also: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html
linuxParameters?
Type:
Linux
(optional, default: none)
Linux-specific modifications that are applied to the container, such as details for device mappings.
logging?
Type:
Log
(optional, default: the log configuration of the Docker daemon)
The loging configuration for this Job.
privileged?
Type:
boolean
(optional, default: false)
When this parameter is true, the container is given elevated permissions on the host container instance (similar to the root user).
readonlyRootFilesystem?
Type:
boolean
(optional, default: false)
Gives the container readonly access to its root filesystem.
secrets?
Type:
{ [string]:
Secret
}
(optional, default: no secrets)
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.
See also: https://docs.aws.amazon.com/batch/latest/userguide/specifying-sensitive-data.html
ulimits?
Type:
Ulimit
[]
(optional, default: no ulimits)
Limits to set for the user this docker container will run as.
user?
Type:
string
(optional, default: no user)
The user name to use inside the container.
volumes?
Type:
Ecs
[]
(optional, default: no volumes)
The volumes to mount to this container.
Automatically added to the job definition.