CfnTaskDefinition
- class aws_cdk.aws_ecs.CfnTaskDefinition(scope, id, *, container_definitions=None, cpu=None, ephemeral_storage=None, execution_role_arn=None, family=None, inference_accelerators=None, ipc_mode=None, memory=None, network_mode=None, pid_mode=None, placement_constraints=None, proxy_configuration=None, requires_compatibilities=None, runtime_platform=None, tags=None, task_role_arn=None, volumes=None)
Bases:
CfnResourceA CloudFormation
AWS::ECS::TaskDefinition.The details of a task definition which describes the container and volume definitions of an Amazon Elastic Container Service task. You can specify which Docker images to use, the required resources, and other configurations related to launching the task definition through an Amazon ECS service or task.
- CloudformationResource:
AWS::ECS::TaskDefinition
- Link:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-taskdefinition.html
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs cfn_task_definition = ecs.CfnTaskDefinition(self, "MyCfnTaskDefinition", container_definitions=[ecs.CfnTaskDefinition.ContainerDefinitionProperty( image="image", name="name", # the properties below are optional command=["command"], cpu=123, depends_on=[ecs.CfnTaskDefinition.ContainerDependencyProperty( condition="condition", container_name="containerName" )], disable_networking=False, dns_search_domains=["dnsSearchDomains"], dns_servers=["dnsServers"], docker_labels={ "docker_labels_key": "dockerLabels" }, docker_security_options=["dockerSecurityOptions"], entry_point=["entryPoint"], environment=[ecs.CfnTaskDefinition.KeyValuePairProperty( name="name", value="value" )], environment_files=[ecs.CfnTaskDefinition.EnvironmentFileProperty( type="type", value="value" )], essential=False, extra_hosts=[ecs.CfnTaskDefinition.HostEntryProperty( hostname="hostname", ip_address="ipAddress" )], firelens_configuration=ecs.CfnTaskDefinition.FirelensConfigurationProperty( options={ "options_key": "options" }, type="type" ), health_check=ecs.CfnTaskDefinition.HealthCheckProperty( command=["command"], interval=123, retries=123, start_period=123, timeout=123 ), hostname="hostname", interactive=False, links=["links"], linux_parameters=ecs.CfnTaskDefinition.LinuxParametersProperty( capabilities=ecs.CfnTaskDefinition.KernelCapabilitiesProperty( add=["add"], drop=["drop"] ), devices=[ecs.CfnTaskDefinition.DeviceProperty( container_path="containerPath", host_path="hostPath", permissions=["permissions"] )], init_process_enabled=False, max_swap=123, shared_memory_size=123, swappiness=123, tmpfs=[ecs.CfnTaskDefinition.TmpfsProperty( size=123, # the properties below are optional container_path="containerPath", mount_options=["mountOptions"] )] ), log_configuration=ecs.CfnTaskDefinition.LogConfigurationProperty( log_driver="logDriver", # the properties below are optional options={ "options_key": "options" }, secret_options=[ecs.CfnTaskDefinition.SecretProperty( name="name", value_from="valueFrom" )] ), memory=123, memory_reservation=123, mount_points=[ecs.CfnTaskDefinition.MountPointProperty( container_path="containerPath", read_only=False, source_volume="sourceVolume" )], port_mappings=[ecs.CfnTaskDefinition.PortMappingProperty( app_protocol="appProtocol", container_port=123, container_port_range="containerPortRange", host_port=123, name="name", protocol="protocol" )], privileged=False, pseudo_terminal=False, readonly_root_filesystem=False, repository_credentials=ecs.CfnTaskDefinition.RepositoryCredentialsProperty( credentials_parameter="credentialsParameter" ), resource_requirements=[ecs.CfnTaskDefinition.ResourceRequirementProperty( type="type", value="value" )], secrets=[ecs.CfnTaskDefinition.SecretProperty( name="name", value_from="valueFrom" )], start_timeout=123, stop_timeout=123, system_controls=[ecs.CfnTaskDefinition.SystemControlProperty( namespace="namespace", value="value" )], ulimits=[ecs.CfnTaskDefinition.UlimitProperty( hard_limit=123, name="name", soft_limit=123 )], user="user", volumes_from=[ecs.CfnTaskDefinition.VolumeFromProperty( read_only=False, source_container="sourceContainer" )], working_directory="workingDirectory" )], cpu="cpu", ephemeral_storage=ecs.CfnTaskDefinition.EphemeralStorageProperty( size_in_gi_b=123 ), execution_role_arn="executionRoleArn", family="family", inference_accelerators=[ecs.CfnTaskDefinition.InferenceAcceleratorProperty( device_name="deviceName", device_type="deviceType" )], ipc_mode="ipcMode", memory="memory", network_mode="networkMode", pid_mode="pidMode", placement_constraints=[ecs.CfnTaskDefinition.TaskDefinitionPlacementConstraintProperty( type="type", # the properties below are optional expression="expression" )], proxy_configuration=ecs.CfnTaskDefinition.ProxyConfigurationProperty( container_name="containerName", # the properties below are optional proxy_configuration_properties=[ecs.CfnTaskDefinition.KeyValuePairProperty( name="name", value="value" )], type="type" ), requires_compatibilities=["requiresCompatibilities"], runtime_platform=ecs.CfnTaskDefinition.RuntimePlatformProperty( cpu_architecture="cpuArchitecture", operating_system_family="operatingSystemFamily" ), tags=[CfnTag( key="key", value="value" )], task_role_arn="taskRoleArn", volumes=[ecs.CfnTaskDefinition.VolumeProperty( docker_volume_configuration=ecs.CfnTaskDefinition.DockerVolumeConfigurationProperty( autoprovision=False, driver="driver", driver_opts={ "driver_opts_key": "driverOpts" }, labels={ "labels_key": "labels" }, scope="scope" ), efs_volume_configuration=ecs.CfnTaskDefinition.EFSVolumeConfigurationProperty( filesystem_id="filesystemId", # the properties below are optional authorization_config=ecs.CfnTaskDefinition.AuthorizationConfigProperty( access_point_id="accessPointId", iam="iam" ), root_directory="rootDirectory", transit_encryption="transitEncryption", transit_encryption_port=123 ), host=ecs.CfnTaskDefinition.HostVolumePropertiesProperty( source_path="sourcePath" ), name="name" )] )
Create a new
AWS::ECS::TaskDefinition.- Parameters:
scope (
Construct) –scope in which this resource is defined.
id (
str) –scoped id of the resource.
container_definitions (
Union[IResolvable,Sequence[Union[ContainerDefinitionProperty,Dict[str,Any],IResolvable]],None]) – A list of container definitions in JSON format that describe the different containers that make up your task. For more information about container definition parameters and defaults, see Amazon ECS Task Definitions in the Amazon Elastic Container Service Developer Guide .cpu (
Optional[str]) – The number ofcpuunits used by the task. If you use the EC2 launch type, this field is optional. Any value can be used. If you use the Fargate launch type, this field is required. You must use one of the following values. The value that you choose determines your range of valid values for thememoryparameter. The CPU units cannot be less than 1 vCPU when you use Windows containers on Fargate. - 256 (.25 vCPU) - Availablememoryvalues: 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - 512 (.5 vCPU) - Availablememoryvalues: 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - 1024 (1 vCPU) - Availablememoryvalues: 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - 2048 (2 vCPU) - Availablememoryvalues: 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - 4096 (4 vCPU) - Availablememoryvalues: 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - 8192 (8 vCPU) - Availablememoryvalues: 16 GB and 60 GB in 4 GB increments This option requires Linux platform1.4.0or later. - 16384 (16vCPU) - Availablememoryvalues: 32GB and 120 GB in 8 GB increments This option requires Linux platform1.4.0or later.ephemeral_storage (
Union[IResolvable,EphemeralStorageProperty,Dict[str,Any],None]) – The ephemeral storage settings to use for tasks run with the task definition.execution_role_arn (
Optional[str]) – The Amazon Resource Name (ARN) of the task execution role that grants the Amazon ECS container agent permission to make AWS API calls on your behalf. The task execution IAM role is required depending on the requirements of your task. For more information, see Amazon ECS task execution IAM role in the Amazon Elastic Container Service Developer Guide .family (
Optional[str]) – The name of a family that this task definition is registered to. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed. A family groups multiple versions of a task definition. Amazon ECS gives the first task definition that you registered to a family a revision number of 1. Amazon ECS gives sequential revision numbers to each task definition that you add. .. epigraph:: To use revision numbers when you update a task definition, specify this property. If you don’t specify a value, AWS CloudFormation generates a new task definition each time that you update it.inference_accelerators (
Union[IResolvable,Sequence[Union[IResolvable,InferenceAcceleratorProperty,Dict[str,Any]]],None]) – The Elastic Inference accelerators to use for the containers in the task.ipc_mode (
Optional[str]) – The IPC resource namespace to use for the containers in the task. The valid values arehost,task, ornone. Ifhostis specified, then all containers within the tasks that specified thehostIPC mode on the same container instance share the same IPC resources with the host Amazon EC2 instance. Iftaskis specified, all containers within the specified task share the same IPC resources. Ifnoneis specified, then IPC resources within the containers of a task are private and not shared with other containers in a task or on the container instance. If no value is specified, then the IPC resource namespace sharing depends on the Docker daemon setting on the container instance. For more information, see IPC settings in the Docker run reference . If thehostIPC mode is used, be aware that there is a heightened risk of undesired IPC namespace expose. For more information, see Docker security . If you are setting namespaced kernel parameters usingsystemControlsfor the containers in the task, the following will apply to your IPC resource namespace. For more information, see System Controls in the Amazon Elastic Container Service Developer Guide . - For tasks that use thehostIPC mode, IPC namespace relatedsystemControlsare not supported. - For tasks that use thetaskIPC mode, IPC namespace relatedsystemControlswill apply to all containers within a task. .. epigraph:: This parameter is not supported for Windows containers or tasks run on AWS Fargate .memory (
Optional[str]) – The amount (in MiB) of memory used by the task. If your tasks runs on Amazon EC2 instances, you must specify either a task-level memory value or a container-level memory value. This field is optional and any value can be used. If a task-level memory value is specified, the container-level memory value is optional. For more information regarding container-level memory and memory reservation, see ContainerDefinition . If your tasks runs on AWS Fargate , this field is required. You must use one of the following values. The value you choose determines your range of valid values for thecpuparameter. - 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Availablecpuvalues: 256 (.25 vCPU) - 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Availablecpuvalues: 512 (.5 vCPU) - 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Availablecpuvalues: 1024 (1 vCPU) - Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Availablecpuvalues: 2048 (2 vCPU) - Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Availablecpuvalues: 4096 (4 vCPU) - Between 16 GB and 60 GB in 4 GB increments - Availablecpuvalues: 8192 (8 vCPU) This option requires Linux platform1.4.0or later. - Between 32GB and 120 GB in 8 GB increments - Availablecpuvalues: 16384 (16 vCPU) This option requires Linux platform1.4.0or later.network_mode (
Optional[str]) – The Docker networking mode to use for the containers in the task. The valid values arenone,bridge,awsvpc, andhost. If no network mode is specified, the default isbridge. For Amazon ECS tasks on Fargate, theawsvpcnetwork mode is required. For Amazon ECS tasks on Amazon EC2 Linux instances, any network mode can be used. For Amazon ECS tasks on Amazon EC2 Windows instances,<default>orawsvpccan be used. If the network mode is set tonone, you cannot specify port mappings in your container definitions, and the tasks containers do not have external connectivity. Thehostandawsvpcnetwork modes offer the highest networking performance for containers because they use the EC2 network stack instead of the virtualized network stack provided by thebridgemode. With thehostandawsvpcnetwork modes, exposed container ports are mapped directly to the corresponding host port (for thehostnetwork mode) or the attached elastic network interface port (for theawsvpcnetwork mode), so you cannot take advantage of dynamic host port mappings. .. epigraph:: When using thehostnetwork mode, you should not run containers using the root user (UID 0). It is considered best practice to use a non-root user. If the network mode isawsvpc, the task is allocated an elastic network interface, and you must specify aNetworkConfigurationvalue when you create a service or run a task with the task definition. For more information, see Task Networking in the Amazon Elastic Container Service Developer Guide . If the network mode ishost, you cannot run multiple instantiations of the same task on a single container instance when port mappings are used. For more information, see Network settings in the Docker run reference .pid_mode (
Optional[str]) –The process namespace to use for the containers in the task. The valid values are
hostortask. Ifhostis specified, then all containers within the tasks that specified thehostPID mode on the same container instance share the same process namespace with the host Amazon EC2 instance. Iftaskis specified, all containers within the specified task share the same process namespace. If no value is specified, the default is a private namespace. For more information, see PID settings in the Docker run reference . If thehostPID mode is used, be aware that there is a heightened risk of undesired process namespace expose. For more information, see Docker security . .. epigraph:: This parameter is not supported for Windows containers or tasks run on AWS Fargate .placement_constraints (
Union[IResolvable,Sequence[Union[IResolvable,TaskDefinitionPlacementConstraintProperty,Dict[str,Any]]],None]) – An array of placement constraint objects to use for tasks. .. epigraph:: This parameter isn’t supported for tasks run on AWS Fargate .proxy_configuration (
Union[ProxyConfigurationProperty,Dict[str,Any],IResolvable,None]) – The configuration details for the App Mesh proxy. Your Amazon ECS container instances require at least version 1.26.0 of the container agent and at least version 1.26.0-1 of theecs-initpackage to use a proxy configuration. If your container instances are launched from the Amazon ECS optimized AMI version20190301or later, they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .requires_compatibilities (
Optional[Sequence[str]]) – The task launch types the task definition was validated against. For more information, see Amazon ECS launch types in the Amazon Elastic Container Service Developer Guide .runtime_platform (
Union[IResolvable,RuntimePlatformProperty,Dict[str,Any],None]) – The operating system that your tasks definitions run on. A platform family is specified only for tasks using the Fargate launch type. When you specify a task definition in a service, this value must match theruntimePlatformvalue of the service.tags (
Optional[Sequence[Union[CfnTag,Dict[str,Any]]]]) – The metadata that you apply to the task definition to help you categorize and organize them. Each tag consists of a key and an optional value. You define both of them. The following basic restrictions apply to tags: - Maximum number of tags per resource - 50 - For each resource, each tag key must be unique, and each tag key can have only one value. - Maximum key length - 128 Unicode characters in UTF-8 - Maximum value length - 256 Unicode characters in UTF-8 - If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @. - Tag keys and values are case-sensitive. - Do not useaws:,AWS:, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.task_role_arn (
Optional[str]) – The short name or full Amazon Resource Name (ARN) of the AWS Identity and Access Management role that grants containers in the task permission to call AWS APIs on your behalf. For more information, see Amazon ECS Task Role in the Amazon Elastic Container Service Developer Guide . IAM roles for tasks on Windows require that the-EnableTaskIAMRoleoption is set when you launch the Amazon ECS-optimized Windows AMI. Your containers must also run some configuration code to use the feature. For more information, see Windows IAM roles for tasks in the Amazon Elastic Container Service Developer Guide .volumes (
Union[IResolvable,Sequence[Union[IResolvable,VolumeProperty,Dict[str,Any]]],None]) – The list of data volume definitions for the task. For more information, see Using data volumes in tasks in the Amazon Elastic Container Service Developer Guide . .. epigraph:: ThehostandsourcePathparameters aren’t supported for tasks run on AWS Fargate .
Methods
- add_deletion_override(path)
Syntactic sugar for
addOverride(path, undefined).- Parameters:
path (
str) – The path of the value to delete.- Return type:
None
- add_depends_on(target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
- Parameters:
target (
CfnResource)- Return type:
None
- add_metadata(key, value)
Add a value to the CloudFormation Resource Metadata.
- Parameters:
key (
str)value (
Any)
- See:
- Return type:
None
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- add_override(path, value)
Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverrideor prefixpathwith “Properties.” (i.e.Properties.TopicName).If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal
.in the property name, prefix with a\. In most programming languages you will need to write this as"\\."because the\itself will need to be escaped.For example:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
valueargument toaddOverridewill not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.- Parameters:
path (
str) –The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
value (
Any) –The value. Could be primitive or complex.
- Return type:
None
- add_property_deletion_override(property_path)
Adds an override that deletes the value of a property from the resource definition.
- Parameters:
property_path (
str) – The path to the property.- Return type:
None
- add_property_override(property_path, value)
Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value).- Parameters:
property_path (
str) – The path of the property.value (
Any) – The value.
- Return type:
None
- apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)
Sets the deletion policy of the resource based on the removal policy specified.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).- Parameters:
policy (
Optional[RemovalPolicy])apply_to_update_replace_policy (
Optional[bool]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional[RemovalPolicy]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.
- Return type:
None
- get_att(attribute_name)
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g.
resource.arn), but this can be used for future compatibility in case there is no generated attribute.- Parameters:
attribute_name (
str) – The name of the attribute.- Return type:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str)- See:
- Return type:
Any
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- inspect(inspector)
Examines the CloudFormation resource and discloses attributes.
- Parameters:
inspector (
TreeInspector) –tree inspector to collect and process attributes.
- Return type:
None
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str) – The new logical ID to use for this stack element.- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str- Returns:
a string representation of this resource
Attributes
- CFN_RESOURCE_TYPE_NAME = 'AWS::ECS::TaskDefinition'
- attr_task_definition_arn
TaskDefinitionArn
- Type:
cloudformationAttribute
- cfn_options
Options for this resource, such as condition, update policy etc.
- cfn_resource_type
AWS resource type.
- container_definitions
A list of container definitions in JSON format that describe the different containers that make up your task.
For more information about container definition parameters and defaults, see Amazon ECS Task Definitions in the Amazon Elastic Container Service Developer Guide .
- cpu
The number of
cpuunits used by the task.If you use the EC2 launch type, this field is optional. Any value can be used. If you use the Fargate launch type, this field is required. You must use one of the following values. The value that you choose determines your range of valid values for the
memoryparameter.The CPU units cannot be less than 1 vCPU when you use Windows containers on Fargate.
256 (.25 vCPU) - Available
memoryvalues: 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB)512 (.5 vCPU) - Available
memoryvalues: 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB)1024 (1 vCPU) - Available
memoryvalues: 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB)2048 (2 vCPU) - Available
memoryvalues: 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB)4096 (4 vCPU) - Available
memoryvalues: 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB)8192 (8 vCPU) - Available
memoryvalues: 16 GB and 60 GB in 4 GB increments
This option requires Linux platform
1.4.0or later.16384 (16vCPU) - Available
memoryvalues: 32GB and 120 GB in 8 GB increments
This option requires Linux platform
1.4.0or later.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- ephemeral_storage
The ephemeral storage settings to use for tasks run with the task definition.
- execution_role_arn
The Amazon Resource Name (ARN) of the task execution role that grants the Amazon ECS container agent permission to make AWS API calls on your behalf.
The task execution IAM role is required depending on the requirements of your task. For more information, see Amazon ECS task execution IAM role in the Amazon Elastic Container Service Developer Guide .
- family
The name of a family that this task definition is registered to.
Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.
A family groups multiple versions of a task definition. Amazon ECS gives the first task definition that you registered to a family a revision number of 1. Amazon ECS gives sequential revision numbers to each task definition that you add. .. epigraph:
To use revision numbers when you update a task definition, specify this property. If you don't specify a value, AWS CloudFormation generates a new task definition each time that you update it.
- inference_accelerators
The Elastic Inference accelerators to use for the containers in the task.
- ipc_mode
The IPC resource namespace to use for the containers in the task.
The valid values are
host,task, ornone. Ifhostis specified, then all containers within the tasks that specified thehostIPC mode on the same container instance share the same IPC resources with the host Amazon EC2 instance. Iftaskis specified, all containers within the specified task share the same IPC resources. Ifnoneis specified, then IPC resources within the containers of a task are private and not shared with other containers in a task or on the container instance. If no value is specified, then the IPC resource namespace sharing depends on the Docker daemon setting on the container instance. For more information, see IPC settings in the Docker run reference .If the
hostIPC mode is used, be aware that there is a heightened risk of undesired IPC namespace expose. For more information, see Docker security .If you are setting namespaced kernel parameters using
systemControlsfor the containers in the task, the following will apply to your IPC resource namespace. For more information, see System Controls in the Amazon Elastic Container Service Developer Guide .For tasks that use the
hostIPC mode, IPC namespace relatedsystemControlsare not supported.For tasks that use the
taskIPC mode, IPC namespace relatedsystemControlswill apply to all containers within a task.
This parameter is not supported for Windows containers or tasks run on AWS Fargate .
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId).- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- memory
The amount (in MiB) of memory used by the task.
If your tasks runs on Amazon EC2 instances, you must specify either a task-level memory value or a container-level memory value. This field is optional and any value can be used. If a task-level memory value is specified, the container-level memory value is optional. For more information regarding container-level memory and memory reservation, see ContainerDefinition .
If your tasks runs on AWS Fargate , this field is required. You must use one of the following values. The value you choose determines your range of valid values for the
cpuparameter.512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available
cpuvalues: 256 (.25 vCPU)1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available
cpuvalues: 512 (.5 vCPU)2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available
cpuvalues: 1024 (1 vCPU)Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available
cpuvalues: 2048 (2 vCPU)Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available
cpuvalues: 4096 (4 vCPU)Between 16 GB and 60 GB in 4 GB increments - Available
cpuvalues: 8192 (8 vCPU)
This option requires Linux platform
1.4.0or later.Between 32GB and 120 GB in 8 GB increments - Available
cpuvalues: 16384 (16 vCPU)
This option requires Linux platform
1.4.0or later.
- network_mode
The Docker networking mode to use for the containers in the task.
The valid values are
none,bridge,awsvpc, andhost. If no network mode is specified, the default isbridge.For Amazon ECS tasks on Fargate, the
awsvpcnetwork mode is required. For Amazon ECS tasks on Amazon EC2 Linux instances, any network mode can be used. For Amazon ECS tasks on Amazon EC2 Windows instances,<default>orawsvpccan be used. If the network mode is set tonone, you cannot specify port mappings in your container definitions, and the tasks containers do not have external connectivity. Thehostandawsvpcnetwork modes offer the highest networking performance for containers because they use the EC2 network stack instead of the virtualized network stack provided by thebridgemode.With the
hostandawsvpcnetwork modes, exposed container ports are mapped directly to the corresponding host port (for thehostnetwork mode) or the attached elastic network interface port (for theawsvpcnetwork mode), so you cannot take advantage of dynamic host port mappings. .. epigraph:When using the ``host`` network mode, you should not run containers using the root user (UID 0). It is considered best practice to use a non-root user.
If the network mode is
awsvpc, the task is allocated an elastic network interface, and you must specify aNetworkConfigurationvalue when you create a service or run a task with the task definition. For more information, see Task Networking in the Amazon Elastic Container Service Developer Guide .If the network mode is
host, you cannot run multiple instantiations of the same task on a single container instance when port mappings are used.For more information, see Network settings in the Docker run reference .
- node
The construct tree node associated with this construct.
- pid_mode
The process namespace to use for the containers in the task.
The valid values are
hostortask. Ifhostis specified, then all containers within the tasks that specified thehostPID mode on the same container instance share the same process namespace with the host Amazon EC2 instance. Iftaskis specified, all containers within the specified task share the same process namespace. If no value is specified, the default is a private namespace. For more information, see PID settings in the Docker run reference .If the
hostPID mode is used, be aware that there is a heightened risk of undesired process namespace expose. For more information, see Docker security . .. epigraph:This parameter is not supported for Windows containers or tasks run on AWS Fargate .
- placement_constraints
An array of placement constraint objects to use for tasks.
This parameter isn’t supported for tasks run on AWS Fargate .
- proxy_configuration
The configuration details for the App Mesh proxy.
Your Amazon ECS container instances require at least version 1.26.0 of the container agent and at least version 1.26.0-1 of the
ecs-initpackage to use a proxy configuration. If your container instances are launched from the Amazon ECS optimized AMI version20190301or later, they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref }).
- requires_compatibilities
The task launch types the task definition was validated against.
For more information, see Amazon ECS launch types in the Amazon Elastic Container Service Developer Guide .
- runtime_platform
The operating system that your tasks definitions run on.
A platform family is specified only for tasks using the Fargate launch type.
When you specify a task definition in a service, this value must match the
runtimePlatformvalue of the service.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- tags
The metadata that you apply to the task definition to help you categorize and organize them.
Each tag consists of a key and an optional value. You define both of them.
The following basic restrictions apply to tags:
Maximum number of tags per resource - 50
For each resource, each tag key must be unique, and each tag key can have only one value.
Maximum key length - 128 Unicode characters in UTF-8
Maximum value length - 256 Unicode characters in UTF-8
If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.
Tag keys and values are case-sensitive.
Do not use
aws:,AWS:, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.
- task_role_arn
The short name or full Amazon Resource Name (ARN) of the AWS Identity and Access Management role that grants containers in the task permission to call AWS APIs on your behalf.
For more information, see Amazon ECS Task Role in the Amazon Elastic Container Service Developer Guide .
IAM roles for tasks on Windows require that the
-EnableTaskIAMRoleoption is set when you launch the Amazon ECS-optimized Windows AMI. Your containers must also run some configuration code to use the feature. For more information, see Windows IAM roles for tasks in the Amazon Elastic Container Service Developer Guide .
- volumes
The list of data volume definitions for the task.
For more information, see Using data volumes in tasks in the Amazon Elastic Container Service Developer Guide . .. epigraph:
The ``host`` and ``sourcePath`` parameters aren't supported for tasks run on AWS Fargate .
Static Methods
- classmethod is_cfn_element(x)
Returns
trueif a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceofto allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any)- Return type:
bool- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_cfn_resource(construct)
Check whether the given construct is a CfnResource.
- Parameters:
construct (
IConstruct)- Return type:
bool
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any)- Return type:
bool
ContainerDefinitionProperty
- class CfnTaskDefinition.ContainerDefinitionProperty(*, image, name, command=None, cpu=None, depends_on=None, disable_networking=None, dns_search_domains=None, dns_servers=None, docker_labels=None, docker_security_options=None, entry_point=None, environment=None, environment_files=None, essential=None, extra_hosts=None, firelens_configuration=None, health_check=None, hostname=None, interactive=None, links=None, linux_parameters=None, log_configuration=None, memory=None, memory_reservation=None, mount_points=None, port_mappings=None, privileged=None, pseudo_terminal=None, readonly_root_filesystem=None, repository_credentials=None, resource_requirements=None, secrets=None, start_timeout=None, stop_timeout=None, system_controls=None, ulimits=None, user=None, volumes_from=None, working_directory=None)
Bases:
objectThe
ContainerDefinitionproperty specifies a container definition.Container definitions are used in task definitions to describe the different containers that are launched as part of a task.
- Parameters:
image (
str) – The image used to start a container. This string is passed directly to the Docker daemon. By default, images in the Docker Hub registry are available. Other repositories are specified with either*repository-url* / *image* : *tag*or*repository-url* / *image* @ *digest*. Up to 255 letters (uppercase and lowercase), numbers, hyphens, underscores, colons, periods, forward slashes, and number signs are allowed. This parameter maps toImagein the Create a container section of the Docker Remote API and theIMAGEparameter of docker run . - When a new task starts, the Amazon ECS container agent pulls the latest version of the specified image and tag for the container to use. However, subsequent updates to a repository image aren’t propagated to already running tasks. - Images in Amazon ECR repositories can be specified by either using the fullregistry/repository:tagorregistry/repository@digest. For example,012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>:latestor012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>@sha256:94afd1f2e64d908bc90dbca0035a5b567EXAMPLE. - Images in official repositories on Docker Hub use a single name (for example,ubuntuormongo). - Images in other repositories on Docker Hub are qualified with an organization name (for example,amazon/amazon-ecs-agent). - Images in other online repositories are qualified further by a domain name (for example,quay.io/assemblyline/ubuntu).name (
str) –The name of a container. If you’re linking multiple containers together in a task definition, the
nameof one container can be entered in thelinksof another container to connect the containers. Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed. This parameter maps tonamein the Create a container section of the Docker Remote API and the--nameoption to docker run .command (
Optional[Sequence[str]]) –The command that’s passed to the container. This parameter maps to
Cmdin the Create a container section of the Docker Remote API and theCOMMANDparameter to docker run . For more information, see https://docs.docker.com/engine/reference/builder/#cmd . If there are multiple arguments, each argument is a separated string in the array.cpu (
Union[int,float,None]) –The number of
cpuunits reserved for the container. This parameter maps toCpuSharesin the Create a container section of the Docker Remote API and the--cpu-sharesoption to docker run . This field is optional for tasks using the Fargate launch type, and the only requirement is that the total amount of CPU reserved for all containers within a task be lower than the task-levelcpuvalue. .. epigraph:: You can determine the number of CPU units that are available per EC2 instance type by multiplying the vCPUs listed for that instance type on the Amazon EC2 Instances detail page by 1,024. Linux containers share unallocated CPU units with other containers on the container instance with the same ratio as their allocated amount. For example, if you run a single-container task on a single-core instance type with 512 CPU units specified for that container, and that’s the only task running on the container instance, that container could use the full 1,024 CPU unit share at any given time. However, if you launched another copy of the same task on that container instance, each task is guaranteed a minimum of 512 CPU units when needed. Moreover, each container could float to higher CPU usage if the other container was not using it. If both tasks were 100% active all of the time, they would be limited to 512 CPU units. On Linux container instances, the Docker daemon on the container instance uses the CPU value to calculate the relative CPU share ratios for running containers. For more information, see CPU share constraint in the Docker documentation. The minimum valid CPU share value that the Linux kernel allows is 2. However, the CPU parameter isn’t required, and you can use CPU values below 2 in your container definitions. For CPU values below 2 (including null), the behavior varies based on your Amazon ECS container agent version: - Agent versions less than or equal to 1.1.0: Null and zero CPU values are passed to Docker as 0, which Docker then converts to 1,024 CPU shares. CPU values of 1 are passed to Docker as 1, which the Linux kernel converts to two CPU shares. - Agent versions greater than or equal to 1.2.0: Null, zero, and CPU values of 1 are passed to Docker as 2. On Windows container instances, the CPU limit is enforced as an absolute limit, or a quota. Windows containers only have access to the specified amount of CPU that’s described in the task definition. A null or zero CPU value is passed to Docker as0, which Windows interprets as 1% of one CPU.depends_on (
Union[IResolvable,Sequence[Union[IResolvable,ContainerDependencyProperty,Dict[str,Any]]],None]) –The dependencies defined for container startup and shutdown. A container can contain multiple dependencies. When a dependency is defined for container startup, for container shutdown it is reversed. For tasks using the EC2 launch type, the container instances require at least version 1.26.0 of the container agent to turn on container dependencies. However, we recommend using the latest container agent version. For information about checking your agent version and updating to the latest version, see Updating the Amazon ECS Container Agent in the Amazon Elastic Container Service Developer Guide . If you’re using an Amazon ECS-optimized Linux AMI, your instance needs at least version 1.26.0-1 of the
ecs-initpackage. If your container instances are launched from version20190301or later, then they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide . For tasks using the Fargate launch type, the task or service requires the following platforms: - Linux platform version1.3.0or later. - Windows platform version1.0.0or later. If the task definition is used in a blue/green deployment that uses AWS::CodeDeploy::DeploymentGroup BlueGreenDeploymentConfiguration , thedependsOnparameter is not supported. For more information see Issue #680 on the on the GitHub website.disable_networking (
Union[bool,IResolvable,None]) –When this parameter is true, networking is off within the container. This parameter maps to
NetworkDisabledin the Create a container section of the Docker Remote API . .. epigraph:: This parameter is not supported for Windows containers.dns_search_domains (
Optional[Sequence[str]]) –A list of DNS search domains that are presented to the container. This parameter maps to
DnsSearchin the Create a container section of the Docker Remote API and the--dns-searchoption to docker run . .. epigraph:: This parameter is not supported for Windows containers.dns_servers (
Optional[Sequence[str]]) –A list of DNS servers that are presented to the container. This parameter maps to
Dnsin the Create a container section of the Docker Remote API and the--dnsoption to docker run . .. epigraph:: This parameter is not supported for Windows containers.docker_labels (
Union[IResolvable,Mapping[str,str],None]) –A key/value map of labels to add to the container. This parameter maps to
Labelsin the Create a container section of the Docker Remote API and the--labeloption to docker run . This parameter requires version 1.18 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:sudo docker version --format '{{.Server.APIVersion}}'docker_security_options (
Optional[Sequence[str]]) –A list of strings to provide custom configuration for multiple security systems. For more information about valid values, see Docker Run Security Configuration . This field isn’t valid for containers in tasks using the Fargate launch type. For Linux tasks on EC2, this parameter can be used to reference custom labels for SELinux and AppArmor multi-level security systems. For any tasks on EC2, this parameter can be used to reference a credential spec file that configures a container for Active Directory authentication. For more information, see Using gMSAs for Windows Containers and Using gMSAs for Linux Containers in the Amazon Elastic Container Service Developer Guide . This parameter maps to
SecurityOptin the Create a container section of the Docker Remote API and the--security-optoption to docker run . .. epigraph:: The Amazon ECS container agent running on a container instance must register with theECS_SELINUX_CAPABLE=trueorECS_APPARMOR_CAPABLE=trueenvironment variables before containers placed on that instance can use these security options. For more information, see Amazon ECS Container Agent Configuration in the Amazon Elastic Container Service Developer Guide . For more information about valid values, see Docker Run Security Configuration . Valid values: “no-new-privileges” | “apparmor:PROFILE” | “label:value” | “credentialspec:CredentialSpecFilePath”entry_point (
Optional[Sequence[str]]) –Early versions of the Amazon ECS container agent don’t properly handle
entryPointparameters. If you have problems usingentryPoint, update your container agent or enter your commands and arguments ascommandarray items instead. The entry point that’s passed to the container. This parameter maps toEntrypointin the Create a container section of the Docker Remote API and the--entrypointoption to docker run . For more information, see https://docs.docker.com/engine/reference/builder/#entrypoint .environment (
Union[IResolvable,Sequence[Union[IResolvable,KeyValuePairProperty,Dict[str,Any]]],None]) –The environment variables to pass to a container. This parameter maps to
Envin the Create a container section of the Docker Remote API and the--envoption to docker run . .. epigraph:: We don’t recommend that you use plaintext environment variables for sensitive information, such as credential data.environment_files (
Union[IResolvable,Sequence[Union[IResolvable,EnvironmentFileProperty,Dict[str,Any]]],None]) –A list of files containing the environment variables to pass to a container. This parameter maps to the
--env-fileoption to docker run . You can specify up to ten environment files. The file must have a.envfile extension. Each line in an environment file contains an environment variable inVARIABLE=VALUEformat. Lines beginning with#are treated as comments and are ignored. For more information about the environment variable file syntax, see Declare default environment variables in file . If there are environment variables specified using theenvironmentparameter in a container definition, they take precedence over the variables contained within an environment file. If multiple environment files are specified that contain the same variable, they’re processed from the top down. We recommend that you use unique variable names. For more information, see Specifying Environment Variables in the Amazon Elastic Container Service Developer Guide .essential (
Union[bool,IResolvable,None]) – If theessentialparameter of a container is marked astrue, and that container fails or stops for any reason, all other containers that are part of the task are stopped. If theessentialparameter of a container is marked asfalse, its failure doesn’t affect the rest of the containers in a task. If this parameter is omitted, a container is assumed to be essential. All tasks must have at least one essential container. If you have an application that’s composed of multiple containers, group containers that are used for a common purpose into components, and separate the different components into multiple task definitions. For more information, see Application Architecture in the Amazon Elastic Container Service Developer Guide .extra_hosts (
Union[IResolvable,Sequence[Union[IResolvable,HostEntryProperty,Dict[str,Any]]],None]) –A list of hostnames and IP address mappings to append to the
/etc/hostsfile on the container. This parameter maps toExtraHostsin the Create a container section of the Docker Remote API and the--add-hostoption to docker run . .. epigraph:: This parameter isn’t supported for Windows containers or tasks that use theawsvpcnetwork mode.firelens_configuration (
Union[IResolvable,FirelensConfigurationProperty,Dict[str,Any],None]) – The FireLens configuration for the container. This is used to specify and configure a log router for container logs. For more information, see Custom Log Routing in the Amazon Elastic Container Service Developer Guide .health_check (
Union[IResolvable,HealthCheckProperty,Dict[str,Any],None]) –The container health check command and associated configuration parameters for the container. This parameter maps to
HealthCheckin the Create a container section of the Docker Remote API and theHEALTHCHECKparameter of docker run .hostname (
Optional[str]) –The hostname to use for your container. This parameter maps to
Hostnamein the Create a container section of the Docker Remote API and the--hostnameoption to docker run . .. epigraph:: Thehostnameparameter is not supported if you’re using theawsvpcnetwork mode.interactive (
Union[bool,IResolvable,None]) –When this parameter is
true, you can deploy containerized applications that requirestdinor attyto be allocated. This parameter maps toOpenStdinin the Create a container section of the Docker Remote API and the--interactiveoption to docker run .links (
Optional[Sequence[str]]) –The
linksparameter allows containers to communicate with each other without the need for port mappings. This parameter is only supported if the network mode of a task definition isbridge. Thename:internalNameconstruct is analogous toname:aliasin Docker links. Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed. For more information about linking Docker containers, go to Legacy container links in the Docker documentation. This parameter maps toLinksin the Create a container section of the Docker Remote API and the--linkoption to docker run . .. epigraph:: This parameter is not supported for Windows containers. > Containers that are collocated on a single container instance may be able to communicate with each other without requiring links or host port mappings. Network isolation is achieved on the container instance using security groups and VPC settings.linux_parameters (
Union[LinuxParametersProperty,Dict[str,Any],IResolvable,None]) – Linux-specific modifications that are applied to the container, such as Linux kernel capabilities. For more information see KernelCapabilities . .. epigraph:: This parameter is not supported for Windows containers.log_configuration (
Union[IResolvable,LogConfigurationProperty,Dict[str,Any],None]) –The log configuration specification for the container. This parameter maps to
LogConfigin the Create a container section of the Docker Remote API and the--log-driveroption to docker run . By default, containers use the same logging driver that the Docker daemon uses. However, the container may use a different logging driver than the Docker daemon by specifying a log driver with this parameter in the container definition. To use a different logging driver for a container, the log system must be configured properly on the container instance (or on a different log server for remote logging options). For more information on the options for different supported log drivers, see Configure logging drivers in the Docker documentation. .. epigraph:: Amazon ECS currently supports a subset of the logging drivers available to the Docker daemon (shown in the LogConfiguration data type). Additional log drivers may be available in future releases of the Amazon ECS container agent. This parameter requires version 1.18 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:sudo docker version --format '{{.Server.APIVersion}}'.. epigraph:: The Amazon ECS container agent running on a container instance must register the logging drivers available on that instance with theECS_AVAILABLE_LOGGING_DRIVERSenvironment variable before containers placed on that instance can use these log configuration options. For more information, see Amazon ECS Container Agent Configuration in the Amazon Elastic Container Service Developer Guide .memory (
Union[int,float,None]) –The amount (in MiB) of memory to present to the container. If your container attempts to exceed the memory specified here, the container is killed. The total amount of memory reserved for all containers within a task must be lower than the task
memoryvalue, if one is specified. This parameter maps toMemoryin the Create a container section of the Docker Remote API and the--memoryoption to docker run . If using the Fargate launch type, this parameter is optional. If using the EC2 launch type, you must specify either a task-level memory value or a container-level memory value. If you specify both a container-levelmemoryandmemoryReservationvalue,memorymust be greater thanmemoryReservation. If you specifymemoryReservation, then that value is subtracted from the available memory resources for the container instance where the container is placed. Otherwise, the value ofmemoryis used. The Docker 20.10.0 or later daemon reserves a minimum of 6 MiB of memory for a container, so you should not specify fewer than 6 MiB of memory for your containers. The Docker 19.03.13-ce or earlier daemon reserves a minimum of 4 MiB of memory for a container, so you should not specify fewer than 4 MiB of memory for your containers.memory_reservation (
Union[int,float,None]) –The soft limit (in MiB) of memory to reserve for the container. When system memory is under heavy contention, Docker attempts to keep the container memory to this soft limit. However, your container can consume more memory when it needs to, up to either the hard limit specified with the
memoryparameter (if applicable), or all of the available memory on the container instance, whichever comes first. This parameter maps toMemoryReservationin the Create a container section of the Docker Remote API and the--memory-reservationoption to docker run . If a task-level memory value is not specified, you must specify a non-zero integer for one or both ofmemoryormemoryReservationin a container definition. If you specify both,memorymust be greater thanmemoryReservation. If you specifymemoryReservation, then that value is subtracted from the available memory resources for the container instance where the container is placed. Otherwise, the value ofmemoryis used. For example, if your container normally uses 128 MiB of memory, but occasionally bursts to 256 MiB of memory for short periods of time, you can set amemoryReservationof 128 MiB, and amemoryhard limit of 300 MiB. This configuration would allow the container to only reserve 128 MiB of memory from the remaining resources on the container instance, but also allow the container to consume more memory resources when needed. The Docker 20.10.0 or later daemon reserves a minimum of 6 MiB of memory for a container. So, don’t specify less than 6 MiB of memory for your containers. The Docker 19.03.13-ce or earlier daemon reserves a minimum of 4 MiB of memory for a container. So, don’t specify less than 4 MiB of memory for your containers.mount_points (
Union[IResolvable,Sequence[Union[IResolvable,MountPointProperty,Dict[str,Any]]],None]) –The mount points for data volumes in your container. This parameter maps to
Volumesin the Create a container section of the Docker Remote API and the--volumeoption to docker run . Windows containers can mount whole directories on the same drive as$env:ProgramData. Windows containers can’t mount directories on a different drive, and mount point can’t be across drives.port_mappings (
Union[IResolvable,Sequence[Union[IResolvable,PortMappingProperty,Dict[str,Any]]],None]) –The list of port mappings for the container. Port mappings allow containers to access ports on the host container instance to send or receive traffic. For task definitions that use the
awsvpcnetwork mode, you should only specify thecontainerPort. ThehostPortcan be left blank or it must be the same value as thecontainerPort. Port mappings on Windows use theNetNATgateway address rather thanlocalhost. There is no loopback for port mappings on Windows, so you cannot access a container’s mapped port from the host itself. This parameter maps toPortBindingsin the Create a container section of the Docker Remote API and the--publishoption to docker run . If the network mode of a task definition is set tonone, then you can’t specify port mappings. If the network mode of a task definition is set tohost, then host ports must either be undefined or they must match the container port in the port mapping. .. epigraph:: After a task reaches theRUNNINGstatus, manual and automatic host and container port assignments are visible in the Network Bindings section of a container description for a selected task in the Amazon ECS console. The assignments are also visible in thenetworkBindingssection DescribeTasks responses.privileged (
Union[bool,IResolvable,None]) –When this parameter is true, the container is given elevated privileges on the host container instance (similar to the
rootuser). This parameter maps toPrivilegedin the Create a container section of the Docker Remote API and the--privilegedoption to docker run . .. epigraph:: This parameter is not supported for Windows containers or tasks run on AWS Fargate .pseudo_terminal (
Union[bool,IResolvable,None]) –When this parameter is
true, a TTY is allocated. This parameter maps toTtyin the Create a container section of the Docker Remote API and the--ttyoption to docker run .readonly_root_filesystem (
Union[bool,IResolvable,None]) –When this parameter is true, the container is given read-only access to its root file system. This parameter maps to
ReadonlyRootfsin the Create a container section of the Docker Remote API and the--read-onlyoption to docker run . .. epigraph:: This parameter is not supported for Windows containers.repository_credentials (
Union[RepositoryCredentialsProperty,Dict[str,Any],IResolvable,None]) – The private repository authentication credentials to use.resource_requirements (
Union[IResolvable,Sequence[Union[IResolvable,ResourceRequirementProperty,Dict[str,Any]]],None]) – The type and amount of a resource to assign to a container. The only supported resource is a GPU.secrets (
Union[IResolvable,Sequence[Union[SecretProperty,Dict[str,Any],IResolvable]],None]) – The secrets to pass to the container. For more information, see Specifying Sensitive Data in the Amazon Elastic Container Service Developer Guide .start_timeout (
Union[int,float,None]) –Time duration (in seconds) to wait before giving up on resolving dependencies for a container. For example, you specify two containers in a task definition with containerA having a dependency on containerB reaching a
COMPLETE,SUCCESS, orHEALTHYstatus. If astartTimeoutvalue is specified for containerB and it doesn’t reach the desired status within that time then containerA gives up and not start. This results in the task transitioning to aSTOPPEDstate. .. epigraph:: When theECS_CONTAINER_START_TIMEOUTcontainer agent configuration variable is used, it’s enforced independently from this start timeout value. For tasks using the Fargate launch type, the task or service requires the following platforms: - Linux platform version1.3.0or later. - Windows platform version1.0.0or later. For tasks using the EC2 launch type, your container instances require at least version1.26.0of the container agent to use a container start timeout value. However, we recommend using the latest container agent version. For information about checking your agent version and updating to the latest version, see Updating the Amazon ECS Container Agent in the Amazon Elastic Container Service Developer Guide . If you’re using an Amazon ECS-optimized Linux AMI, your instance needs at least version1.26.0-1of theecs-initpackage. If your container instances are launched from version20190301or later, then they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .stop_timeout (
Union[int,float,None]) –Time duration (in seconds) to wait before the container is forcefully killed if it doesn’t exit normally on its own. For tasks using the Fargate launch type, the task or service requires the following platforms: - Linux platform version
1.3.0or later. - Windows platform version1.0.0or later. The max stop timeout value is 120 seconds and if the parameter is not specified, the default value of 30 seconds is used. For tasks that use the EC2 launch type, if thestopTimeoutparameter isn’t specified, the value set for the Amazon ECS container agent configuration variableECS_CONTAINER_STOP_TIMEOUTis used. If neither thestopTimeoutparameter or theECS_CONTAINER_STOP_TIMEOUTagent configuration variable are set, then the default values of 30 seconds for Linux containers and 30 seconds on Windows containers are used. Your container instances require at least version 1.26.0 of the container agent to use a container stop timeout value. However, we recommend using the latest container agent version. For information about checking your agent version and updating to the latest version, see Updating the Amazon ECS Container Agent in the Amazon Elastic Container Service Developer Guide . If you’re using an Amazon ECS-optimized Linux AMI, your instance needs at least version 1.26.0-1 of theecs-initpackage. If your container instances are launched from version20190301or later, then they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .system_controls (
Union[IResolvable,Sequence[Union[IResolvable,SystemControlProperty,Dict[str,Any]]],None]) –A list of namespaced kernel parameters to set in the container. This parameter maps to
Sysctlsin the Create a container section of the Docker Remote API and the--sysctloption to docker run . .. epigraph:: We don’t recommended that you specify network-relatedsystemControlsparameters for multiple containers in a single task that also uses either theawsvpcorhostnetwork modes. For tasks that use theawsvpcnetwork mode, the container that’s started last determines whichsystemControlsparameters take effect. For tasks that use thehostnetwork mode, it changes the container instance’s namespaced kernel parameters as well as the containers.ulimits (
Union[IResolvable,Sequence[Union[IResolvable,UlimitProperty,Dict[str,Any]]],None]) –A list of
ulimitsto set in the container. This parameter maps toUlimitsin the Create a container section of the Docker Remote API and the--ulimitoption to docker run . Valid naming values are displayed in the Ulimit data type. This parameter requires version 1.18 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:sudo docker version --format '{{.Server.APIVersion}}'.. epigraph:: This parameter is not supported for Windows containers.user (
Optional[str]) –The user to use inside the container. This parameter maps to
Userin the Create a container section of the Docker Remote API and the--useroption to docker run . .. epigraph:: When running tasks using thehostnetwork mode, don’t run containers using the root user (UID 0). We recommend using a non-root user for better security. You can specify theuserusing the following formats. If specifying a UID or GID, you must specify it as a positive integer. -user-user:group-uid-uid:gid-user:gid-uid:group.. epigraph:: This parameter is not supported for Windows containers.volumes_from (
Union[IResolvable,Sequence[Union[IResolvable,VolumeFromProperty,Dict[str,Any]]],None]) –Data volumes to mount from another container. This parameter maps to
VolumesFromin the Create a container section of the Docker Remote API and the--volumes-fromoption to docker run .working_directory (
Optional[str]) –The working directory to run commands inside the container in. This parameter maps to
WorkingDirin the Create a container section of the Docker Remote API and the--workdiroption to docker run .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs container_definition_property = ecs.CfnTaskDefinition.ContainerDefinitionProperty( image="image", name="name", # the properties below are optional command=["command"], cpu=123, depends_on=[ecs.CfnTaskDefinition.ContainerDependencyProperty( condition="condition", container_name="containerName" )], disable_networking=False, dns_search_domains=["dnsSearchDomains"], dns_servers=["dnsServers"], docker_labels={ "docker_labels_key": "dockerLabels" }, docker_security_options=["dockerSecurityOptions"], entry_point=["entryPoint"], environment=[ecs.CfnTaskDefinition.KeyValuePairProperty( name="name", value="value" )], environment_files=[ecs.CfnTaskDefinition.EnvironmentFileProperty( type="type", value="value" )], essential=False, extra_hosts=[ecs.CfnTaskDefinition.HostEntryProperty( hostname="hostname", ip_address="ipAddress" )], firelens_configuration=ecs.CfnTaskDefinition.FirelensConfigurationProperty( options={ "options_key": "options" }, type="type" ), health_check=ecs.CfnTaskDefinition.HealthCheckProperty( command=["command"], interval=123, retries=123, start_period=123, timeout=123 ), hostname="hostname", interactive=False, links=["links"], linux_parameters=ecs.CfnTaskDefinition.LinuxParametersProperty( capabilities=ecs.CfnTaskDefinition.KernelCapabilitiesProperty( add=["add"], drop=["drop"] ), devices=[ecs.CfnTaskDefinition.DeviceProperty( container_path="containerPath", host_path="hostPath", permissions=["permissions"] )], init_process_enabled=False, max_swap=123, shared_memory_size=123, swappiness=123, tmpfs=[ecs.CfnTaskDefinition.TmpfsProperty( size=123, # the properties below are optional container_path="containerPath", mount_options=["mountOptions"] )] ), log_configuration=ecs.CfnTaskDefinition.LogConfigurationProperty( log_driver="logDriver", # the properties below are optional options={ "options_key": "options" }, secret_options=[ecs.CfnTaskDefinition.SecretProperty( name="name", value_from="valueFrom" )] ), memory=123, memory_reservation=123, mount_points=[ecs.CfnTaskDefinition.MountPointProperty( container_path="containerPath", read_only=False, source_volume="sourceVolume" )], port_mappings=[ecs.CfnTaskDefinition.PortMappingProperty( app_protocol="appProtocol", container_port=123, container_port_range="containerPortRange", host_port=123, name="name", protocol="protocol" )], privileged=False, pseudo_terminal=False, readonly_root_filesystem=False, repository_credentials=ecs.CfnTaskDefinition.RepositoryCredentialsProperty( credentials_parameter="credentialsParameter" ), resource_requirements=[ecs.CfnTaskDefinition.ResourceRequirementProperty( type="type", value="value" )], secrets=[ecs.CfnTaskDefinition.SecretProperty( name="name", value_from="valueFrom" )], start_timeout=123, stop_timeout=123, system_controls=[ecs.CfnTaskDefinition.SystemControlProperty( namespace="namespace", value="value" )], ulimits=[ecs.CfnTaskDefinition.UlimitProperty( hard_limit=123, name="name", soft_limit=123 )], user="user", volumes_from=[ecs.CfnTaskDefinition.VolumeFromProperty( read_only=False, source_container="sourceContainer" )], working_directory="workingDirectory" )
Attributes
- command
The command that’s passed to the container.
This parameter maps to
Cmdin the Create a container section of the Docker Remote API and theCOMMANDparameter to docker run . For more information, see https://docs.docker.com/engine/reference/builder/#cmd . If there are multiple arguments, each argument is a separated string in the array.
- cpu
The number of
cpuunits reserved for the container.This parameter maps to
CpuSharesin the Create a container section of the Docker Remote API and the--cpu-sharesoption to docker run .This field is optional for tasks using the Fargate launch type, and the only requirement is that the total amount of CPU reserved for all containers within a task be lower than the task-level
cpuvalue. .. epigraph:You can determine the number of CPU units that are available per EC2 instance type by multiplying the vCPUs listed for that instance type on the `Amazon EC2 Instances <https://docs.aws.amazon.com/ec2/instance-types/>`_ detail page by 1,024.
Linux containers share unallocated CPU units with other containers on the container instance with the same ratio as their allocated amount. For example, if you run a single-container task on a single-core instance type with 512 CPU units specified for that container, and that’s the only task running on the container instance, that container could use the full 1,024 CPU unit share at any given time. However, if you launched another copy of the same task on that container instance, each task is guaranteed a minimum of 512 CPU units when needed. Moreover, each container could float to higher CPU usage if the other container was not using it. If both tasks were 100% active all of the time, they would be limited to 512 CPU units.
On Linux container instances, the Docker daemon on the container instance uses the CPU value to calculate the relative CPU share ratios for running containers. For more information, see CPU share constraint in the Docker documentation. The minimum valid CPU share value that the Linux kernel allows is 2. However, the CPU parameter isn’t required, and you can use CPU values below 2 in your container definitions. For CPU values below 2 (including null), the behavior varies based on your Amazon ECS container agent version:
Agent versions less than or equal to 1.1.0: Null and zero CPU values are passed to Docker as 0, which Docker then converts to 1,024 CPU shares. CPU values of 1 are passed to Docker as 1, which the Linux kernel converts to two CPU shares.
Agent versions greater than or equal to 1.2.0: Null, zero, and CPU values of 1 are passed to Docker as 2.
On Windows container instances, the CPU limit is enforced as an absolute limit, or a quota. Windows containers only have access to the specified amount of CPU that’s described in the task definition. A null or zero CPU value is passed to Docker as
0, which Windows interprets as 1% of one CPU.
- depends_on
The dependencies defined for container startup and shutdown.
A container can contain multiple dependencies. When a dependency is defined for container startup, for container shutdown it is reversed.
For tasks using the EC2 launch type, the container instances require at least version 1.26.0 of the container agent to turn on container dependencies. However, we recommend using the latest container agent version. For information about checking your agent version and updating to the latest version, see Updating the Amazon ECS Container Agent in the Amazon Elastic Container Service Developer Guide . If you’re using an Amazon ECS-optimized Linux AMI, your instance needs at least version 1.26.0-1 of the
ecs-initpackage. If your container instances are launched from version20190301or later, then they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .For tasks using the Fargate launch type, the task or service requires the following platforms:
Linux platform version
1.3.0or later.Windows platform version
1.0.0or later.
If the task definition is used in a blue/green deployment that uses AWS::CodeDeploy::DeploymentGroup BlueGreenDeploymentConfiguration , the
dependsOnparameter is not supported. For more information see Issue #680 on the on the GitHub website.
- disable_networking
When this parameter is true, networking is off within the container.
This parameter maps to
NetworkDisabledin the Create a container section of the Docker Remote API . .. epigraph:This parameter is not supported for Windows containers.
- dns_search_domains
A list of DNS search domains that are presented to the container.
This parameter maps to
DnsSearchin the Create a container section of the Docker Remote API and the--dns-searchoption to docker run . .. epigraph:This parameter is not supported for Windows containers.
- dns_servers
A list of DNS servers that are presented to the container.
This parameter maps to
Dnsin the Create a container section of the Docker Remote API and the--dnsoption to docker run . .. epigraph:This parameter is not supported for Windows containers.
- docker_labels
A key/value map of labels to add to the container.
This parameter maps to
Labelsin the Create a container section of the Docker Remote API and the--labeloption to docker run . This parameter requires version 1.18 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:sudo docker version --format '{{.Server.APIVersion}}'
- docker_security_options
A list of strings to provide custom configuration for multiple security systems.
For more information about valid values, see Docker Run Security Configuration . This field isn’t valid for containers in tasks using the Fargate launch type.
For Linux tasks on EC2, this parameter can be used to reference custom labels for SELinux and AppArmor multi-level security systems.
For any tasks on EC2, this parameter can be used to reference a credential spec file that configures a container for Active Directory authentication. For more information, see Using gMSAs for Windows Containers and Using gMSAs for Linux Containers in the Amazon Elastic Container Service Developer Guide .
This parameter maps to
SecurityOptin the Create a container section of the Docker Remote API and the--security-optoption to docker run . .. epigraph:The Amazon ECS container agent running on a container instance must register with the ``ECS_SELINUX_CAPABLE=true`` or ``ECS_APPARMOR_CAPABLE=true`` environment variables before containers placed on that instance can use these security options. For more information, see `Amazon ECS Container Agent Configuration <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html>`_ in the *Amazon Elastic Container Service Developer Guide* .
For more information about valid values, see Docker Run Security Configuration .
Valid values: “no-new-privileges” | “apparmor:PROFILE” | “label:value” | “credentialspec:CredentialSpecFilePath”
- entry_point
Early versions of the Amazon ECS container agent don’t properly handle
entryPointparameters.If you have problems using
entryPoint, update your container agent or enter your commands and arguments ascommandarray items instead.The entry point that’s passed to the container. This parameter maps to
Entrypointin the Create a container section of the Docker Remote API and the--entrypointoption to docker run . For more information, see https://docs.docker.com/engine/reference/builder/#entrypoint .
- environment
The environment variables to pass to a container.
This parameter maps to
Envin the Create a container section of the Docker Remote API and the--envoption to docker run . .. epigraph:We don't recommend that you use plaintext environment variables for sensitive information, such as credential data.
- environment_files
A list of files containing the environment variables to pass to a container.
This parameter maps to the
--env-fileoption to docker run .You can specify up to ten environment files. The file must have a
.envfile extension. Each line in an environment file contains an environment variable inVARIABLE=VALUEformat. Lines beginning with#are treated as comments and are ignored. For more information about the environment variable file syntax, see Declare default environment variables in file .If there are environment variables specified using the
environmentparameter in a container definition, they take precedence over the variables contained within an environment file. If multiple environment files are specified that contain the same variable, they’re processed from the top down. We recommend that you use unique variable names. For more information, see Specifying Environment Variables in the Amazon Elastic Container Service Developer Guide .
- essential
If the
essentialparameter of a container is marked astrue, and that container fails or stops for any reason, all other containers that are part of the task are stopped.If the
essentialparameter of a container is marked asfalse, its failure doesn’t affect the rest of the containers in a task. If this parameter is omitted, a container is assumed to be essential.All tasks must have at least one essential container. If you have an application that’s composed of multiple containers, group containers that are used for a common purpose into components, and separate the different components into multiple task definitions. For more information, see Application Architecture in the Amazon Elastic Container Service Developer Guide .
- extra_hosts
A list of hostnames and IP address mappings to append to the
/etc/hostsfile on the container.This parameter maps to
ExtraHostsin the Create a container section of the Docker Remote API and the--add-hostoption to docker run . .. epigraph:This parameter isn't supported for Windows containers or tasks that use the ``awsvpc`` network mode.
- firelens_configuration
The FireLens configuration for the container.
This is used to specify and configure a log router for container logs. For more information, see Custom Log Routing in the Amazon Elastic Container Service Developer Guide .
- health_check
The container health check command and associated configuration parameters for the container.
This parameter maps to
HealthCheckin the Create a container section of the Docker Remote API and theHEALTHCHECKparameter of docker run .
- hostname
The hostname to use for your container.
This parameter maps to
Hostnamein the Create a container section of the Docker Remote API and the--hostnameoption to docker run . .. epigraph:The ``hostname`` parameter is not supported if you're using the ``awsvpc`` network mode.
- image
The image used to start a container.
This string is passed directly to the Docker daemon. By default, images in the Docker Hub registry are available. Other repositories are specified with either
*repository-url* / *image* : *tag*or*repository-url* / *image* @ *digest*. Up to 255 letters (uppercase and lowercase), numbers, hyphens, underscores, colons, periods, forward slashes, and number signs are allowed. This parameter maps toImagein the Create a container section of the Docker Remote API and theIMAGEparameter of docker run .When a new task starts, the Amazon ECS container agent pulls the latest version of the specified image and tag for the container to use. However, subsequent updates to a repository image aren’t propagated to already running tasks.
Images in Amazon ECR repositories can be specified by either using the full
registry/repository:tagorregistry/repository@digest. For example,012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>:latestor012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>@sha256:94afd1f2e64d908bc90dbca0035a5b567EXAMPLE.Images in official repositories on Docker Hub use a single name (for example,
ubuntuormongo).Images in other repositories on Docker Hub are qualified with an organization name (for example,
amazon/amazon-ecs-agent).Images in other online repositories are qualified further by a domain name (for example,
quay.io/assemblyline/ubuntu).
- interactive
When this parameter is
true, you can deploy containerized applications that requirestdinor attyto be allocated.This parameter maps to
OpenStdinin the Create a container section of the Docker Remote API and the--interactiveoption to docker run .
- links
The
linksparameter allows containers to communicate with each other without the need for port mappings.This parameter is only supported if the network mode of a task definition is
bridge. Thename:internalNameconstruct is analogous toname:aliasin Docker links. Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed. For more information about linking Docker containers, go to Legacy container links in the Docker documentation. This parameter maps toLinksin the Create a container section of the Docker Remote API and the--linkoption to docker run . .. epigraph:This parameter is not supported for Windows containers. > Containers that are collocated on a single container instance may be able to communicate with each other without requiring links or host port mappings. Network isolation is achieved on the container instance using security groups and VPC settings.
- linux_parameters
Linux-specific modifications that are applied to the container, such as Linux kernel capabilities. For more information see KernelCapabilities .
This parameter is not supported for Windows containers.
- log_configuration
The log configuration specification for the container.
This parameter maps to
LogConfigin the Create a container section of the Docker Remote API and the--log-driveroption to docker run . By default, containers use the same logging driver that the Docker daemon uses. However, the container may use a different logging driver than the Docker daemon by specifying a log driver with this parameter in the container definition. To use a different logging driver for a container, the log system must be configured properly on the container instance (or on a different log server for remote logging options). For more information on the options for different supported log drivers, see Configure logging drivers in the Docker documentation. .. epigraph:Amazon ECS currently supports a subset of the logging drivers available to the Docker daemon (shown in the `LogConfiguration <https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html>`_ data type). Additional log drivers may be available in future releases of the Amazon ECS container agent.
This parameter requires version 1.18 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:
sudo docker version --format '{{.Server.APIVersion}}'.. epigraph:The Amazon ECS container agent running on a container instance must register the logging drivers available on that instance with the ``ECS_AVAILABLE_LOGGING_DRIVERS`` environment variable before containers placed on that instance can use these log configuration options. For more information, see `Amazon ECS Container Agent Configuration <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html>`_ in the *Amazon Elastic Container Service Developer Guide* .
- memory
The amount (in MiB) of memory to present to the container.
If your container attempts to exceed the memory specified here, the container is killed. The total amount of memory reserved for all containers within a task must be lower than the task
memoryvalue, if one is specified. This parameter maps toMemoryin the Create a container section of the Docker Remote API and the--memoryoption to docker run .If using the Fargate launch type, this parameter is optional.
If using the EC2 launch type, you must specify either a task-level memory value or a container-level memory value. If you specify both a container-level
memoryandmemoryReservationvalue,memorymust be greater thanmemoryReservation. If you specifymemoryReservation, then that value is subtracted from the available memory resources for the container instance where the container is placed. Otherwise, the value ofmemoryis used.The Docker 20.10.0 or later daemon reserves a minimum of 6 MiB of memory for a container, so you should not specify fewer than 6 MiB of memory for your containers.
The Docker 19.03.13-ce or earlier daemon reserves a minimum of 4 MiB of memory for a container, so you should not specify fewer than 4 MiB of memory for your containers.
- memory_reservation
The soft limit (in MiB) of memory to reserve for the container.
When system memory is under heavy contention, Docker attempts to keep the container memory to this soft limit. However, your container can consume more memory when it needs to, up to either the hard limit specified with the
memoryparameter (if applicable), or all of the available memory on the container instance, whichever comes first. This parameter maps toMemoryReservationin the Create a container section of the Docker Remote API and the--memory-reservationoption to docker run .If a task-level memory value is not specified, you must specify a non-zero integer for one or both of
memoryormemoryReservationin a container definition. If you specify both,memorymust be greater thanmemoryReservation. If you specifymemoryReservation, then that value is subtracted from the available memory resources for the container instance where the container is placed. Otherwise, the value ofmemoryis used.For example, if your container normally uses 128 MiB of memory, but occasionally bursts to 256 MiB of memory for short periods of time, you can set a
memoryReservationof 128 MiB, and amemoryhard limit of 300 MiB. This configuration would allow the container to only reserve 128 MiB of memory from the remaining resources on the container instance, but also allow the container to consume more memory resources when needed.The Docker 20.10.0 or later daemon reserves a minimum of 6 MiB of memory for a container. So, don’t specify less than 6 MiB of memory for your containers.
The Docker 19.03.13-ce or earlier daemon reserves a minimum of 4 MiB of memory for a container. So, don’t specify less than 4 MiB of memory for your containers.
- mount_points
The mount points for data volumes in your container.
This parameter maps to
Volumesin the Create a container section of the Docker Remote API and the--volumeoption to docker run .Windows containers can mount whole directories on the same drive as
$env:ProgramData. Windows containers can’t mount directories on a different drive, and mount point can’t be across drives.
- name
The name of a container.
If you’re linking multiple containers together in a task definition, the
nameof one container can be entered in thelinksof another container to connect the containers. Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed. This parameter maps tonamein the Create a container section of the Docker Remote API and the--nameoption to docker run .
- port_mappings
The list of port mappings for the container.
Port mappings allow containers to access ports on the host container instance to send or receive traffic.
For task definitions that use the
awsvpcnetwork mode, you should only specify thecontainerPort. ThehostPortcan be left blank or it must be the same value as thecontainerPort.Port mappings on Windows use the
NetNATgateway address rather thanlocalhost. There is no loopback for port mappings on Windows, so you cannot access a container’s mapped port from the host itself.This parameter maps to
PortBindingsin the Create a container section of the Docker Remote API and the--publishoption to docker run . If the network mode of a task definition is set tonone, then you can’t specify port mappings. If the network mode of a task definition is set tohost, then host ports must either be undefined or they must match the container port in the port mapping. .. epigraph:After a task reaches the ``RUNNING`` status, manual and automatic host and container port assignments are visible in the *Network Bindings* section of a container description for a selected task in the Amazon ECS console. The assignments are also visible in the ``networkBindings`` section `DescribeTasks <https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTasks.html>`_ responses.
- privileged
When this parameter is true, the container is given elevated privileges on the host container instance (similar to the
rootuser).This parameter maps to
Privilegedin the Create a container section of the Docker Remote API and the--privilegedoption to docker run . .. epigraph:This parameter is not supported for Windows containers or tasks run on AWS Fargate .
- pseudo_terminal
When this parameter is
true, a TTY is allocated.This parameter maps to
Ttyin the Create a container section of the Docker Remote API and the--ttyoption to docker run .
- readonly_root_filesystem
When this parameter is true, the container is given read-only access to its root file system.
This parameter maps to
ReadonlyRootfsin the Create a container section of the Docker Remote API and the--read-onlyoption to docker run . .. epigraph:This parameter is not supported for Windows containers.
- repository_credentials
The private repository authentication credentials to use.
- resource_requirements
The type and amount of a resource to assign to a container.
The only supported resource is a GPU.
- secrets
The secrets to pass to the container.
For more information, see Specifying Sensitive Data in the Amazon Elastic Container Service Developer Guide .
- start_timeout
Time duration (in seconds) to wait before giving up on resolving dependencies for a container.
For example, you specify two containers in a task definition with containerA having a dependency on containerB reaching a
COMPLETE,SUCCESS, orHEALTHYstatus. If astartTimeoutvalue is specified for containerB and it doesn’t reach the desired status within that time then containerA gives up and not start. This results in the task transitioning to aSTOPPEDstate. .. epigraph:When the ``ECS_CONTAINER_START_TIMEOUT`` container agent configuration variable is used, it's enforced independently from this start timeout value.
For tasks using the Fargate launch type, the task or service requires the following platforms:
Linux platform version
1.3.0or later.Windows platform version
1.0.0or later.
For tasks using the EC2 launch type, your container instances require at least version
1.26.0of the container agent to use a container start timeout value. However, we recommend using the latest container agent version. For information about checking your agent version and updating to the latest version, see Updating the Amazon ECS Container Agent in the Amazon Elastic Container Service Developer Guide . If you’re using an Amazon ECS-optimized Linux AMI, your instance needs at least version1.26.0-1of theecs-initpackage. If your container instances are launched from version20190301or later, then they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .
- stop_timeout
Time duration (in seconds) to wait before the container is forcefully killed if it doesn’t exit normally on its own.
For tasks using the Fargate launch type, the task or service requires the following platforms:
Linux platform version
1.3.0or later.Windows platform version
1.0.0or later.
The max stop timeout value is 120 seconds and if the parameter is not specified, the default value of 30 seconds is used.
For tasks that use the EC2 launch type, if the
stopTimeoutparameter isn’t specified, the value set for the Amazon ECS container agent configuration variableECS_CONTAINER_STOP_TIMEOUTis used. If neither thestopTimeoutparameter or theECS_CONTAINER_STOP_TIMEOUTagent configuration variable are set, then the default values of 30 seconds for Linux containers and 30 seconds on Windows containers are used. Your container instances require at least version 1.26.0 of the container agent to use a container stop timeout value. However, we recommend using the latest container agent version. For information about checking your agent version and updating to the latest version, see Updating the Amazon ECS Container Agent in the Amazon Elastic Container Service Developer Guide . If you’re using an Amazon ECS-optimized Linux AMI, your instance needs at least version 1.26.0-1 of theecs-initpackage. If your container instances are launched from version20190301or later, then they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .
- system_controls
A list of namespaced kernel parameters to set in the container.
This parameter maps to
Sysctlsin the Create a container section of the Docker Remote API and the--sysctloption to docker run . .. epigraph:We don't recommended that you specify network-related ``systemControls`` parameters for multiple containers in a single task that also uses either the ``awsvpc`` or ``host`` network modes. For tasks that use the ``awsvpc`` network mode, the container that's started last determines which ``systemControls`` parameters take effect. For tasks that use the ``host`` network mode, it changes the container instance's namespaced kernel parameters as well as the containers.
- ulimits
A list of
ulimitsto set in the container.This parameter maps to
Ulimitsin the Create a container section of the Docker Remote API and the--ulimitoption to docker run . Valid naming values are displayed in the Ulimit data type. This parameter requires version 1.18 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:sudo docker version --format '{{.Server.APIVersion}}'.. epigraph:This parameter is not supported for Windows containers.
- user
The user to use inside the container.
This parameter maps to
Userin the Create a container section of the Docker Remote API and the--useroption to docker run . .. epigraph:When running tasks using the ``host`` network mode, don't run containers using the root user (UID 0). We recommend using a non-root user for better security.
You can specify the
userusing the following formats. If specifying a UID or GID, you must specify it as a positive integer.useruser:groupuiduid:giduser:giduid:group
This parameter is not supported for Windows containers.
- volumes_from
Data volumes to mount from another container.
This parameter maps to
VolumesFromin the Create a container section of the Docker Remote API and the--volumes-fromoption to docker run .
- working_directory
The working directory to run commands inside the container in.
This parameter maps to
WorkingDirin the Create a container section of the Docker Remote API and the--workdiroption to docker run .
ContainerDependencyProperty
- class CfnTaskDefinition.ContainerDependencyProperty(*, condition=None, container_name=None)
Bases:
objectThe
ContainerDependencyproperty specifies the dependencies defined for container startup and shutdown.A container can contain multiple dependencies. When a dependency is defined for container startup, for container shutdown it is reversed.
Your Amazon ECS container instances require at least version 1.26.0 of the container agent to enable container dependencies. However, we recommend using the latest container agent version. For information about checking your agent version and updating to the latest version, see Updating the Amazon ECS Container Agent in the Amazon Elastic Container Service Developer Guide . If you are using an Amazon ECS-optimized Linux AMI, your instance needs at least version 1.26.0-1 of the
ecs-initpackage. If your container instances are launched from version20190301or later, then they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide . .. epigraph:For tasks using the Fargate launch type, this parameter requires that the task or service uses platform version 1.3.0 or later.
- Parameters:
condition (
Optional[str]) – The dependency condition of the container. The following are the available conditions and their behavior:. -START- This condition emulates the behavior of links and volumes today. It validates that a dependent container is started before permitting other containers to start. -COMPLETE- This condition validates that a dependent container runs to completion (exits) before permitting other containers to start. This can be useful for nonessential containers that run a script and then exit. This condition can’t be set on an essential container. -SUCCESS- This condition is the same asCOMPLETE, but it also requires that the container exits with azerostatus. This condition can’t be set on an essential container. -HEALTHY- This condition validates that the dependent container passes its Docker health check before permitting other containers to start. This requires that the dependent container has health checks configured. This condition is confirmed only at task startup.container_name (
Optional[str]) – The name of a container.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs container_dependency_property = ecs.CfnTaskDefinition.ContainerDependencyProperty( condition="condition", container_name="containerName" )
Attributes
- condition
.
START- This condition emulates the behavior of links and volumes today. It validates that a dependent container is started before permitting other containers to start.COMPLETE- This condition validates that a dependent container runs to completion (exits) before permitting other containers to start. This can be useful for nonessential containers that run a script and then exit. This condition can’t be set on an essential container.SUCCESS- This condition is the same asCOMPLETE, but it also requires that the container exits with azerostatus. This condition can’t be set on an essential container.HEALTHY- This condition validates that the dependent container passes its Docker health check before permitting other containers to start. This requires that the dependent container has health checks configured. This condition is confirmed only at task startup.
- Link:
- Type:
The dependency condition of the container. The following are the available conditions and their behavior
- container_name
The name of a container.
DeviceProperty
- class CfnTaskDefinition.DeviceProperty(*, container_path=None, host_path=None, permissions=None)
Bases:
objectThe
Deviceproperty specifies an object representing a container instance host device.- Parameters:
container_path (
Optional[str]) – The path inside the container at which to expose the host device.host_path (
Optional[str]) – The path for the device on the host container instance.permissions (
Optional[Sequence[str]]) – The explicit permissions to provide to the container for the device. By default, the container has permissions forread,write, andmknodfor the device.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs device_property = ecs.CfnTaskDefinition.DeviceProperty( container_path="containerPath", host_path="hostPath", permissions=["permissions"] )
Attributes
- container_path
The path inside the container at which to expose the host device.
- host_path
The path for the device on the host container instance.
- permissions
The explicit permissions to provide to the container for the device.
By default, the container has permissions for
read,write, andmknodfor the device.
DockerVolumeConfigurationProperty
- class CfnTaskDefinition.DockerVolumeConfigurationProperty(*, autoprovision=None, driver=None, driver_opts=None, labels=None, scope=None)
Bases:
objectThe
DockerVolumeConfigurationproperty specifies a Docker volume configuration and is used when you use Docker volumes.Docker volumes are only supported when you are using the EC2 launch type. Windows containers only support the use of the
localdriver. To use bind mounts, specify ahostinstead.- Parameters:
autoprovision (
Union[bool,IResolvable,None]) – If this value istrue, the Docker volume is created if it doesn’t already exist. .. epigraph:: This field is only used if thescopeisshared.driver (
Optional[str]) –The Docker volume driver to use. The driver value must match the driver name provided by Docker because it is used for task placement. If the driver was installed using the Docker plugin CLI, use
docker plugin lsto retrieve the driver name from your container instance. If the driver was installed using another method, use Docker plugin discovery to retrieve the driver name. For more information, see Docker plugin discovery . This parameter maps toDriverin the Create a volume section of the Docker Remote API and thexxdriveroption to docker volume create .driver_opts (
Union[IResolvable,Mapping[str,str],None]) –A map of Docker driver-specific options passed through. This parameter maps to
DriverOptsin the Create a volume section of the Docker Remote API and thexxoptoption to docker volume create .labels (
Union[IResolvable,Mapping[str,str],None]) –Custom metadata to add to your Docker volume. This parameter maps to
Labelsin the Create a volume section of the Docker Remote API and thexxlabeloption to docker volume create .scope (
Optional[str]) – The scope for the Docker volume that determines its lifecycle. Docker volumes that are scoped to ataskare automatically provisioned when the task starts and destroyed when the task stops. Docker volumes that are scoped assharedpersist after the task stops.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs docker_volume_configuration_property = ecs.CfnTaskDefinition.DockerVolumeConfigurationProperty( autoprovision=False, driver="driver", driver_opts={ "driver_opts_key": "driverOpts" }, labels={ "labels_key": "labels" }, scope="scope" )
Attributes
- autoprovision
If this value is
true, the Docker volume is created if it doesn’t already exist.This field is only used if the
scopeisshared.
- driver
The Docker volume driver to use.
The driver value must match the driver name provided by Docker because it is used for task placement. If the driver was installed using the Docker plugin CLI, use
docker plugin lsto retrieve the driver name from your container instance. If the driver was installed using another method, use Docker plugin discovery to retrieve the driver name. For more information, see Docker plugin discovery . This parameter maps toDriverin the Create a volume section of the Docker Remote API and thexxdriveroption to docker volume create .
- driver_opts
A map of Docker driver-specific options passed through.
This parameter maps to
DriverOptsin the Create a volume section of the Docker Remote API and thexxoptoption to docker volume create .
- labels
Custom metadata to add to your Docker volume.
This parameter maps to
Labelsin the Create a volume section of the Docker Remote API and thexxlabeloption to docker volume create .
- scope
The scope for the Docker volume that determines its lifecycle.
Docker volumes that are scoped to a
taskare automatically provisioned when the task starts and destroyed when the task stops. Docker volumes that are scoped assharedpersist after the task stops.
EFSVolumeConfigurationProperty
- class CfnTaskDefinition.EFSVolumeConfigurationProperty(*, filesystem_id, authorization_config=None, root_directory=None, transit_encryption=None, transit_encryption_port=None)
Bases:
objectThis parameter is specified when you’re using an Amazon Elastic File System file system for task storage.
For more information, see Amazon EFS volumes in the Amazon Elastic Container Service Developer Guide .
- Parameters:
filesystem_id (
str) – The Amazon EFS file system ID to use.authorization_config (
Union[IResolvable,AuthorizationConfigProperty,Dict[str,Any],None]) – The authorization configuration details for the Amazon EFS file system.root_directory (
Optional[str]) – The directory within the Amazon EFS file system to mount as the root directory inside the host. If this parameter is omitted, the root of the Amazon EFS volume will be used. Specifying/will have the same effect as omitting this parameter. .. epigraph:: If an EFS access point is specified in theauthorizationConfig, the root directory parameter must either be omitted or set to/which will enforce the path set on the EFS access point.transit_encryption (
Optional[str]) – Determines whether to use encryption for Amazon EFS data in transit between the Amazon ECS host and the Amazon EFS server. Transit encryption must be turned on if Amazon EFS IAM authorization is used. If this parameter is omitted, the default value ofDISABLEDis used. For more information, see Encrypting data in transit in the Amazon Elastic File System User Guide .transit_encryption_port (
Union[int,float,None]) – The port to use when sending encrypted data between the Amazon ECS host and the Amazon EFS server. If you do not specify a transit encryption port, it will use the port selection strategy that the Amazon EFS mount helper uses. For more information, see EFS mount helper in the Amazon Elastic File System User Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs e_fSVolume_configuration_property = ecs.CfnTaskDefinition.EFSVolumeConfigurationProperty( filesystem_id="filesystemId", # the properties below are optional authorization_config=ecs.CfnTaskDefinition.AuthorizationConfigProperty( access_point_id="accessPointId", iam="iam" ), root_directory="rootDirectory", transit_encryption="transitEncryption", transit_encryption_port=123 )
Attributes
- authorization_config
The authorization configuration details for the Amazon EFS file system.
- filesystem_id
The Amazon EFS file system ID to use.
- root_directory
The directory within the Amazon EFS file system to mount as the root directory inside the host.
If this parameter is omitted, the root of the Amazon EFS volume will be used. Specifying
/will have the same effect as omitting this parameter. .. epigraph:If an EFS access point is specified in the ``authorizationConfig`` , the root directory parameter must either be omitted or set to ``/`` which will enforce the path set on the EFS access point.
- transit_encryption
Determines whether to use encryption for Amazon EFS data in transit between the Amazon ECS host and the Amazon EFS server.
Transit encryption must be turned on if Amazon EFS IAM authorization is used. If this parameter is omitted, the default value of
DISABLEDis used. For more information, see Encrypting data in transit in the Amazon Elastic File System User Guide .
- transit_encryption_port
The port to use when sending encrypted data between the Amazon ECS host and the Amazon EFS server.
If you do not specify a transit encryption port, it will use the port selection strategy that the Amazon EFS mount helper uses. For more information, see EFS mount helper in the Amazon Elastic File System User Guide .
EnvironmentFileProperty
- class CfnTaskDefinition.EnvironmentFileProperty(*, type=None, value=None)
Bases:
objectA list of files containing the environment variables to pass to a container.
You can specify up to ten environment files. The file must have a
.envfile extension. Each line in an environment file should contain an environment variable inVARIABLE=VALUEformat. Lines beginning with#are treated as comments and are ignored. For more information about the environment variable file syntax, see Declare default environment variables in file .If there are environment variables specified using the
environmentparameter in a container definition, they take precedence over the variables contained within an environment file. If multiple environment files are specified that contain the same variable, they’re processed from the top down. We recommend that you use unique variable names. For more information, see Specifying environment variables in the Amazon Elastic Container Service Developer Guide .This parameter is only supported for tasks hosted on Fargate using the following platform versions:
Linux platform version
1.4.0or later.Windows platform version
1.0.0or later.
- Parameters:
type (
Optional[str]) – The file type to use. The only supported value iss3.value (
Optional[str]) – The Amazon Resource Name (ARN) of the Amazon S3 object containing the environment variable file.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs environment_file_property = ecs.CfnTaskDefinition.EnvironmentFileProperty( type="type", value="value" )
Attributes
- type
The file type to use.
The only supported value is
s3.
- value
The Amazon Resource Name (ARN) of the Amazon S3 object containing the environment variable file.
EphemeralStorageProperty
- class CfnTaskDefinition.EphemeralStorageProperty(*, size_in_gib=None)
Bases:
objectThe amount of ephemeral storage to allocate for the task.
This parameter is used to expand the total amount of ephemeral storage available, beyond the default amount, for tasks hosted on AWS Fargate . For more information, see Fargate task storage in the Amazon ECS User Guide for AWS Fargate . .. epigraph:
For tasks using the Fargate launch type, the task requires the following platforms: - Linux platform version ``1.4.0`` or later. - Windows platform version ``1.0.0`` or later.
- Parameters:
size_in_gib (
Union[int,float,None]) – The total amount, in GiB, of ephemeral storage to set for the task. The minimum supported value is21GiB and the maximum supported value is200GiB.- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs ephemeral_storage_property = ecs.CfnTaskDefinition.EphemeralStorageProperty( size_in_gi_b=123 )
Attributes
- size_in_gib
The total amount, in GiB, of ephemeral storage to set for the task.
The minimum supported value is
21GiB and the maximum supported value is200GiB.
FirelensConfigurationProperty
- class CfnTaskDefinition.FirelensConfigurationProperty(*, options=None, type=None)
Bases:
objectThe FireLens configuration for the container.
This is used to specify and configure a log router for container logs. For more information, see Custom log routing in the Amazon Elastic Container Service Developer Guide .
- Parameters:
options (
Union[IResolvable,Mapping[str,str],None]) – The options to use when configuring the log router. This field is optional and can be used to add additional metadata, such as the task, task definition, cluster, and container instance details to the log event. If specified, valid option keys are: -enable-ecs-log-metadata, which can betrueorfalse-config-file-type, which can bes3orfile-config-file-value, which is either an S3 ARN or a file pathtype (
Optional[str]) – The log router to use. The valid values arefluentdorfluentbit.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs firelens_configuration_property = ecs.CfnTaskDefinition.FirelensConfigurationProperty( options={ "options_key": "options" }, type="type" )
Attributes
- options
The options to use when configuring the log router.
This field is optional and can be used to add additional metadata, such as the task, task definition, cluster, and container instance details to the log event.
If specified, valid option keys are:
enable-ecs-log-metadata, which can betrueorfalseconfig-file-type, which can bes3orfileconfig-file-value, which is either an S3 ARN or a file path
- type
The log router to use.
The valid values are
fluentdorfluentbit.
HealthCheckProperty
- class CfnTaskDefinition.HealthCheckProperty(*, command=None, interval=None, retries=None, start_period=None, timeout=None)
Bases:
objectThe
HealthCheckproperty specifies an object representing a container health check.Health check parameters that are specified in a container definition override any Docker health checks that exist in the container image (such as those specified in a parent image or from the image’s Dockerfile). This configuration maps to the
HEALTHCHECKparameter of docker run . .. epigraph:The Amazon ECS container agent only monitors and reports on the health checks specified in the task definition. Amazon ECS does not monitor Docker health checks that are embedded in a container image and not specified in the container definition. Health check parameters that are specified in a container definition override any Docker health checks that exist in the container image.
If a task is run manually, and not as part of a service, the task will continue its lifecycle regardless of its health status. For tasks that are part of a service, if the task reports as unhealthy then the task will be stopped and the service scheduler will replace it.
The following are notes about container health check support:
Container health checks require version 1.17.0 or greater of the Amazon ECS container agent. For more information, see Updating the Amazon ECS Container Agent .
Container health checks are supported for Fargate tasks if you are using platform version 1.1.0 or greater. For more information, see AWS Fargate Platform Versions .
Container health checks are not supported for tasks that are part of a service that is configured to use a Classic Load Balancer.
- Parameters:
command (
Optional[Sequence[str]]) –A string array representing the command that the container runs to determine if it is healthy. The string array must start with
CMDto run the command arguments directly, orCMD-SHELLto run the command with the container’s default shell. When you use the AWS Management Console JSON panel, the AWS Command Line Interface , or the APIs, enclose the list of commands in double quotes and brackets.[ "CMD-SHELL", "curl -f http://localhost/ || exit 1" ]You don’t include the double quotes and brackets when you use the AWS Management Console.CMD-SHELL, curl -f http://localhost/ || exit 1An exit code of 0 indicates success, and non-zero exit code indicates failure. For more information, seeHealthCheckin the Create a container section of the Docker Remote API .interval (
Union[int,float,None]) – The time period in seconds between each health check execution. You may specify between 5 and 300 seconds. The default value is 30 seconds.retries (
Union[int,float,None]) – The number of times to retry a failed health check before the container is considered unhealthy. You may specify between 1 and 10 retries. The default value is 3.start_period (
Union[int,float,None]) – The optional grace period to provide containers time to bootstrap before failed health checks count towards the maximum number of retries. You can specify between 0 and 300 seconds. By default, thestartPeriodis off. .. epigraph:: If a health check succeeds within thestartPeriod, then the container is considered healthy and any subsequent failures count toward the maximum number of retries.timeout (
Union[int,float,None]) – The time period in seconds to wait for a health check to succeed before it is considered a failure. You may specify between 2 and 60 seconds. The default value is 5.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs health_check_property = ecs.CfnTaskDefinition.HealthCheckProperty( command=["command"], interval=123, retries=123, start_period=123, timeout=123 )
Attributes
- command
A string array representing the command that the container runs to determine if it is healthy.
The string array must start with
CMDto run the command arguments directly, orCMD-SHELLto run the command with the container’s default shell.When you use the AWS Management Console JSON panel, the AWS Command Line Interface , or the APIs, enclose the list of commands in double quotes and brackets.
[ "CMD-SHELL", "curl -f http://localhost/ || exit 1" ]You don’t include the double quotes and brackets when you use the AWS Management Console.
CMD-SHELL, curl -f http://localhost/ || exit 1An exit code of 0 indicates success, and non-zero exit code indicates failure. For more information, see
HealthCheckin the Create a container section of the Docker Remote API .
- interval
The time period in seconds between each health check execution.
You may specify between 5 and 300 seconds. The default value is 30 seconds.
- retries
The number of times to retry a failed health check before the container is considered unhealthy.
You may specify between 1 and 10 retries. The default value is 3.
- start_period
The optional grace period to provide containers time to bootstrap before failed health checks count towards the maximum number of retries.
You can specify between 0 and 300 seconds. By default, the
startPeriodis off. .. epigraph:If a health check succeeds within the ``startPeriod`` , then the container is considered healthy and any subsequent failures count toward the maximum number of retries.
- timeout
The time period in seconds to wait for a health check to succeed before it is considered a failure.
You may specify between 2 and 60 seconds. The default value is 5.
HostEntryProperty
- class CfnTaskDefinition.HostEntryProperty(*, hostname=None, ip_address=None)
Bases:
objectThe
HostEntryproperty specifies a hostname and an IP address that are added to the/etc/hostsfile of a container through theextraHostsparameter of itsContainerDefinitionresource.- Parameters:
hostname (
Optional[str]) – The hostname to use in the/etc/hostsentry.ip_address (
Optional[str]) – The IP address to use in the/etc/hostsentry.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs host_entry_property = ecs.CfnTaskDefinition.HostEntryProperty( hostname="hostname", ip_address="ipAddress" )
Attributes
- hostname
The hostname to use in the
/etc/hostsentry.
- ip_address
The IP address to use in the
/etc/hostsentry.
HostVolumePropertiesProperty
- class CfnTaskDefinition.HostVolumePropertiesProperty(*, source_path=None)
Bases:
objectThe
HostVolumePropertiesproperty specifies details on a container instance bind mount host volume.- Parameters:
source_path (
Optional[str]) – When thehostparameter is used, specify asourcePathto declare the path on the host container instance that’s presented to the container. If this parameter is empty, then the Docker daemon has assigned a host path for you. If thehostparameter contains asourcePathfile location, then the data volume persists at the specified location on the host container instance until you delete it manually. If thesourcePathvalue doesn’t exist on the host container instance, the Docker daemon creates it. If the location does exist, the contents of the source path folder are exported. If you’re using the Fargate launch type, thesourcePathparameter is not supported.- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs host_volume_properties_property = ecs.CfnTaskDefinition.HostVolumePropertiesProperty( source_path="sourcePath" )
Attributes
- source_path
When the
hostparameter is used, specify asourcePathto declare the path on the host container instance that’s presented to the container.If this parameter is empty, then the Docker daemon has assigned a host path for you. If the
hostparameter contains asourcePathfile location, then the data volume persists at the specified location on the host container instance until you delete it manually. If thesourcePathvalue doesn’t exist on the host container instance, the Docker daemon creates it. If the location does exist, the contents of the source path folder are exported.If you’re using the Fargate launch type, the
sourcePathparameter is not supported.
InferenceAcceleratorProperty
- class CfnTaskDefinition.InferenceAcceleratorProperty(*, device_name=None, device_type=None)
Bases:
objectDetails on an Elastic Inference accelerator.
For more information, see Working with Amazon Elastic Inference on Amazon ECS in the Amazon Elastic Container Service Developer Guide .
- Parameters:
device_name (
Optional[str]) – The Elastic Inference accelerator device name. ThedeviceNamemust also be referenced in a container definition as a ResourceRequirement .device_type (
Optional[str]) – The Elastic Inference accelerator type to use.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs inference_accelerator_property = ecs.CfnTaskDefinition.InferenceAcceleratorProperty( device_name="deviceName", device_type="deviceType" )
Attributes
- device_name
The Elastic Inference accelerator device name.
The
deviceNamemust also be referenced in a container definition as a ResourceRequirement .
- device_type
The Elastic Inference accelerator type to use.
KernelCapabilitiesProperty
- class CfnTaskDefinition.KernelCapabilitiesProperty(*, add=None, drop=None)
Bases:
objectThe
KernelCapabilitiesproperty specifies the Linux capabilities for the container that are added to or dropped from the default configuration that is provided by Docker.For more information on the default capabilities and the non-default available capabilities, see Runtime privilege and Linux capabilities in the Docker run reference . For more detailed information on these Linux capabilities, see the capabilities(7) Linux manual page.
- Parameters:
add (
Optional[Sequence[str]]) –The Linux capabilities for the container that have been added to the default configuration provided by Docker. This parameter maps to
CapAddin the Create a container section of the Docker Remote API and the--cap-addoption to docker run . .. epigraph:: Tasks launched on AWS Fargate only support adding theSYS_PTRACEkernel capability. Valid values:"ALL" | "AUDIT_CONTROL" | "AUDIT_WRITE" | "BLOCK_SUSPEND" | "CHOWN" | "DAC_OVERRIDE" | "DAC_READ_SEARCH" | "FOWNER" | "FSETID" | "IPC_LOCK" | "IPC_OWNER" | "KILL" | "LEASE" | "LINUX_IMMUTABLE" | "MAC_ADMIN" | "MAC_OVERRIDE" | "MKNOD" | "NET_ADMIN" | "NET_BIND_SERVICE" | "NET_BROADCAST" | "NET_RAW" | "SETFCAP" | "SETGID" | "SETPCAP" | "SETUID" | "SYS_ADMIN" | "SYS_BOOT" | "SYS_CHROOT" | "SYS_MODULE" | "SYS_NICE" | "SYS_PACCT" | "SYS_PTRACE" | "SYS_RAWIO" | "SYS_RESOURCE" | "SYS_TIME" | "SYS_TTY_CONFIG" | "SYSLOG" | "WAKE_ALARM"drop (
Optional[Sequence[str]]) –The Linux capabilities for the container that have been removed from the default configuration provided by Docker. This parameter maps to
CapDropin the Create a container section of the Docker Remote API and the--cap-dropoption to docker run . Valid values:"ALL" | "AUDIT_CONTROL" | "AUDIT_WRITE" | "BLOCK_SUSPEND" | "CHOWN" | "DAC_OVERRIDE" | "DAC_READ_SEARCH" | "FOWNER" | "FSETID" | "IPC_LOCK" | "IPC_OWNER" | "KILL" | "LEASE" | "LINUX_IMMUTABLE" | "MAC_ADMIN" | "MAC_OVERRIDE" | "MKNOD" | "NET_ADMIN" | "NET_BIND_SERVICE" | "NET_BROADCAST" | "NET_RAW" | "SETFCAP" | "SETGID" | "SETPCAP" | "SETUID" | "SYS_ADMIN" | "SYS_BOOT" | "SYS_CHROOT" | "SYS_MODULE" | "SYS_NICE" | "SYS_PACCT" | "SYS_PTRACE" | "SYS_RAWIO" | "SYS_RESOURCE" | "SYS_TIME" | "SYS_TTY_CONFIG" | "SYSLOG" | "WAKE_ALARM"
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs kernel_capabilities_property = ecs.CfnTaskDefinition.KernelCapabilitiesProperty( add=["add"], drop=["drop"] )
Attributes
- add
The Linux capabilities for the container that have been added to the default configuration provided by Docker.
This parameter maps to
CapAddin the Create a container section of the Docker Remote API and the--cap-addoption to docker run . .. epigraph:Tasks launched on AWS Fargate only support adding the ``SYS_PTRACE`` kernel capability.
Valid values:
"ALL" | "AUDIT_CONTROL" | "AUDIT_WRITE" | "BLOCK_SUSPEND" | "CHOWN" | "DAC_OVERRIDE" | "DAC_READ_SEARCH" | "FOWNER" | "FSETID" | "IPC_LOCK" | "IPC_OWNER" | "KILL" | "LEASE" | "LINUX_IMMUTABLE" | "MAC_ADMIN" | "MAC_OVERRIDE" | "MKNOD" | "NET_ADMIN" | "NET_BIND_SERVICE" | "NET_BROADCAST" | "NET_RAW" | "SETFCAP" | "SETGID" | "SETPCAP" | "SETUID" | "SYS_ADMIN" | "SYS_BOOT" | "SYS_CHROOT" | "SYS_MODULE" | "SYS_NICE" | "SYS_PACCT" | "SYS_PTRACE" | "SYS_RAWIO" | "SYS_RESOURCE" | "SYS_TIME" | "SYS_TTY_CONFIG" | "SYSLOG" | "WAKE_ALARM"
- drop
The Linux capabilities for the container that have been removed from the default configuration provided by Docker.
This parameter maps to
CapDropin the Create a container section of the Docker Remote API and the--cap-dropoption to docker run .Valid values:
"ALL" | "AUDIT_CONTROL" | "AUDIT_WRITE" | "BLOCK_SUSPEND" | "CHOWN" | "DAC_OVERRIDE" | "DAC_READ_SEARCH" | "FOWNER" | "FSETID" | "IPC_LOCK" | "IPC_OWNER" | "KILL" | "LEASE" | "LINUX_IMMUTABLE" | "MAC_ADMIN" | "MAC_OVERRIDE" | "MKNOD" | "NET_ADMIN" | "NET_BIND_SERVICE" | "NET_BROADCAST" | "NET_RAW" | "SETFCAP" | "SETGID" | "SETPCAP" | "SETUID" | "SYS_ADMIN" | "SYS_BOOT" | "SYS_CHROOT" | "SYS_MODULE" | "SYS_NICE" | "SYS_PACCT" | "SYS_PTRACE" | "SYS_RAWIO" | "SYS_RESOURCE" | "SYS_TIME" | "SYS_TTY_CONFIG" | "SYSLOG" | "WAKE_ALARM"
KeyValuePairProperty
- class CfnTaskDefinition.KeyValuePairProperty(*, name=None, value=None)
Bases:
objectA key-value pair object.
- Parameters:
name (
Optional[str]) – The name of the key-value pair. For environment variables, this is the name of the environment variable.value (
Optional[str]) – The value of the key-value pair. For environment variables, this is the value of the environment variable.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs key_value_pair_property = ecs.CfnTaskDefinition.KeyValuePairProperty( name="name", value="value" )
Attributes
- name
The name of the key-value pair.
For environment variables, this is the name of the environment variable.
- value
The value of the key-value pair.
For environment variables, this is the value of the environment variable.
LinuxParametersProperty
- class CfnTaskDefinition.LinuxParametersProperty(*, capabilities=None, devices=None, init_process_enabled=None, max_swap=None, shared_memory_size=None, swappiness=None, tmpfs=None)
Bases:
objectThe Linux-specific options that are applied to the container, such as Linux KernelCapabilities .
- Parameters:
capabilities (
Union[IResolvable,KernelCapabilitiesProperty,Dict[str,Any],None]) – The Linux capabilities for the container that are added to or dropped from the default configuration provided by Docker. .. epigraph:: For tasks that use the Fargate launch type,capabilitiesis supported for all platform versions but theaddparameter is only supported if using platform version 1.4.0 or later.devices (
Union[IResolvable,Sequence[Union[IResolvable,DeviceProperty,Dict[str,Any]]],None]) –Any host devices to expose to the container. This parameter maps to
Devicesin the Create a container section of the Docker Remote API and the--deviceoption to docker run . .. epigraph:: If you’re using tasks that use the Fargate launch type, thedevicesparameter isn’t supported.init_process_enabled (
Union[bool,IResolvable,None]) –Run an
initprocess inside the container that forwards signals and reaps processes. This parameter maps to the--initoption to docker run . This parameter requires version 1.25 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:sudo docker version --format '{{.Server.APIVersion}}'max_swap (
Union[int,float,None]) –The total amount of swap memory (in MiB) a container can use. This parameter will be translated to the
--memory-swapoption to docker run where the value would be the sum of the container memory plus themaxSwapvalue. If amaxSwapvalue of0is specified, the container will not use swap. Accepted values are0or any positive integer. If themaxSwapparameter is omitted, the container will use the swap configuration for the container instance it is running on. AmaxSwapvalue must be set for theswappinessparameter to be used. .. epigraph:: If you’re using tasks that use the Fargate launch type, themaxSwapparameter isn’t supported. If you’re using tasks on Amazon Linux 2023 theswappinessparameter isn’t supported.shared_memory_size (
Union[int,float,None]) –The value for the size (in MiB) of the
/dev/shmvolume. This parameter maps to the--shm-sizeoption to docker run . .. epigraph:: If you are using tasks that use the Fargate launch type, thesharedMemorySizeparameter is not supported.swappiness (
Union[int,float,None]) –This allows you to tune a container’s memory swappiness behavior. A
swappinessvalue of0will cause swapping to not happen unless absolutely necessary. Aswappinessvalue of100will cause pages to be swapped very aggressively. Accepted values are whole numbers between0and100. If theswappinessparameter is not specified, a default value of60is used. If a value is not specified formaxSwapthen this parameter is ignored. This parameter maps to the--memory-swappinessoption to docker run . .. epigraph:: If you’re using tasks that use the Fargate launch type, theswappinessparameter isn’t supported. If you’re using tasks on Amazon Linux 2023 theswappinessparameter isn’t supported.tmpfs (
Union[IResolvable,Sequence[Union[IResolvable,TmpfsProperty,Dict[str,Any]]],None]) –The container path, mount options, and size (in MiB) of the tmpfs mount. This parameter maps to the
--tmpfsoption to docker run . .. epigraph:: If you’re using tasks that use the Fargate launch type, thetmpfsparameter isn’t supported.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs linux_parameters_property = ecs.CfnTaskDefinition.LinuxParametersProperty( capabilities=ecs.CfnTaskDefinition.KernelCapabilitiesProperty( add=["add"], drop=["drop"] ), devices=[ecs.CfnTaskDefinition.DeviceProperty( container_path="containerPath", host_path="hostPath", permissions=["permissions"] )], init_process_enabled=False, max_swap=123, shared_memory_size=123, swappiness=123, tmpfs=[ecs.CfnTaskDefinition.TmpfsProperty( size=123, # the properties below are optional container_path="containerPath", mount_options=["mountOptions"] )] )
Attributes
- capabilities
The Linux capabilities for the container that are added to or dropped from the default configuration provided by Docker.
For tasks that use the Fargate launch type,
capabilitiesis supported for all platform versions but theaddparameter is only supported if using platform version 1.4.0 or later.
- devices
Any host devices to expose to the container.
This parameter maps to
Devicesin the Create a container section of the Docker Remote API and the--deviceoption to docker run . .. epigraph:If you're using tasks that use the Fargate launch type, the ``devices`` parameter isn't supported.
- init_process_enabled
Run an
initprocess inside the container that forwards signals and reaps processes.This parameter maps to the
--initoption to docker run . This parameter requires version 1.25 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:sudo docker version --format '{{.Server.APIVersion}}'
- max_swap
The total amount of swap memory (in MiB) a container can use.
This parameter will be translated to the
--memory-swapoption to docker run where the value would be the sum of the container memory plus themaxSwapvalue.If a
maxSwapvalue of0is specified, the container will not use swap. Accepted values are0or any positive integer. If themaxSwapparameter is omitted, the container will use the swap configuration for the container instance it is running on. AmaxSwapvalue must be set for theswappinessparameter to be used. .. epigraph:If you're using tasks that use the Fargate launch type, the ``maxSwap`` parameter isn't supported. If you're using tasks on Amazon Linux 2023 the ``swappiness`` parameter isn't supported.
The value for the size (in MiB) of the
/dev/shmvolume.This parameter maps to the
--shm-sizeoption to docker run . .. epigraph:If you are using tasks that use the Fargate launch type, the ``sharedMemorySize`` parameter is not supported.
- swappiness
This allows you to tune a container’s memory swappiness behavior.
A
swappinessvalue of0will cause swapping to not happen unless absolutely necessary. Aswappinessvalue of100will cause pages to be swapped very aggressively. Accepted values are whole numbers between0and100. If theswappinessparameter is not specified, a default value of60is used. If a value is not specified formaxSwapthen this parameter is ignored. This parameter maps to the--memory-swappinessoption to docker run . .. epigraph:If you're using tasks that use the Fargate launch type, the ``swappiness`` parameter isn't supported. If you're using tasks on Amazon Linux 2023 the ``swappiness`` parameter isn't supported.
- tmpfs
The container path, mount options, and size (in MiB) of the tmpfs mount.
This parameter maps to the
--tmpfsoption to docker run . .. epigraph:If you're using tasks that use the Fargate launch type, the ``tmpfs`` parameter isn't supported.
LogConfigurationProperty
- class CfnTaskDefinition.LogConfigurationProperty(*, log_driver, options=None, secret_options=None)
Bases:
objectThe
LogConfigurationproperty specifies log configuration options to send to a custom log driver for the container.- Parameters:
log_driver (
str) –The log driver to use for the container. For tasks on AWS Fargate , the supported log drivers are
awslogs,splunk, andawsfirelens. For tasks hosted on Amazon EC2 instances, the supported log drivers areawslogs,fluentd,gelf,json-file,journald,logentries,syslog,splunk, andawsfirelens. For more information about using theawslogslog driver, see Using the awslogs log driver in the Amazon Elastic Container Service Developer Guide . For more information about using theawsfirelenslog driver, see Custom log routing in the Amazon Elastic Container Service Developer Guide . .. epigraph:: If you have a custom driver that isn’t listed, you can fork the Amazon ECS container agent project that’s available on GitHub and customize it to work with that driver. We encourage you to submit pull requests for changes that you would like to have included. However, we don’t currently provide support for running modified copies of this software.options (
Union[IResolvable,Mapping[str,str],None]) – The configuration options to send to the log driver. This parameter requires version 1.19 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:sudo docker version --format '{{.Server.APIVersion}}'secret_options (
Union[IResolvable,Sequence[Union[SecretProperty,Dict[str,Any],IResolvable]],None]) –The secrets to pass to the log configuration. For more information, see Specifying sensitive data in the Amazon Elastic Container Service Developer Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs log_configuration_property = ecs.CfnTaskDefinition.LogConfigurationProperty( log_driver="logDriver", # the properties below are optional options={ "options_key": "options" }, secret_options=[ecs.CfnTaskDefinition.SecretProperty( name="name", value_from="valueFrom" )] )
Attributes
- log_driver
The log driver to use for the container.
For tasks on AWS Fargate , the supported log drivers are
awslogs,splunk, andawsfirelens.For tasks hosted on Amazon EC2 instances, the supported log drivers are
awslogs,fluentd,gelf,json-file,journald,logentries,syslog,splunk, andawsfirelens.For more information about using the
awslogslog driver, see Using the awslogs log driver in the Amazon Elastic Container Service Developer Guide .For more information about using the
awsfirelenslog driver, see Custom log routing in the Amazon Elastic Container Service Developer Guide . .. epigraph:If you have a custom driver that isn't listed, you can fork the Amazon ECS container agent project that's `available on GitHub <https://docs.aws.amazon.com/https://github.com/aws/amazon-ecs-agent>`_ and customize it to work with that driver. We encourage you to submit pull requests for changes that you would like to have included. However, we don't currently provide support for running modified copies of this software.
- options
The configuration options to send to the log driver.
This parameter requires version 1.19 of the Docker Remote API or greater on your container instance. To check the Docker Remote API version on your container instance, log in to your container instance and run the following command:
sudo docker version --format '{{.Server.APIVersion}}'
- secret_options
The secrets to pass to the log configuration.
For more information, see Specifying sensitive data in the Amazon Elastic Container Service Developer Guide .
MountPointProperty
- class CfnTaskDefinition.MountPointProperty(*, container_path=None, read_only=None, source_volume=None)
Bases:
objectThe details for a volume mount point that’s used in a container definition.
- Parameters:
container_path (
Optional[str]) – The path on the container to mount the host volume at.read_only (
Union[bool,IResolvable,None]) – If this value istrue, the container has read-only access to the volume. If this value isfalse, then the container can write to the volume. The default value isfalse.source_volume (
Optional[str]) – The name of the volume to mount. Must be a volume name referenced in thenameparameter of task definitionvolume.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs mount_point_property = ecs.CfnTaskDefinition.MountPointProperty( container_path="containerPath", read_only=False, source_volume="sourceVolume" )
Attributes
- container_path
The path on the container to mount the host volume at.
- read_only
If this value is
true, the container has read-only access to the volume.If this value is
false, then the container can write to the volume. The default value isfalse.
- source_volume
The name of the volume to mount.
Must be a volume name referenced in the
nameparameter of task definitionvolume.
PortMappingProperty
- class CfnTaskDefinition.PortMappingProperty(*, app_protocol=None, container_port=None, container_port_range=None, host_port=None, name=None, protocol=None)
Bases:
objectThe
PortMappingproperty specifies a port mapping.Port mappings allow containers to access ports on the host container instance to send or receive traffic. Port mappings are specified as part of the container definition.
If you are using containers in a task with the
awsvpcorhostnetwork mode, exposed ports should be specified usingcontainerPort. ThehostPortcan be left blank or it must be the same value as thecontainerPort.After a task reaches the
RUNNINGstatus, manual and automatic host and container port assignments are visible in thenetworkBindingssection of DescribeTasks API responses.- Parameters:
app_protocol (
Optional[str]) – The application protocol that’s used for the port mapping. This parameter only applies to Service Connect. We recommend that you set this parameter to be consistent with the protocol that your application uses. If you set this parameter, Amazon ECS adds protocol-specific connection handling to the Service Connect proxy. If you set this parameter, Amazon ECS adds protocol-specific telemetry in the Amazon ECS console and CloudWatch. If you don’t set a value for this parameter, then TCP is used. However, Amazon ECS doesn’t add protocol-specific telemetry for TCP. Tasks that run in a namespace can use short names to connect to services in the namespace. Tasks can connect to services across all of the clusters in the namespace. Tasks connect through a managed proxy container that collects logs and metrics for increased visibility. Only the tasks that Amazon ECS services create are supported with Service Connect. For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide .container_port (
Union[int,float,None]) – The port number on the container that’s bound to the user-specified or automatically assigned host port. If you use containers in a task with theawsvpcorhostnetwork mode, specify the exposed ports usingcontainerPort. If you use containers in a task with thebridgenetwork mode and you specify a container port and not a host port, your container automatically receives a host port in the ephemeral port range. For more information, seehostPort. Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance.container_port_range (
Optional[str]) – The port number range on the container that’s bound to the dynamically mapped host port range. The following rules apply when you specify acontainerPortRange: - You must use either thebridgenetwork mode or theawsvpcnetwork mode. - This parameter is available for both the EC2 and AWS Fargate launch types. - This parameter is available for both the Linux and Windows operating systems. - The container instance must have at least version 1.67.0 of the container agent and at least version 1.67.0-1 of theecs-initpackage - You can specify a maximum of 100 port ranges per container. - You do not specify ahostPortRange. The value of thehostPortRangeis set as follows: - For containers in a task with theawsvpcnetwork mode, thehostPortis set to the same value as thecontainerPort. This is a static mapping strategy. - For containers in a task with thebridgenetwork mode, the Amazon ECS agent finds open host ports from the default ephemeral range and passes it to docker to bind them to the container ports. - ThecontainerPortRangevalid values are between 1 and 65535. - A port can only be included in one port mapping per container. - You cannot specify overlapping port ranges. - The first port in the range must be less than last port in the range. - Docker recommends that you turn off the docker-proxy in the Docker daemon config file when you have a large number of ports. For more information, see Issue #11185 on the Github website. For information about how to turn off the docker-proxy in the Docker daemon config file, see Docker daemon in the Amazon ECS Developer Guide . You can call`DescribeTasks<https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTasks.html>`_ to view thehostPortRangewhich are the host ports that are bound to the container ports.host_port (
Union[int,float,None]) – The port number on the container instance to reserve for your container. If you specify acontainerPortRange, leave this field empty and the value of thehostPortis set as follows: - For containers in a task with theawsvpcnetwork mode, thehostPortis set to the same value as thecontainerPort. This is a static mapping strategy. - For containers in a task with thebridgenetwork mode, the Amazon ECS agent finds open ports on the host and automatically binds them to the container ports. This is a dynamic mapping strategy. If you use containers in a task with theawsvpcorhostnetwork mode, thehostPortcan either be left blank or set to the same value as thecontainerPort. If you use containers in a task with thebridgenetwork mode, you can specify a non-reserved host port for your container port mapping, or you can omit thehostPort(or set it to0) while specifying acontainerPortand your container automatically receives a port in the ephemeral port range for your container instance operating system and Docker version. The default ephemeral port range for Docker version 1.6.0 and later is listed on the instance under/proc/sys/net/ipv4/ip_local_port_range. If this kernel parameter is unavailable, the default ephemeral port range from 49153 through 65535 is used. Do not attempt to specify a host port in the ephemeral port range as these are reserved for automatic assignment. In general, ports below 32768 are outside of the ephemeral port range. The default reserved ports are 22 for SSH, the Docker ports 2375 and 2376, and the Amazon ECS container agent ports 51678-51680. Any host port that was previously specified in a running task is also reserved while the task is running. That is, after a task stops, the host port is released. The current reserved ports are displayed in theremainingResourcesof DescribeContainerInstances output. A container instance can have up to 100 reserved ports at a time. This number includes the default reserved ports. Automatically assigned ports aren’t included in the 100 reserved ports quota.name (
Optional[str]) –The name that’s used for the port mapping. This parameter only applies to Service Connect. This parameter is the name that you use in the
serviceConnectConfigurationof a service. The name can include up to 64 characters. The characters can include lowercase letters, numbers, underscores (_), and hyphens (-). The name can’t start with a hyphen. For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide .protocol (
Optional[str]) – The protocol used for the port mapping. Valid values aretcpandudp. The default istcp.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs port_mapping_property = ecs.CfnTaskDefinition.PortMappingProperty( app_protocol="appProtocol", container_port=123, container_port_range="containerPortRange", host_port=123, name="name", protocol="protocol" )
Attributes
- app_protocol
The application protocol that’s used for the port mapping.
This parameter only applies to Service Connect. We recommend that you set this parameter to be consistent with the protocol that your application uses. If you set this parameter, Amazon ECS adds protocol-specific connection handling to the Service Connect proxy. If you set this parameter, Amazon ECS adds protocol-specific telemetry in the Amazon ECS console and CloudWatch.
If you don’t set a value for this parameter, then TCP is used. However, Amazon ECS doesn’t add protocol-specific telemetry for TCP.
Tasks that run in a namespace can use short names to connect to services in the namespace. Tasks can connect to services across all of the clusters in the namespace. Tasks connect through a managed proxy container that collects logs and metrics for increased visibility. Only the tasks that Amazon ECS services create are supported with Service Connect. For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide .
- container_port
The port number on the container that’s bound to the user-specified or automatically assigned host port.
If you use containers in a task with the
awsvpcorhostnetwork mode, specify the exposed ports usingcontainerPort.If you use containers in a task with the
bridgenetwork mode and you specify a container port and not a host port, your container automatically receives a host port in the ephemeral port range. For more information, seehostPort. Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance.
- container_port_range
The port number range on the container that’s bound to the dynamically mapped host port range.
The following rules apply when you specify a
containerPortRange:You must use either the
bridgenetwork mode or theawsvpcnetwork mode.This parameter is available for both the EC2 and AWS Fargate launch types.
This parameter is available for both the Linux and Windows operating systems.
The container instance must have at least version 1.67.0 of the container agent and at least version 1.67.0-1 of the
ecs-initpackageYou can specify a maximum of 100 port ranges per container.
You do not specify a
hostPortRange. The value of thehostPortRangeis set as follows:For containers in a task with the
awsvpcnetwork mode, thehostPortis set to the same value as thecontainerPort. This is a static mapping strategy.For containers in a task with the
bridgenetwork mode, the Amazon ECS agent finds open host ports from the default ephemeral range and passes it to docker to bind them to the container ports.The
containerPortRangevalid values are between 1 and 65535.A port can only be included in one port mapping per container.
You cannot specify overlapping port ranges.
The first port in the range must be less than last port in the range.
Docker recommends that you turn off the docker-proxy in the Docker daemon config file when you have a large number of ports.
For more information, see Issue #11185 on the Github website.
For information about how to turn off the docker-proxy in the Docker daemon config file, see Docker daemon in the Amazon ECS Developer Guide .
You can call
`DescribeTasks<https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTasks.html>`_ to view thehostPortRangewhich are the host ports that are bound to the container ports.
- host_port
The port number on the container instance to reserve for your container.
If you specify a
containerPortRange, leave this field empty and the value of thehostPortis set as follows:For containers in a task with the
awsvpcnetwork mode, thehostPortis set to the same value as thecontainerPort. This is a static mapping strategy.For containers in a task with the
bridgenetwork mode, the Amazon ECS agent finds open ports on the host and automatically binds them to the container ports. This is a dynamic mapping strategy.
If you use containers in a task with the
awsvpcorhostnetwork mode, thehostPortcan either be left blank or set to the same value as thecontainerPort.If you use containers in a task with the
bridgenetwork mode, you can specify a non-reserved host port for your container port mapping, or you can omit thehostPort(or set it to0) while specifying acontainerPortand your container automatically receives a port in the ephemeral port range for your container instance operating system and Docker version.The default ephemeral port range for Docker version 1.6.0 and later is listed on the instance under
/proc/sys/net/ipv4/ip_local_port_range. If this kernel parameter is unavailable, the default ephemeral port range from 49153 through 65535 is used. Do not attempt to specify a host port in the ephemeral port range as these are reserved for automatic assignment. In general, ports below 32768 are outside of the ephemeral port range.The default reserved ports are 22 for SSH, the Docker ports 2375 and 2376, and the Amazon ECS container agent ports 51678-51680. Any host port that was previously specified in a running task is also reserved while the task is running. That is, after a task stops, the host port is released. The current reserved ports are displayed in the
remainingResourcesof DescribeContainerInstances output. A container instance can have up to 100 reserved ports at a time. This number includes the default reserved ports. Automatically assigned ports aren’t included in the 100 reserved ports quota.
- name
The name that’s used for the port mapping.
This parameter only applies to Service Connect. This parameter is the name that you use in the
serviceConnectConfigurationof a service. The name can include up to 64 characters. The characters can include lowercase letters, numbers, underscores (_), and hyphens (-). The name can’t start with a hyphen.For more information, see Service Connect in the Amazon Elastic Container Service Developer Guide .
- protocol
The protocol used for the port mapping.
Valid values are
tcpandudp. The default istcp.
ProxyConfigurationProperty
- class CfnTaskDefinition.ProxyConfigurationProperty(*, container_name, proxy_configuration_properties=None, type=None)
Bases:
objectThe configuration details for the App Mesh proxy.
For tasks that use the EC2 launch type, the container instances require at least version 1.26.0 of the container agent and at least version 1.26.0-1 of the
ecs-initpackage to use a proxy configuration. If your container instances are launched from the Amazon ECS optimized AMI version20190301or later, then they contain the required versions of the container agent andecs-init. For more information, see Amazon ECS-optimized Linux AMI- Parameters:
container_name (
str) – The name of the container that will serve as the App Mesh proxy.proxy_configuration_properties (
Union[IResolvable,Sequence[Union[IResolvable,KeyValuePairProperty,Dict[str,Any]]],None]) – The set of network configuration parameters to provide the Container Network Interface (CNI) plugin, specified as key-value pairs. -IgnoredUID- (Required) The user ID (UID) of the proxy container as defined by theuserparameter in a container definition. This is used to ensure the proxy ignores its own traffic. IfIgnoredGIDis specified, this field can be empty. -IgnoredGID- (Required) The group ID (GID) of the proxy container as defined by theuserparameter in a container definition. This is used to ensure the proxy ignores its own traffic. IfIgnoredUIDis specified, this field can be empty. -AppPorts- (Required) The list of ports that the application uses. Network traffic to these ports is forwarded to theProxyIngressPortandProxyEgressPort. -ProxyIngressPort- (Required) Specifies the port that incoming traffic to theAppPortsis directed to. -ProxyEgressPort- (Required) Specifies the port that outgoing traffic from theAppPortsis directed to. -EgressIgnoredPorts- (Required) The egress traffic going to the specified ports is ignored and not redirected to theProxyEgressPort. It can be an empty list. -EgressIgnoredIPs- (Required) The egress traffic going to the specified IP addresses is ignored and not redirected to theProxyEgressPort. It can be an empty list.type (
Optional[str]) – The proxy type. The only supported value isAPPMESH.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs proxy_configuration_property = ecs.CfnTaskDefinition.ProxyConfigurationProperty( container_name="containerName", # the properties below are optional proxy_configuration_properties=[ecs.CfnTaskDefinition.KeyValuePairProperty( name="name", value="value" )], type="type" )
Attributes
- container_name
The name of the container that will serve as the App Mesh proxy.
- proxy_configuration_properties
The set of network configuration parameters to provide the Container Network Interface (CNI) plugin, specified as key-value pairs.
IgnoredUID- (Required) The user ID (UID) of the proxy container as defined by theuserparameter in a container definition. This is used to ensure the proxy ignores its own traffic. IfIgnoredGIDis specified, this field can be empty.IgnoredGID- (Required) The group ID (GID) of the proxy container as defined by theuserparameter in a container definition. This is used to ensure the proxy ignores its own traffic. IfIgnoredUIDis specified, this field can be empty.AppPorts- (Required) The list of ports that the application uses. Network traffic to these ports is forwarded to theProxyIngressPortandProxyEgressPort.ProxyIngressPort- (Required) Specifies the port that incoming traffic to theAppPortsis directed to.ProxyEgressPort- (Required) Specifies the port that outgoing traffic from theAppPortsis directed to.EgressIgnoredPorts- (Required) The egress traffic going to the specified ports is ignored and not redirected to theProxyEgressPort. It can be an empty list.EgressIgnoredIPs- (Required) The egress traffic going to the specified IP addresses is ignored and not redirected to theProxyEgressPort. It can be an empty list.
- type
The proxy type.
The only supported value is
APPMESH.
RepositoryCredentialsProperty
- class CfnTaskDefinition.RepositoryCredentialsProperty(*, credentials_parameter=None)
Bases:
objectThe repository credentials for private registry authentication.
- Parameters:
credentials_parameter (
Optional[str]) – The Amazon Resource Name (ARN) of the secret containing the private repository credentials. .. epigraph:: When you use the Amazon ECS API, AWS CLI , or AWS SDK, if the secret exists in the same Region as the task that you’re launching then you can use either the full ARN or the name of the secret. When you use the AWS Management Console, you must specify the full ARN of the secret.- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs repository_credentials_property = ecs.CfnTaskDefinition.RepositoryCredentialsProperty( credentials_parameter="credentialsParameter" )
Attributes
- credentials_parameter
The Amazon Resource Name (ARN) of the secret containing the private repository credentials.
When you use the Amazon ECS API, AWS CLI , or AWS SDK, if the secret exists in the same Region as the task that you’re launching then you can use either the full ARN or the name of the secret. When you use the AWS Management Console, you must specify the full ARN of the secret.
ResourceRequirementProperty
- class CfnTaskDefinition.ResourceRequirementProperty(*, type, value)
Bases:
objectThe type and amount of a resource to assign to a container.
The supported resource types are GPUs and Elastic Inference accelerators. For more information, see Working with GPUs on Amazon ECS or Working with Amazon Elastic Inference on Amazon ECS in the Amazon Elastic Container Service Developer Guide
- Parameters:
type (
str) – The type of resource to assign to a container. The supported values areGPUorInferenceAccelerator.value (
str) – The value for the specified resource type. If theGPUtype is used, the value is the number of physicalGPUsthe Amazon ECS container agent reserves for the container. The number of GPUs that’s reserved for all containers in a task can’t exceed the number of available GPUs on the container instance that the task is launched on. If theInferenceAcceleratortype is used, thevaluematches thedeviceNamefor an InferenceAccelerator specified in a task definition.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs resource_requirement_property = ecs.CfnTaskDefinition.ResourceRequirementProperty( type="type", value="value" )
Attributes
- type
The type of resource to assign to a container.
The supported values are
GPUorInferenceAccelerator.
- value
The value for the specified resource type.
If the
GPUtype is used, the value is the number of physicalGPUsthe Amazon ECS container agent reserves for the container. The number of GPUs that’s reserved for all containers in a task can’t exceed the number of available GPUs on the container instance that the task is launched on.If the
InferenceAcceleratortype is used, thevaluematches thedeviceNamefor an InferenceAccelerator specified in a task definition.
RuntimePlatformProperty
- class CfnTaskDefinition.RuntimePlatformProperty(*, cpu_architecture=None, operating_system_family=None)
Bases:
objectInformation about the platform for the Amazon ECS service or task.
For more information about
RuntimePlatform, see RuntimePlatform in the Amazon Elastic Container Service Developer Guide .- Parameters:
cpu_architecture (
Optional[str]) – The CPU architecture. You can run your Linux tasks on an ARM-based platform by setting the value toARM64. This option is available for tasks that run on Linux Amazon EC2 instance or Linux containers on Fargate.operating_system_family (
Optional[str]) – The operating system.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs runtime_platform_property = ecs.CfnTaskDefinition.RuntimePlatformProperty( cpu_architecture="cpuArchitecture", operating_system_family="operatingSystemFamily" )
Attributes
- cpu_architecture
The CPU architecture.
You can run your Linux tasks on an ARM-based platform by setting the value to
ARM64. This option is available for tasks that run on Linux Amazon EC2 instance or Linux containers on Fargate.
- operating_system_family
The operating system.
SecretProperty
- class CfnTaskDefinition.SecretProperty(*, name, value_from)
Bases:
objectAn object representing the secret to expose to your container.
Secrets can be exposed to a container in the following ways:
To inject sensitive data into your containers as environment variables, use the
secretscontainer definition parameter.To reference sensitive information in the log configuration of a container, use the
secretOptionscontainer definition parameter.
For more information, see Specifying sensitive data in the Amazon Elastic Container Service Developer Guide .
- Parameters:
name (
str) – The name of the secret.value_from (
str) –The secret to expose to the container. The supported values are either the full ARN of the AWS Secrets Manager secret or the full ARN of the parameter in the SSM Parameter Store. For information about the require AWS Identity and Access Management permissions, see Required IAM permissions for Amazon ECS secrets (for Secrets Manager) or Required IAM permissions for Amazon ECS secrets (for Systems Manager Parameter store) in the Amazon Elastic Container Service Developer Guide . .. epigraph:: If the SSM Parameter Store parameter exists in the same Region as the task you’re launching, then you can use either the full ARN or name of the parameter. If the parameter exists in a different Region, then the full ARN must be specified.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs secret_property = ecs.CfnTaskDefinition.SecretProperty( name="name", value_from="valueFrom" )
Attributes
- name
The name of the secret.
- value_from
The secret to expose to the container.
The supported values are either the full ARN of the AWS Secrets Manager secret or the full ARN of the parameter in the SSM Parameter Store.
For information about the require AWS Identity and Access Management permissions, see Required IAM permissions for Amazon ECS secrets (for Secrets Manager) or Required IAM permissions for Amazon ECS secrets (for Systems Manager Parameter store) in the Amazon Elastic Container Service Developer Guide . .. epigraph:
If the SSM Parameter Store parameter exists in the same Region as the task you're launching, then you can use either the full ARN or name of the parameter. If the parameter exists in a different Region, then the full ARN must be specified.
SystemControlProperty
- class CfnTaskDefinition.SystemControlProperty(*, namespace=None, value=None)
Bases:
objectA list of namespaced kernel parameters to set in the container.
This parameter maps to
Sysctlsin the Create a container section of the Docker Remote API and the--sysctloption to docker run .We don’t recommend that you specify network-related
systemControlsparameters for multiple containers in a single task. This task also uses either theawsvpcorhostnetwork mode. It does it for the following reasons.For tasks that use the
awsvpcnetwork mode, if you setsystemControlsfor any container, it applies to all containers in the task. If you set differentsystemControlsfor multiple containers in a single task, the container that’s started last determines whichsystemControlstake effect.For tasks that use the
hostnetwork mode, thesystemControlsparameter applies to the container instance’s kernel parameter and that of all containers of any tasks running on that container instance.
- Parameters:
namespace (
Optional[str]) – The namespaced kernel parameter to set avaluefor.value (
Optional[str]) – The value for the namespaced kernel parameter that’s specified innamespace.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs system_control_property = ecs.CfnTaskDefinition.SystemControlProperty( namespace="namespace", value="value" )
Attributes
- namespace
The namespaced kernel parameter to set a
valuefor.
- value
The value for the namespaced kernel parameter that’s specified in
namespace.
TaskDefinitionPlacementConstraintProperty
- class CfnTaskDefinition.TaskDefinitionPlacementConstraintProperty(*, type, expression=None)
Bases:
objectThe constraint on task placement in the task definition.
For more information, see Task placement constraints in the Amazon Elastic Container Service Developer Guide . .. epigraph:
Task placement constraints aren't supported for tasks run on AWS Fargate .
- Parameters:
type (
str) – The type of constraint. TheMemberOfconstraint restricts selection to be from a group of valid candidates.expression (
Optional[str]) – A cluster query language expression to apply to the constraint. For more information, see Cluster query language in the Amazon Elastic Container Service Developer Guide .
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs task_definition_placement_constraint_property = ecs.CfnTaskDefinition.TaskDefinitionPlacementConstraintProperty( type="type", # the properties below are optional expression="expression" )
Attributes
- expression
A cluster query language expression to apply to the constraint.
For more information, see Cluster query language in the Amazon Elastic Container Service Developer Guide .
- type
The type of constraint.
The
MemberOfconstraint restricts selection to be from a group of valid candidates.
TmpfsProperty
- class CfnTaskDefinition.TmpfsProperty(*, size, container_path=None, mount_options=None)
Bases:
objectThe container path, mount options, and size of the tmpfs mount.
- Parameters:
size (
Union[int,float]) – The maximum size (in MiB) of the tmpfs volume.container_path (
Optional[str]) – The absolute file path where the tmpfs volume is to be mounted.mount_options (
Optional[Sequence[str]]) – The list of tmpfs volume mount options. Valid values:"defaults" | "ro" | "rw" | "suid" | "nosuid" | "dev" | "nodev" | "exec" | "noexec" | "sync" | "async" | "dirsync" | "remount" | "mand" | "nomand" | "atime" | "noatime" | "diratime" | "nodiratime" | "bind" | "rbind" | "unbindable" | "runbindable" | "private" | "rprivate" | "shared" | "rshared" | "slave" | "rslave" | "relatime" | "norelatime" | "strictatime" | "nostrictatime" | "mode" | "uid" | "gid" | "nr_inodes" | "nr_blocks" | "mpol"
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs tmpfs_property = ecs.CfnTaskDefinition.TmpfsProperty( size=123, # the properties below are optional container_path="containerPath", mount_options=["mountOptions"] )
Attributes
- container_path
The absolute file path where the tmpfs volume is to be mounted.
- mount_options
The list of tmpfs volume mount options.
Valid values:
"defaults" | "ro" | "rw" | "suid" | "nosuid" | "dev" | "nodev" | "exec" | "noexec" | "sync" | "async" | "dirsync" | "remount" | "mand" | "nomand" | "atime" | "noatime" | "diratime" | "nodiratime" | "bind" | "rbind" | "unbindable" | "runbindable" | "private" | "rprivate" | "shared" | "rshared" | "slave" | "rslave" | "relatime" | "norelatime" | "strictatime" | "nostrictatime" | "mode" | "uid" | "gid" | "nr_inodes" | "nr_blocks" | "mpol"
- size
The maximum size (in MiB) of the tmpfs volume.
UlimitProperty
- class CfnTaskDefinition.UlimitProperty(*, hard_limit, name, soft_limit)
Bases:
objectThe
ulimitsettings to pass to the container.Amazon ECS tasks hosted on AWS Fargate use the default resource limit values set by the operating system with the exception of the
nofileresource limit parameter which AWS Fargate overrides. Thenofileresource limit sets a restriction on the number of open files that a container can use. The defaultnofilesoft limit is1024and the default hard limit is4096.You can specify the
ulimitsettings for a container in a task definition.- Parameters:
hard_limit (
Union[int,float]) – The hard limit for theulimittype.name (
str) – Thetypeof theulimit.soft_limit (
Union[int,float]) – The soft limit for theulimittype.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs ulimit_property = ecs.CfnTaskDefinition.UlimitProperty( hard_limit=123, name="name", soft_limit=123 )
Attributes
- hard_limit
The hard limit for the
ulimittype.
- name
The
typeof theulimit.
- soft_limit
The soft limit for the
ulimittype.
VolumeFromProperty
- class CfnTaskDefinition.VolumeFromProperty(*, read_only=None, source_container=None)
Bases:
objectDetails on a data volume from another container in the same task definition.
- Parameters:
read_only (
Union[bool,IResolvable,None]) – If this value istrue, the container has read-only access to the volume. If this value isfalse, then the container can write to the volume. The default value isfalse.source_container (
Optional[str]) – The name of another container within the same task definition to mount volumes from.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs volume_from_property = ecs.CfnTaskDefinition.VolumeFromProperty( read_only=False, source_container="sourceContainer" )
Attributes
- read_only
If this value is
true, the container has read-only access to the volume.If this value is
false, then the container can write to the volume. The default value isfalse.
- source_container
The name of another container within the same task definition to mount volumes from.
VolumeProperty
- class CfnTaskDefinition.VolumeProperty(*, docker_volume_configuration=None, efs_volume_configuration=None, host=None, name=None)
Bases:
objectThe
Volumeproperty specifies a data volume used in a task definition.For tasks that use a Docker volume, specify a
DockerVolumeConfiguration. For tasks that use a bind mount host volume, specify ahostand optionalsourcePath. For more information abouthostand optionalsourcePath, see Volumes and Using Data Volumes in Tasks .- Parameters:
docker_volume_configuration (
Union[IResolvable,DockerVolumeConfigurationProperty,Dict[str,Any],None]) – This parameter is specified when you use Docker volumes. Windows containers only support the use of thelocaldriver. To use bind mounts, specify thehostparameter instead. .. epigraph:: Docker volumes aren’t supported by tasks run on AWS Fargate .efs_volume_configuration (
Union[IResolvable,EFSVolumeConfigurationProperty,Dict[str,Any],None]) – This parameter is specified when you use an Amazon Elastic File System file system for task storage.host (
Union[IResolvable,HostVolumePropertiesProperty,Dict[str,Any],None]) – This parameter is specified when you use bind mount host volumes. The contents of thehostparameter determine whether your bind mount host volume persists on the host container instance and where it’s stored. If thehostparameter is empty, then the Docker daemon assigns a host path for your data volume. However, the data isn’t guaranteed to persist after the containers that are associated with it stop running. Windows containers can mount whole directories on the same drive as$env:ProgramData. Windows containers can’t mount directories on a different drive, and mount point can’t be across drives. For example, you can mountC:\my\path:C:\my\pathandD:\:D:\, but notD:\my\path:C:\my\pathorD:\:C:\my\path.name (
Optional[str]) – The name of the volume. Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed. This name is referenced in thesourceVolumeparameter of container definitionmountPoints.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_ecs as ecs volume_property = ecs.CfnTaskDefinition.VolumeProperty( docker_volume_configuration=ecs.CfnTaskDefinition.DockerVolumeConfigurationProperty( autoprovision=False, driver="driver", driver_opts={ "driver_opts_key": "driverOpts" }, labels={ "labels_key": "labels" }, scope="scope" ), efs_volume_configuration=ecs.CfnTaskDefinition.EFSVolumeConfigurationProperty( filesystem_id="filesystemId", # the properties below are optional authorization_config=ecs.CfnTaskDefinition.AuthorizationConfigProperty( access_point_id="accessPointId", iam="iam" ), root_directory="rootDirectory", transit_encryption="transitEncryption", transit_encryption_port=123 ), host=ecs.CfnTaskDefinition.HostVolumePropertiesProperty( source_path="sourcePath" ), name="name" )
Attributes
- docker_volume_configuration
This parameter is specified when you use Docker volumes.
Windows containers only support the use of the
localdriver. To use bind mounts, specify thehostparameter instead. .. epigraph:Docker volumes aren't supported by tasks run on AWS Fargate .
- efs_volume_configuration
This parameter is specified when you use an Amazon Elastic File System file system for task storage.
- host
This parameter is specified when you use bind mount host volumes.
The contents of the
hostparameter determine whether your bind mount host volume persists on the host container instance and where it’s stored. If thehostparameter is empty, then the Docker daemon assigns a host path for your data volume. However, the data isn’t guaranteed to persist after the containers that are associated with it stop running.Windows containers can mount whole directories on the same drive as
$env:ProgramData. Windows containers can’t mount directories on a different drive, and mount point can’t be across drives. For example, you can mountC:\my\path:C:\my\pathandD:\:D:\, but notD:\my\path:C:\my\pathorD:\:C:\my\path.
- name
The name of the volume.
Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed. This name is referenced in the
sourceVolumeparameter of container definitionmountPoints.