Skip to content
v2.278.0

EcsFargateContainerDefinitionProps Struct ​

Props to configure an EcsFargateContainerDefinition.

Example ​

ts
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,
  }),
});
python
job_defn = batch.EcsJobDefinition(self, "JobDefn",
    container=batch.EcsFargateContainerDefinition(self, "myFargateContainer",
        image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        memory=cdk.Size.mebibytes(2048),
        cpu=256,
        ephemeral_storage_size=cdk.Size.gibibytes(100),
        fargate_cpu_architecture=ecs.CpuArchitecture.ARM64,
        fargate_operating_system_family=ecs.OperatingSystemFamily.LINUX
    )
)
java
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
        .container(EcsFargateContainerDefinition.Builder.create(this, "myFargateContainer")
                .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                .memory(Size.mebibytes(2048))
                .cpu(256)
                .ephemeralStorageSize(Size.gibibytes(100))
                .fargateCpuArchitecture(CpuArchitecture.ARM64)
                .fargateOperatingSystemFamily(OperatingSystemFamily.LINUX)
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
    Container = new EcsFargateContainerDefinition(this, "myFargateContainer", new EcsFargateContainerDefinitionProps {
        Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
        Memory = Size.Mebibytes(2048),
        Cpu = 256,
        EphemeralStorageSize = Size.Gibibytes(100),
        FargateCpuArchitecture = CpuArchitecture.ARM64,
        FargateOperatingSystemFamily = OperatingSystemFamily.LINUX
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
	Container: batch.NewEcsFargateContainerDefinition(this, jsii.String("myFargateContainer"), &EcsFargateContainerDefinitionProps{
		Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
		Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
		Cpu: jsii.Number(256),
		EphemeralStorageSize: cdk.Size_Gibibytes(jsii.Number(100)),
		FargateCpuArchitecture: ecs.CpuArchitecture_ARM64(),
		FargateOperatingSystemFamily: ecs.OperatingSystemFamily_LINUX(),
	}),
})

Properties ​

assignPublicIpoptionalbooleanassign_public_ipoptionalboolassignPublicIpoptionalBooleanAssignPublicIpoptionalboolAssignPublicIpoptional*bool = 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.

commandoptionalstring[]commandoptionaltyping.List[str]commandoptionalList<String>Commandoptionalstring[]Commandoptional*[]*string #
The command that's passed to the container.

Default: no command

cpunumbercpuint | floatcpuNumberCpudoubleCpu*float64 required #
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.

enableExecuteCommandoptionalbooleanenable_execute_commandoptionalboolenableExecuteCommandoptionalBooleanEnableExecuteCommandoptionalboolEnableExecuteCommandoptional*bool #
Determines whether execute command functionality is turned on for this task.

Default: undefined - AWS Batch default is false

notes

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.

environmentoptional{ [key: string]: string }environmentoptionaltyping.Mapping[str, str]environmentoptionalMap<String, String>EnvironmentoptionalIDictionary<string, string>Environmentoptional*map[string]*string #
The environment variables to pass to a container.

Default: no environment variables

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

ephemeralStorageSizeoptionalSizeephemeral_storage_sizeoptionalSizeephemeralStorageSizeoptionalSizeEphemeralStorageSizeoptionalSizeEphemeralStorageSizeoptionalSize #
The size for ephemeral storage.

Default: 20 GiB

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

Default: a Role will be created

fargateCpuArchitectureoptionalCpuArchitecturefargate_cpu_architectureoptionalCpuArchitecturefargateCpuArchitectureoptionalCpuArchitectureFargateCpuArchitectureoptionalCpuArchitectureFargateCpuArchitectureoptionalCpuArchitecture = X86_64 #
The vCPU architecture of Fargate Runtime.
fargateOperatingSystemFamilyoptionalOperatingSystemFamilyfargate_operating_system_familyoptionalOperatingSystemFamilyfargateOperatingSystemFamilyoptionalOperatingSystemFamilyFargateOperatingSystemFamilyoptionalOperatingSystemFamilyFargateOperatingSystemFamilyoptionalOperatingSystemFamily = LINUX #
The operating system for the compute environment.
fargatePlatformVersionoptionalFargatePlatformVersionfargate_platform_versionoptionalFargatePlatformVersionfargatePlatformVersionoptionalFargatePlatformVersionFargatePlatformVersionoptionalFargatePlatformVersionFargatePlatformVersionoptionalFargatePlatformVersion = LATEST #
Which version of Fargate to use when running this container.
The image that this container will run.
jobRoleoptionalIRolejob_roleoptionalIRolejobRoleoptionalIRoleJobRoleoptionalIRoleJobRoleoptionalIRole #
The role that the container can assume.

Default: no job role

linuxParametersoptionalLinuxParameterslinux_parametersoptionalLinuxParameterslinuxParametersoptionalLinuxParametersLinuxParametersoptionalLinuxParametersLinuxParametersoptionalLinuxParameters = none #
Linux-specific modifications that are applied to the container, such as details for device mappings.
loggingoptionalLogDriverloggingoptionalLogDriverloggingoptionalLogDriverLoggingoptionalLogDriverLoggingoptionalLogDriver #
The loging configuration for this Job.

Default: the log configuration of the Docker daemon

memorySizememorySizememorySizeMemorySizeMemorySize required #
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.

readonlyRootFilesystemoptionalbooleanreadonly_root_filesystemoptionalboolreadonlyRootFilesystemoptionalBooleanReadonlyRootFilesystemoptionalboolReadonlyRootFilesystemoptional*bool = false #
Gives the container readonly access to its root filesystem.
secretsoptional{ [key: string]: Secret }secretsoptionaltyping.Mapping[str, Secret]secretsoptionalMap<String, Secret>SecretsoptionalIDictionary<string, Secret>Secretsoptional*map[string]Secret #
A map from environment variable names to the secrets for the container.

Default: no secrets

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

useroptionalstringuseroptionalstruseroptionalStringUseroptionalstringUseroptional*string #
The user name to use inside the container.

Default: no user

volumesoptionalEcsVolume[]volumesoptionaltyping.List[EcsVolume]volumesoptionalList<EcsVolume>VolumesoptionalEcsVolume[]Volumesoptional*[]EcsVolume #
The volumes to mount to this container.

Default: no volumes

Automatically added to the job definition.