Class EcsEc2ContainerDefinition
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.services.batch.EcsEc2ContainerDefinition
- All Implemented Interfaces:
IEcsContainerDefinition,IEcsEc2ContainerDefinition,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.116.0 (build 0eddcff)",
date="2025-10-29T11:15:33.337Z")
@Stability(Stable)
public class EcsEc2ContainerDefinition
extends software.constructs.Construct
implements IEcsEc2ContainerDefinition, IEcsContainerDefinition
A container orchestrated by ECS that uses EC2 resources.
Example:
IVpc vpc;
EcsJobDefinition ecsJob = EcsJobDefinition.Builder.create(this, "JobDefn")
.container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
.image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
.memory(Size.mebibytes(2048))
.cpu(256)
.build())
.build();
JobQueue queue = JobQueue.Builder.create(this, "JobQueue")
.computeEnvironments(List.of(OrderedComputeEnvironment.builder()
.computeEnvironment(ManagedEc2EcsComputeEnvironment.Builder.create(this, "managedEc2CE")
.vpc(vpc)
.build())
.order(1)
.build()))
.priority(10)
.build();
User user = new User(this, "MyUser");
ecsJob.grantSubmitJob(user, queue);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forEcsEc2ContainerDefinition.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default, software.constructs.IConstruct.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.services.batch.IEcsContainerDefinition
IEcsContainerDefinition.Jsii$Default, IEcsContainerDefinition.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.services.batch.IEcsEc2ContainerDefinition
IEcsEc2ContainerDefinition.Jsii$Default, IEcsEc2ContainerDefinition.Jsii$Proxy -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEcsEc2ContainerDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedEcsEc2ContainerDefinition(software.amazon.jsii.JsiiObjectRef objRef) EcsEc2ContainerDefinition(software.constructs.Construct scope, String id, EcsEc2ContainerDefinitionProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a ulimit to this container.voidAdd a Volume to this container.The command that's passed to the container.getCpu()The number of vCPUs reserved for the container.Whether to enable ecs exec for this container.The environment variables to pass to a container.The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.getGpu()The number of physical GPUs to reserve for the container.getImage()The image that this container will run.The role that the container can assume.Linux-specific modifications that are applied to the container, such as details for device mappings.The configuration of the log driver.The memory hard limit present to the container.When this parameter is true, the container is given elevated permissions on the host container instance (similar to the root user).Gives the container readonly access to its root filesystem.A map from environment variable names to the secrets for the container.Limits to set for the user this docker container will run as.getUser()The user name to use inside the container.The volumes to mount to this container.Methods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
Uniquely identifies this class.
-
-
Constructor Details
-
EcsEc2ContainerDefinition
protected EcsEc2ContainerDefinition(software.amazon.jsii.JsiiObjectRef objRef) -
EcsEc2ContainerDefinition
protected EcsEc2ContainerDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
EcsEc2ContainerDefinition
@Stability(Stable) public EcsEc2ContainerDefinition(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull EcsEc2ContainerDefinitionProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Details
-
addUlimit
Add a ulimit to this container.- Specified by:
addUlimitin interfaceIEcsEc2ContainerDefinition- Parameters:
ulimit- This parameter is required.
-
addVolume
Add a Volume to this container.- Specified by:
addVolumein interfaceIEcsContainerDefinition- Parameters:
volume- This parameter is required.
-
getCpu
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.
- Specified by:
getCpuin interfaceIEcsContainerDefinition
-
getExecutionRole
The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.- Specified by:
getExecutionRolein interfaceIEcsContainerDefinition- See Also:
-
getImage
The image that this container will run.- Specified by:
getImagein interfaceIEcsContainerDefinition
-
getMemory
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.
- Specified by:
getMemoryin interfaceIEcsContainerDefinition
-
getUlimits
Limits to set for the user this docker container will run as.- Specified by:
getUlimitsin interfaceIEcsEc2ContainerDefinition
-
getVolumes
The volumes to mount to this container.Automatically added to the job definition.
- Specified by:
getVolumesin interfaceIEcsContainerDefinition
-
getCommand
The command that's passed to the container.- Specified by:
getCommandin interfaceIEcsContainerDefinition- See Also:
-
getEnableExecuteCommand
Whether to enable ecs exec for this container.- Specified by:
getEnableExecuteCommandin interfaceIEcsContainerDefinition
-
getEnvironment
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.- Specified by:
getEnvironmentin interfaceIEcsContainerDefinition
-
getGpu
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.
- Specified by:
getGpuin interfaceIEcsEc2ContainerDefinition
-
getJobRole
The role that the container can assume.- Specified by:
getJobRolein interfaceIEcsContainerDefinition- See Also:
-
getLinuxParameters
Linux-specific modifications that are applied to the container, such as details for device mappings.- Specified by:
getLinuxParametersin interfaceIEcsContainerDefinition
-
getLogDriverConfig
The configuration of the log driver.- Specified by:
getLogDriverConfigin interfaceIEcsContainerDefinition
-
getPrivileged
When this parameter is true, the container is given elevated permissions on the host container instance (similar to the root user).- Specified by:
getPrivilegedin interfaceIEcsEc2ContainerDefinition
-
getReadonlyRootFilesystem
Gives the container readonly access to its root filesystem.- Specified by:
getReadonlyRootFilesystemin interfaceIEcsContainerDefinition
-
getSecrets
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.
- Specified by:
getSecretsin interfaceIEcsContainerDefinition- See Also:
-
getUser
The user name to use inside the container.- Specified by:
getUserin interfaceIEcsContainerDefinition
-