class EcsFargateContainerDefinition (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.Batch.EcsFargateContainerDefinition |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsbatch#EcsFargateContainerDefinition |
![]() | software.amazon.awscdk.services.batch.EcsFargateContainerDefinition |
![]() | aws_cdk.aws_batch.EcsFargateContainerDefinition |
![]() | aws-cdk-lib » aws_batch » EcsFargateContainerDefinition |
Implements
IConstruct
, IDependable
, IEcs
, IEcs
A container orchestrated by ECS that uses Fargate resources.
Example
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
container: new batch.EcsFargateContainerDefinition(this, 'myFargateContainer', {
image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
memory: cdk.Size.mebibytes(2048),
cpu: 256,
ephemeralStorageSize: cdk.Size.gibibytes(100),
fargateCpuArchitecture: ecs.CpuArchitecture.ARM64,
fargateOperatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
}),
});
Initializer
new EcsFargateContainerDefinition(scope: Construct, id: string, props: EcsFargateContainerDefinitionProps)
Parameters
- scope
Construct
- id
string
- props
Ecs
Fargate Container Definition Props
Construct Props
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. |
assign | boolean | Indicates 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. |
ephemeral | Size | The size for ephemeral storage. |
execution | IRole | The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf. |
fargate | Cpu | The vCPU architecture of Fargate Runtime. |
fargate | Operating | The operating system for the compute environment. |
fargate | Fargate | Which version of Fargate to use when running this 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. |
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. |
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.
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.
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
fargateCpuArchitecture?
Type:
Cpu
(optional, default: X86_64)
The vCPU architecture of Fargate Runtime.
fargateOperatingSystemFamily?
Type:
Operating
(optional, default: LINUX)
The operating system for the compute environment.
fargatePlatformVersion?
Type:
Fargate
(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:
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.
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.
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.
Properties
Name | Type | Description |
---|---|---|
cpu | number | The number of vCPUs reserved for the container. |
execution | IRole | The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf. |
image | Container | The image that this container will run. |
memory | Size | The memory hard limit present to the container. |
node | Node | The tree node. |
volumes | Ecs [] | The volumes to mount to this container. |
assign | boolean | Indicates 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. |
ephemeral | Size | The size for ephemeral storage. |
fargate | Cpu | The vCPU architecture of Fargate Runtime. |
fargate | Operating | The operating system for the compute environment. |
fargate | Fargate | Which version of Fargate to use when running this 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. |
log | Log | The configuration of the log driver. |
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. |
user? | string | The 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:
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.
node
Type:
Node
The tree node.
volumes
Type:
Ecs
[]
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.
fargateCpuArchitecture?
Type:
Cpu
(optional)
The vCPU architecture of Fargate Runtime.
fargateOperatingSystemFamily?
Type:
Operating
(optional)
The operating system for the compute environment.
fargatePlatformVersion?
Type:
Fargate
(optional)
Which version of Fargate to use when running this container.
jobRole?
Type:
IRole
(optional)
The role that the container can assume.
linuxParameters?
Type:
Linux
(optional)
Linux-specific modifications that are applied to the container, such as details for device mappings.
logDriverConfig?
Type:
Log
(optional)
The configuration of the log driver.
readonlyRootFilesystem?
Type:
boolean
(optional)
Gives the container readonly access to its root filesystem.
secrets?
Type:
{ [string]:
Secret
}
(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
Name | Description |
---|---|
add | Add a Volume to this container. |
to | Returns a string representation of this construct. |
addVolume(volume)
public addVolume(volume: EcsVolume): void
Parameters
- volume
Ecs
Volume
Add a Volume to this container.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.