Skip to content
v2.273.0

EksContainerDefinition ​

A container that can be run with EKS orchestration on EC2 resources.

Example ​

ts
const jobDefn = new batch.EksJobDefinition(this, 'eksf2', {
  container: new batch.EksContainerDefinition(this, 'container', {
    image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
    volumes: [batch.EksVolume.emptyDir({
      name: 'myEmptyDirVolume',
      mountPath: '/mount/path',
      medium: batch.EmptyDirMediumType.MEMORY,
      readonly: true,
      sizeLimit: cdk.Size.mebibytes(2048),
    })],
  }),
});
python
job_defn = batch.EksJobDefinition(self, "eksf2",
    container=batch.EksContainerDefinition(self, "container",
        image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
        volumes=[batch.EksVolume.empty_dir(
            name="myEmptyDirVolume",
            mount_path="/mount/path",
            medium=batch.EmptyDirMediumType.MEMORY,
            readonly=True,
            size_limit=cdk.Size.mebibytes(2048)
        )]
    )
)
java
EksJobDefinition jobDefn = EksJobDefinition.Builder.create(this, "eksf2")
        .container(EksContainerDefinition.Builder.create(this, "container")
                .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
                .volumes(List.of(EksVolume.emptyDir(EmptyDirVolumeOptions.builder()
                        .name("myEmptyDirVolume")
                        .mountPath("/mount/path")
                        .medium(EmptyDirMediumType.MEMORY)
                        .readonly(true)
                        .sizeLimit(Size.mebibytes(2048))
                        .build())))
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var jobDefn = new EksJobDefinition(this, "eksf2", new EksJobDefinitionProps {
    Container = new EksContainerDefinition(this, "container", new EksContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
        Volumes = new [] { EksVolume.EmptyDir(new EmptyDirVolumeOptions {
            Name = "myEmptyDirVolume",
            MountPath = "/mount/path",
            Medium = EmptyDirMediumType.MEMORY,
            Readonly = true,
            SizeLimit = Size.Mebibytes(2048)
        }) }
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
jobDefn := batch.NewEksJobDefinition(this, jsii.String("eksf2"), &EksJobDefinitionProps{
	Container: batch.NewEksContainerDefinition(this, jsii.String("container"), &EksContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("amazon/amazon-ecs-sample")),
		Volumes: []EksVolume{
			batch.EksVolume_EmptyDir(&EmptyDirVolumeOptions{
				Name: jsii.String("myEmptyDirVolume"),
				MountPath: jsii.String("/mount/path"),
				Medium: batch.EmptyDirMediumType_MEMORY,
				Readonly: jsii.Boolean(true),
				SizeLimit: cdk.Size_Mebibytes(jsii.Number(2048)),
			}),
		},
	}),
})

Initializer ​

ts
new EksContainerDefinition(scope: Construct, id: string, props: EksContainerDefinitionProps)
python
EksContainerDefinition(scope: Construct, id: str, props: EksContainerDefinitionProps)
java
new EksContainerDefinition(Construct scope, String id, EksContainerDefinitionProps props)
csharp
new EksContainerDefinition(Construct scope, string id, EksContainerDefinitionProps props)
go
NewEksContainerDefinition(Scope Construct, Id *string, Props EksContainerDefinitionProps)

Construct Props ​

argsstring[]argstyping.List[str]argsList<String>Argsstring[]Args*[]*string= no args#
An array of arguments to the entrypoint.
notes

If this isn't specified, the CMD of the container image is used. This corresponds to the args member in the Entrypoint portion of the Pod in Kubernetes. Environment variable references are expanded using the container's environment. If the referenced environment variable doesn't exist, the reference in the command isn't changed. For example, if the reference is to "(NAME1)"andtheNAME1environmentvariabledoesn′texist,thecommandstringwillremain"(NAME1)." $$ is replaced with $, and the resulting string isn't expanded. or example, $$(VAR_NAME) is passed as $(VAR_NAME) whether or not the VAR_NAME environment variable exists.

commandstring[]commandtyping.List[str]commandList<String>Commandstring[]Command*[]*string= no command#
The entrypoint for the container.
notes

This isn't run within a shell. If this isn't specified, the ENTRYPOINT of the container image is used. Environment variable references are expanded using the container's environment. If the referenced environment variable doesn't exist, the reference in the command isn't changed. For example, if the reference is to "$(NAME1)" and the NAME1 environment variable doesn't exist, the command string will remain "$(NAME1)." $$ is replaced with $ and the resulting string isn't expanded. For example, $$(VAR_NAME) will be passed as $(VAR_NAME) whether or not the VAR_NAME environment variable exists.

The entrypoint can't be updated.

cpuLimitnumbercpu_limitint | floatcpuLimitNumberCpuLimitdoubleCpuLimit*float64= No CPU limit#
The hard limit of CPUs to present to this container. Must be an even multiple of 0.25.

If your container attempts to exceed this limit, it will be terminated.

At least one of cpuReservation and cpuLimit is required. If both are specified, then cpuLimit must be at least as large as cpuReservation.

cpuReservationnumbercpu_reservationint | floatcpuReservationNumberCpuReservationdoubleCpuReservation*float64= No CPUs reserved#
The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.

The container will given at least this many CPUs, but may consume more.

At least one of cpuReservation and cpuLimit is required. If both are specified, then cpuLimit must be at least as large as cpuReservation.

env{ [key: string]: string }envtyping.Mapping[str, str]envMap<String, String>EnvIDictionary<string, string>Env*map[string]*string= no environment variables#
The environment variables to pass to this container.

Note: Environment variables cannot start with "AWS_BATCH". This naming convention is reserved for variables that AWS Batch sets.

gpuLimitnumbergpu_limitint | floatgpuLimitNumberGpuLimitdoubleGpuLimit*float64= No GPU limit#
The hard limit of GPUs to present to this container.

If your container attempts to exceed this limit, it will be terminated.

If both gpuReservation and gpuLimit are specified, then gpuLimit must be equal to gpuReservation.

gpuReservationnumbergpu_reservationint | floatgpuReservationNumberGpuReservationdoubleGpuReservation*float64= No GPUs reserved#
The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.

The container will given at least this many CPUs, but may consume more.

If both gpuReservation and gpuLimit are specified, then gpuLimit must be equal to gpuReservation.

The image that this container will run.
imagePullPolicyImagePullPolicyimage_pull_policyImagePullPolicyimagePullPolicyImagePullPolicyImagePullPolicyImagePullPolicyImagePullPolicyImagePullPolicy= `ALWAYS` if the `:latest` tag is…#
The image pull policy for this container.
default

Default: ALWAYS if the :latest tag is specified, IF_NOT_PRESENT otherwise

memoryLimitSizememory_limitSizememoryLimitSizeMemoryLimitSizeMemoryLimitSize= No memory limit#
The amount (in MiB) of memory to present to the container.
notes

If your container attempts to exceed the allocated memory, it will be terminated.

Must be larger that 4 MiB

At least one of memoryLimit and memoryReservation is required

Note: To maximize your resource utilization, provide your jobs with as much memory as possible for the specific instance type that you are using.

memoryReservationSizememory_reservationSizememoryReservationSizeMemoryReservationSizeMemoryReservationSize= No memory reserved#
The soft limit (in MiB) of memory to reserve for the container.
notes

Your container will be given at least this much memory, but may consume more.

Must be larger that 4 MiB

When system memory is under heavy contention, Docker attempts to keep the container memory to this soft limit. However, your container can consume more memory when it needs to, up to either the hard limit specified with the memory parameter (if applicable), or all of the available memory on the container instance, whichever comes first.

At least one of memoryLimit and memoryReservation is required. If both are specified, then memoryLimit must be equal to memoryReservation

Note: To maximize your resource utilization, provide your jobs with as much memory as possible for the specific instance type that you are using.

namestringnamestrnameStringNamestringName*string= : `'Default'`#
The name of this container.
privilegedbooleanprivilegedboolprivilegedBooleanPrivilegedboolPrivileged*bool= false#
If specified, gives this container elevated permissions on the host container instance.

The level of permissions are similar to the root user permissions.

This parameter maps to privileged policy in the Privileged pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

readonlyRootFilesystembooleanreadonly_root_filesystemboolreadonlyRootFilesystemBooleanReadonlyRootFilesystemboolReadonlyRootFilesystem*bool= false#
If specified, gives this container readonly access to its root file system.

This parameter maps to ReadOnlyRootFilesystem policy in the Volumes and file systems pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

runAsGroupnumberrun_as_groupint | floatrunAsGroupNumberRunAsGroupdoubleRunAsGroup*float64= none#
If specified, the container is run as the specified group ID (`gid`).
notes

If this parameter isn't specified, the default is the group that's specified in the image metadata. This parameter maps to RunAsGroup and MustRunAs policy in the Users and groups pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

runAsRootbooleanrun_as_rootboolrunAsRootBooleanRunAsRootboolRunAsRoot*bool= the container is *not* required …#
If specified, the container is run as a user with a `uid` other than 0.

Otherwise, no such rule is enforced. This parameter maps to RunAsUser and MustRunAsNonRoot policy in the Users and groups pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

default

Default: the container is not required to run as a non-root user

runAsUsernumberrun_as_userint | floatrunAsUserNumberRunAsUserdoubleRunAsUser*float64= the user that is specified in th…#
If specified, this container is run as the specified user ID (`uid`).

This parameter maps to RunAsUser and MustRunAs policy in the Users and groups pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

default

Default: the user that is specified in the image metadata.

volumesEksVolume[]volumestyping.List[EksVolume]volumesList<EksVolume>VolumesEksVolume[]Volumes*[]EksVolume= no volumes#
The Volumes to mount to this container.

Automatically added to the Pod.

Properties ​

argsstring[]argstyping.List[str]argsList<String>Argsstring[]Args*[]*string#
An array of arguments to the entrypoint.
notes

If this isn't specified, the CMD of the container image is used. This corresponds to the args member in the Entrypoint portion of the Pod in Kubernetes. Environment variable references are expanded using the container's environment. If the referenced environment variable doesn't exist, the reference in the command isn't changed. For example, if the reference is to "(NAME1)"andtheNAME1environmentvariabledoesn′texist,thecommandstringwillremain"(NAME1)." $$ is replaced with $, and the resulting string isn't expanded. or example, $$(VAR_NAME) is passed as $(VAR_NAME) whether or not the VAR_NAME environment variable exists.

commandstring[]commandtyping.List[str]commandList<String>Commandstring[]Command*[]*string#
The entrypoint for the container.
notes

This isn't run within a shell. If this isn't specified, the ENTRYPOINT of the container image is used. Environment variable references are expanded using the container's environment. If the referenced environment variable doesn't exist, the reference in the command isn't changed. For example, if the reference is to "$(NAME1)" and the NAME1 environment variable doesn't exist, the command string will remain "$(NAME1)." $$ is replaced with $ and the resulting string isn't expanded. For example, $$(VAR_NAME) will be passed as $(VAR_NAME) whether or not the VAR_NAME environment variable exists.

The entrypoint can't be updated.

cpuLimitnumbercpu_limitint | floatcpuLimitNumberCpuLimitdoubleCpuLimit*float64#
The hard limit of CPUs to present to this container. Must be an even multiple of 0.25.

If your container attempts to exceed this limit, it will be terminated.

At least one of cpuReservation and cpuLimit is required. If both are specified, then cpuLimit must be at least as large as cpuReservation.

cpuReservationnumbercpu_reservationint | floatcpuReservationNumberCpuReservationdoubleCpuReservation*float64#
The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.

The container will given at least this many CPUs, but may consume more.

At least one of cpuReservation and cpuLimit is required. If both are specified, then cpuLimit must be at least as large as cpuReservation.

env{ [key: string]: string }envtyping.Mapping[str, str]envMap<String, String>EnvIDictionary<string, string>Env*map[string]*string#
The environment variables to pass to this container.

Note: Environment variables cannot start with "AWS_BATCH". This naming convention is reserved for variables that AWS Batch sets.

gpuLimitnumbergpu_limitint | floatgpuLimitNumberGpuLimitdoubleGpuLimit*float64#
The hard limit of GPUs to present to this container.

If your container attempts to exceed this limit, it will be terminated.

If both gpuReservation and gpuLimit are specified, then gpuLimit must be equal to gpuReservation.

gpuReservationnumbergpu_reservationint | floatgpuReservationNumberGpuReservationdoubleGpuReservation*float64#
The soft limit of CPUs to reserve for the container Must be an even multiple of 0.25.

The container will given at least this many CPUs, but may consume more.

If both gpuReservation and gpuLimit are specified, then gpuLimit must be equal to gpuReservation.

The image that this container will run.
imagePullPolicyImagePullPolicyimage_pull_policyImagePullPolicyimagePullPolicyImagePullPolicyImagePullPolicyImagePullPolicyImagePullPolicyImagePullPolicy#
The image pull policy for this container.
memoryLimitSizememory_limitSizememoryLimitSizeMemoryLimitSizeMemoryLimitSize#
The amount (in MiB) of memory to present to the container.
notes

If your container attempts to exceed the allocated memory, it will be terminated.

Must be larger that 4 MiB

At least one of memoryLimit and memoryReservation is required

Note: To maximize your resource utilization, provide your jobs with as much memory as possible for the specific instance type that you are using.

memoryReservationSizememory_reservationSizememoryReservationSizeMemoryReservationSizeMemoryReservationSize#
The soft limit (in MiB) of memory to reserve for the container.
notes

Your container will be given at least this much memory, but may consume more.

Must be larger that 4 MiB

When system memory is under heavy contention, Docker attempts to keep the container memory to this soft limit. However, your container can consume more memory when it needs to, up to either the hard limit specified with the memory parameter (if applicable), or all of the available memory on the container instance, whichever comes first.

At least one of memoryLimit and memoryReservation is required. If both are specified, then memoryLimit must be equal to memoryReservation

Note: To maximize your resource utilization, provide your jobs with as much memory as possible for the specific instance type that you are using.

namestringnamestrnameStringNamestringName*string#
The name of this container.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
privilegedbooleanprivilegedboolprivilegedBooleanPrivilegedboolPrivileged*bool#
If specified, gives this container elevated permissions on the host container instance.

The level of permissions are similar to the root user permissions.

This parameter maps to privileged policy in the Privileged pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
readonlyRootFilesystembooleanreadonly_root_filesystemboolreadonlyRootFilesystemBooleanReadonlyRootFilesystemboolReadonlyRootFilesystem*bool#
If specified, gives this container readonly access to its root file system.

This parameter maps to ReadOnlyRootFilesystem policy in the Volumes and file systems pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

runAsGroupnumberrun_as_groupint | floatrunAsGroupNumberRunAsGroupdoubleRunAsGroup*float64#
If specified, the container is run as the specified group ID (`gid`).
notes

If this parameter isn't specified, the default is the group that's specified in the image metadata. This parameter maps to RunAsGroup and MustRunAs policy in the Users and groups pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

runAsRootbooleanrun_as_rootboolrunAsRootBooleanRunAsRootboolRunAsRoot*bool#
If specified, the container is run as a user with a `uid` other than 0.

Otherwise, no such rule is enforced. This parameter maps to RunAsUser and MustRunAsNonRoot policy in the Users and groups pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

runAsUsernumberrun_as_userint | floatrunAsUserNumberRunAsUserdoubleRunAsUser*float64#
If specified, this container is run as the specified user ID (`uid`).

This parameter maps to RunAsUser and MustRunAs policy in the Users and groups pod security policies in the Kubernetes documentation.

Note: this is only compatible with Kubernetes < v1.25

volumesEksVolume[]volumestyping.List[EksVolume]volumesList<EksVolume>VolumesEksVolume[]Volumes*[]EksVolumerequired#
The Volumes to mount to this container.

Automatically added to the Pod.

Methods ​

addVolume(volume: EksVolume): voiddef add_volume(self, volume: EksVolume) -> Nonepublic void addVolume(EksVolume volume)public void AddVolume(EksVolume volume)func AddVolume(Volume EksVolume)#
Mount a Volume to this container.

Automatically added to the Pod.

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining