EcsContainerDefinitionProps Struct
Props to configure an EcsContainerDefinition.
| Source | aws-batch/lib/ecs-container-definition.ts |
|---|---|
| Type last changed |
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_batch as batch } from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
declare const containerImage: ecs.ContainerImage;
declare const ecsVolume: batch.EcsVolume;
declare const linuxParameters: batch.LinuxParameters;
declare const logDriver: ecs.LogDriver;
declare const role: iam.Role;
declare const secret: batch.Secret;
declare const size: cdk.Size;
const ecsContainerDefinitionProps: batch.EcsContainerDefinitionProps = {
cpu: 123,
image: containerImage,
memory: size,
// the properties below are optional
command: ['command'],
enableExecuteCommand: false,
environment: {
environmentKey: 'environment',
},
executionRole: role,
jobRole: role,
linuxParameters: linuxParameters,
logging: logDriver,
readonlyRootFilesystem: false,
secrets: {
secretsKey: secret,
},
user: 'user',
volumes: [ecsVolume],
};
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_batch as batch
from aws_cdk import aws_ecs as ecs
from aws_cdk import aws_iam as iam
# container_image: ecs.ContainerImage
# ecs_volume: batch.EcsVolume
# linux_parameters: batch.LinuxParameters
# log_driver: ecs.LogDriver
# role: iam.Role
# secret: batch.Secret
# size: cdk.Size
ecs_container_definition_props = batch.EcsContainerDefinitionProps(
cpu=123,
image=container_image,
memory=size,
# the properties below are optional
command=["command"],
enable_execute_command=False,
environment={
"environment_key": "environment"
},
execution_role=role,
job_role=role,
linux_parameters=linux_parameters,
logging=log_driver,
readonly_root_filesystem=False,
secrets={
"secrets_key": secret
},
user="user",
volumes=[ecs_volume]
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.batch.*;
import software.amazon.awscdk.services.ecs.*;
import software.amazon.awscdk.services.iam.*;
ContainerImage containerImage;
EcsVolume ecsVolume;
LinuxParameters linuxParameters;
LogDriver logDriver;
Role role;
Secret secret;
Size size;
EcsContainerDefinitionProps ecsContainerDefinitionProps = EcsContainerDefinitionProps.builder()
.cpu(123)
.image(containerImage)
.memory(size)
// the properties below are optional
.command(List.of("command"))
.enableExecuteCommand(false)
.environment(Map.of(
"environmentKey", "environment"))
.executionRole(role)
.jobRole(role)
.linuxParameters(linuxParameters)
.logging(logDriver)
.readonlyRootFilesystem(false)
.secrets(Map.of(
"secretsKey", secret))
.user("user")
.volumes(List.of(ecsVolume))
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.Batch;
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.IAM;
ContainerImage containerImage;
EcsVolume ecsVolume;
LinuxParameters linuxParameters;
LogDriver logDriver;
Role role;
Secret secret;
Size size;
var ecsContainerDefinitionProps = new EcsContainerDefinitionProps {
Cpu = 123,
Image = containerImage,
Memory = size,
// the properties below are optional
Command = new [] { "command" },
EnableExecuteCommand = false,
Environment = new Dictionary<string, string> {
{ "environmentKey", "environment" }
},
ExecutionRole = role,
JobRole = role,
LinuxParameters = linuxParameters,
Logging = logDriver,
ReadonlyRootFilesystem = false,
Secrets = new Dictionary<string, Secret> {
{ "secretsKey", secret }
},
User = "user",
Volumes = new [] { ecsVolume }
};
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var containerImage ContainerImage
var ecsVolume EcsVolume
var linuxParameters LinuxParameters
var logDriver LogDriver
var role Role
var secret Secret
var size Size
ecsContainerDefinitionProps := &EcsContainerDefinitionProps{
Cpu: jsii.Number(123),
Image: containerImage,
Memory: size,
// the properties below are optional
Command: []*string{
jsii.String("command"),
},
EnableExecuteCommand: jsii.Boolean(false),
Environment: map[string]*string{
"environmentKey": jsii.String("environment"),
},
ExecutionRole: role,
JobRole: role,
LinuxParameters: linuxParameters,
Logging: logDriver,
ReadonlyRootFilesystem: jsii.Boolean(false),
Secrets: map[string]Secret{
"secretsKey": secret,
},
User: jsii.String("user"),
Volumes: []EcsVolume{
ecsVolume,
},
}
Properties
commandoptionalstring[]commandoptionaltyping.List[str]commandoptionalList<String>Commandoptionalstring[]Commandoptional*[]*string #Default: no command
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 #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 #Default: no environment variables
Cannot start with AWS_BATCH. We don't recommend using plaintext environment variables for sensitive information, such as credential data.
executionRoleoptionalIRoleexecution_roleoptionalIRoleexecutionRoleoptionalIRoleExecutionRoleoptionalIRoleExecutionRoleoptionalIRole #Default: a Role will be created
imageContainerImageimageContainerImageimageContainerImageImageContainerImageImageContainerImage required #jobRoleoptionalIRolejob_roleoptionalIRolejobRoleoptionalIRoleJobRoleoptionalIRoleJobRoleoptionalIRole #Default: no job role
linuxParametersoptionalLinuxParameterslinux_parametersoptionalLinuxParameterslinuxParametersoptionalLinuxParametersLinuxParametersoptionalLinuxParametersLinuxParametersoptionalLinuxParameters = none #loggingoptionalLogDriverloggingoptionalLogDriverloggingoptionalLogDriverLoggingoptionalLogDriverLoggingoptionalLogDriver #Default: the log configuration of the Docker daemon
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 #secretsoptional{ [key: string]: Secret }secretsoptionaltyping.Mapping[str, Secret]secretsoptionalMap<String, Secret>SecretsoptionalIDictionary<string, Secret>Secretsoptional*map[string]Secret #Default: no secrets
Allows your job definitions to reference the secret by the environment variable name defined in this property.
Default: no user