Show / Hide Table of Contents

Class EcsEc2ContainerDefinitionProps

Props to configure an EcsEc2ContainerDefinition.

Inheritance
object
EcsEc2ContainerDefinitionProps
Implements
IEcsEc2ContainerDefinitionProps
IEcsContainerDefinitionProps
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: Amazon.CDK.AWS.Batch
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class EcsEc2ContainerDefinitionProps : IEcsEc2ContainerDefinitionProps, IEcsContainerDefinitionProps
Syntax (vb)
Public Class EcsEc2ContainerDefinitionProps Implements IEcsEc2ContainerDefinitionProps, IEcsContainerDefinitionProps
Remarks

ExampleMetadata: infused

Examples
IVpc vpc;


            var ecsJob = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
                Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
                    Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
                    Memory = Size.Mebibytes(2048),
                    Cpu = 256
                })
            });

            var queue = new JobQueue(this, "JobQueue", new JobQueueProps {
                ComputeEnvironments = new [] { new OrderedComputeEnvironment {
                    ComputeEnvironment = new ManagedEc2EcsComputeEnvironment(this, "managedEc2CE", new ManagedEc2EcsComputeEnvironmentProps {
                        Vpc = vpc
                    }),
                    Order = 1
                } },
                Priority = 10
            });

            var user = new User(this, "MyUser");
            ecsJob.GrantSubmitJob(user, queue);

Synopsis

Constructors

EcsEc2ContainerDefinitionProps()

Props to configure an EcsEc2ContainerDefinition.

Properties

Command

The command that's passed to the container.

Cpu

The number of vCPUs reserved for the container.

EnableExecuteCommand

Determines whether execute command functionality is turned on for this task.

Environment

The environment variables to pass to a container.

ExecutionRole

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

Gpu

The number of physical GPUs to reserve for the container.

Image

The image that this container will run.

JobRole

The role that the container can assume.

LinuxParameters

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

Logging

The loging configuration for this Job.

Memory

The memory hard limit present to the container.

Privileged

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

ReadonlyRootFilesystem

Gives the container readonly access to its root filesystem.

Secrets

A map from environment variable names to the secrets for the container.

Ulimits

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

User

The user name to use inside the container.

Volumes

The volumes to mount to this container.

Constructors

EcsEc2ContainerDefinitionProps()

Props to configure an EcsEc2ContainerDefinition.

public EcsEc2ContainerDefinitionProps()
Remarks

ExampleMetadata: infused

Examples
IVpc vpc;


            var ecsJob = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
                Container = new EcsEc2ContainerDefinition(this, "containerDefn", new EcsEc2ContainerDefinitionProps {
                    Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
                    Memory = Size.Mebibytes(2048),
                    Cpu = 256
                })
            });

            var queue = new JobQueue(this, "JobQueue", new JobQueueProps {
                ComputeEnvironments = new [] { new OrderedComputeEnvironment {
                    ComputeEnvironment = new ManagedEc2EcsComputeEnvironment(this, "managedEc2CE", new ManagedEc2EcsComputeEnvironmentProps {
                        Vpc = vpc
                    }),
                    Order = 1
                } },
                Priority = 10
            });

            var user = new User(this, "MyUser");
            ecsJob.GrantSubmitJob(user, queue);

Properties

Command

The command that's passed to the container.

public string[]? Command { get; set; }
Property Value

string[]

Remarks

Default: - no command

See: https://docs.docker.com/engine/reference/builder/#cmd

Cpu

The number of vCPUs reserved for the container.

public double Cpu { get; set; }
Property Value

double

Remarks

Each vCPU is equivalent to 1,024 CPU shares. For containers running on EC2 resources, you must specify at least one vCPU.

EnableExecuteCommand

Determines whether execute command functionality is turned on for this task.

public bool? EnableExecuteCommand { get; set; }
Property Value

bool?

Remarks

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

See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html

Environment

The environment variables to pass to a container.

public IDictionary<string, string>? Environment { get; set; }
Property Value

IDictionary<string, string>

Remarks

Cannot start with AWS_BATCH. We don't recommend using plaintext environment variables for sensitive information, such as credential data.

Default: - no environment variables

ExecutionRole

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

public IRole? ExecutionRole { get; set; }
Property Value

IRole

Remarks

Default: - a Role will be created

See: https://docs.aws.amazon.com/batch/latest/userguide/execution-IAM-role.html

Gpu

The number of physical GPUs to reserve for the container.

public double? Gpu { get; set; }
Property Value

double?

Remarks

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

Image

The image that this container will run.

public ContainerImage Image { get; set; }
Property Value

ContainerImage

Remarks

ExampleMetadata: infused

JobRole

The role that the container can assume.

public IRole? JobRole { get; set; }
Property Value

IRole

Remarks

Default: - no job role

See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html

LinuxParameters

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

public LinuxParameters? LinuxParameters { get; set; }
Property Value

LinuxParameters

Remarks

Default: none

Logging

The loging configuration for this Job.

public LogDriver? Logging { get; set; }
Property Value

LogDriver

Remarks

Default: - the log configuration of the Docker daemon

Memory

The memory hard limit present to the container.

public Size Memory { get; set; }
Property Value

Size

Remarks

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.

Privileged

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

public bool? Privileged { get; set; }
Property Value

bool?

Remarks

Default: false

ReadonlyRootFilesystem

Gives the container readonly access to its root filesystem.

public bool? ReadonlyRootFilesystem { get; set; }
Property Value

bool?

Remarks

Default: false

Secrets

A map from environment variable names to the secrets for the container.

public IDictionary<string, Secret>? Secrets { get; set; }
Property Value

IDictionary<string, Secret>

Remarks

Allows your job definitions to reference the secret by the environment variable name defined in this property.

Default: - no secrets

See: https://docs.aws.amazon.com/batch/latest/userguide/specifying-sensitive-data.html

Ulimits

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

public IUlimit[]? Ulimits { get; set; }
Property Value

IUlimit[]

Remarks

Default: - no ulimits

User

The user name to use inside the container.

public string? User { get; set; }
Property Value

string

Remarks

Default: - no user

Volumes

The volumes to mount to this container.

public EcsVolume[]? Volumes { get; set; }
Property Value

EcsVolume[]

Remarks

Automatically added to the job definition.

Default: - no volumes

Implements

IEcsEc2ContainerDefinitionProps
IEcsContainerDefinitionProps
Back to top Generated by DocFX