@aws-cdk_aws-batch-alpha.EcsFargateContainerDefinition

class EcsFargateContainerDefinition (construct) ๐Ÿ”น

LanguageType name
.NETAmazon.CDK.AWS.Batch.Alpha.EcsFargateContainerDefinition
Gogithub.com/aws/aws-cdk-go/awscdkbatchalpha/v2#EcsFargateContainerDefinition
Javasoftware.amazon.awscdk.services.batch.alpha.EcsFargateContainerDefinition
Pythonaws_cdk.aws_batch_alpha.EcsFargateContainerDefinition
TypeScript (source)@aws-cdk/aws-batch-alpha ยป EcsFargateContainerDefinition

Implements IConstruct, IDependable, IEcsFargateContainerDefinition, IEcsContainerDefinition

A container orchestrated by ECS that uses Fargate resources.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as batch_alpha from '@aws-cdk/aws-batch-alpha';
import * as cdk from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
import { aws_secretsmanager as secretsmanager } from 'aws-cdk-lib';

declare const containerImage: ecs.ContainerImage;
declare const ecsVolume: batch_alpha.EcsVolume;
declare const linuxParameters: batch_alpha.LinuxParameters;
declare const logDriver: ecs.LogDriver;
declare const role: iam.Role;
declare const secret: secretsmanager.Secret;
declare const size: cdk.Size;
const ecsFargateContainerDefinition = new batch_alpha.EcsFargateContainerDefinition(this, 'MyEcsFargateContainerDefinition', {
  cpu: 123,
  image: containerImage,
  memory: size,

  // the properties below are optional
  assignPublicIp: false,
  command: ['command'],
  environment: {
    environmentKey: 'environment',
  },
  ephemeralStorageSize: size,
  executionRole: role,
  fargatePlatformVersion: ecs.FargatePlatformVersion.LATEST,
  jobRole: role,
  linuxParameters: linuxParameters,
  logging: logDriver,
  readonlyRootFilesystem: false,
  secrets: {
    secretsKey: secret,
  },
  user: 'user',
  volumes: [ecsVolume],
});

Initializer

new EcsFargateContainerDefinition(scope: Construct, id: string, props: EcsFargateContainerDefinitionProps)

Parameters

  • scope Construct
  • id string
  • props EcsFargateContainerDefinitionProps

Construct Props

NameTypeDescription
cpu๐Ÿ”นnumberThe number of vCPUs reserved for the container.
image๐Ÿ”นContainerImageThe image that this container will run.
memory๐Ÿ”นSizeThe memory hard limit present to the container.
assignPublicIp?๐Ÿ”นbooleanIndicates whether the job has a public IP address.
command?๐Ÿ”นstring[]The command that's passed to the container.
environment?๐Ÿ”น{ [string]: string }The environment variables to pass to a container.
ephemeralStorageSize?๐Ÿ”นSizeThe size for ephemeral storage.
executionRole?๐Ÿ”นIRoleThe role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.
fargatePlatformVersion?๐Ÿ”นFargatePlatformVersionWhich version of Fargate to use when running this container.
jobRole?๐Ÿ”นIRoleThe role that the container can assume.
linuxParameters?๐Ÿ”นLinuxParametersLinux-specific modifications that are applied to the container, such as details for device mappings.
logging?๐Ÿ”นLogDriverThe loging configuration for this Job.
readonlyRootFilesystem?๐Ÿ”นbooleanGives the container readonly access to its root filesystem.
secrets?๐Ÿ”น{ [string]: ISecret }A map from environment variable names to the secrets for the container.
user?๐Ÿ”นstringThe user name to use inside the container.
volumes?๐Ÿ”นEcsVolume[]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: ContainerImage

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.


assignPublicIp?๐Ÿ”น

Type: boolean (optional, default: false)

Indicates whether the job has a public IP address.

For a job that's running on Fargate resources in a private subnet to send outbound traffic to the internet (for example, to pull container images), the private subnet requires a NAT gateway be attached to route requests to the internet.

See also: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-networking.html


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.


ephemeralStorageSize?๐Ÿ”น

Type: Size (optional, default: 20 GiB)

The size for ephemeral storage.


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


fargatePlatformVersion?๐Ÿ”น

Type: FargatePlatformVersion (optional, default: LATEST)

Which version of Fargate to use when running this container.


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: LinuxParameters (optional, default: none)

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


logging?๐Ÿ”น

Type: LogDriver (optional, default: the log configuration of the Docker daemon)

The loging configuration for this Job.


readonlyRootFilesystem?๐Ÿ”น

Type: boolean (optional, default: false)

Gives the container readonly access to its root filesystem.


secrets?๐Ÿ”น

Type: { [string]: ISecret } (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


user?๐Ÿ”น

Type: string (optional, default: no user)

The user name to use inside the container.


volumes?๐Ÿ”น

Type: EcsVolume[] (optional, default: no volumes)

The volumes to mount to this container.

Automatically added to the job definition.

Properties

NameTypeDescription
cpu๐Ÿ”นnumberThe number of vCPUs reserved for the container.
executionRole๐Ÿ”นIRoleThe role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.
image๐Ÿ”นContainerImageThe image that this container will run.
memory๐Ÿ”นSizeThe memory hard limit present to the container.
node๐Ÿ”นNodeThe tree node.
volumes๐Ÿ”นEcsVolume[]The volumes to mount to this container.
assignPublicIp?๐Ÿ”นbooleanIndicates whether the job has a public IP address.
command?๐Ÿ”นstring[]The command that's passed to the container.
environment?๐Ÿ”น{ [string]: string }The environment variables to pass to a container.
ephemeralStorageSize?๐Ÿ”นSizeThe size for ephemeral storage.
fargatePlatformVersion?๐Ÿ”นFargatePlatformVersionWhich version of Fargate to use when running this container.
jobRole?๐Ÿ”นIRoleThe role that the container can assume.
linuxParameters?๐Ÿ”นLinuxParametersLinux-specific modifications that are applied to the container, such as details for device mappings.
logDriverConfig?๐Ÿ”นLogDriverConfigThe configuration of the log driver.
readonlyRootFilesystem?๐Ÿ”นbooleanGives the container readonly access to its root filesystem.
secrets?๐Ÿ”น{ [string]: ISecret }A map from environment variable names to the secrets for the container.
user?๐Ÿ”นstringThe user name to use inside the 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.


executionRole๐Ÿ”น

Type: IRole

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


image๐Ÿ”น

Type: ContainerImage

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.


node๐Ÿ”น

Type: Node

The tree node.


volumes๐Ÿ”น

Type: EcsVolume[]

The volumes to mount to this container.

Automatically added to the job definition.


assignPublicIp?๐Ÿ”น

Type: boolean (optional)

Indicates whether the job has a public IP address.

For a job that's running on Fargate resources in a private subnet to send outbound traffic to the internet (for example, to pull container images), the private subnet requires a NAT gateway be attached to route requests to the internet.


command?๐Ÿ”น

Type: string[] (optional)

The command that's passed to the container.


environment?๐Ÿ”น

Type: { [string]: string } (optional)

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.


ephemeralStorageSize?๐Ÿ”น

Type: Size (optional)

The size for ephemeral storage.


fargatePlatformVersion?๐Ÿ”น

Type: FargatePlatformVersion (optional)

Which version of Fargate to use when running this container.


jobRole?๐Ÿ”น

Type: IRole (optional)

The role that the container can assume.


linuxParameters?๐Ÿ”น

Type: LinuxParameters (optional)

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


logDriverConfig?๐Ÿ”น

Type: LogDriverConfig (optional)

The configuration of the log driver.


readonlyRootFilesystem?๐Ÿ”น

Type: boolean (optional)

Gives the container readonly access to its root filesystem.


secrets?๐Ÿ”น

Type: { [string]: ISecret } (optional)

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.


user?๐Ÿ”น

Type: string (optional)

The user name to use inside the container.

Methods

NameDescription
addVolume(volume)๐Ÿ”นAdd a Volume to this container.
toString()๐Ÿ”นReturns a string representation of this construct.

addVolume(volume)๐Ÿ”น

public addVolume(volume: EcsVolume): void

Parameters

  • volume EcsVolume

Add a Volume to this container.


toString()๐Ÿ”น

public toString(): string

Returns

  • string

Returns a string representation of this construct.