Class: AWSCDK::ECS::CfnTaskDefinitionProps

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
ecs/cfn_task_definition_props.rb

Overview

Properties for defining a CfnTaskDefinition.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container_definitions: nil, cpu: nil, enable_fault_injection: nil, ephemeral_storage: nil, execution_role_arn: nil, family: nil, inference_accelerators: nil, ipc_mode: nil, memory: nil, network_mode: nil, pid_mode: nil, placement_constraints: nil, proxy_configuration: nil, requires_compatibilities: nil, runtime_platform: nil, tags: nil, task_role_arn: nil, volumes: nil) ⇒ CfnTaskDefinitionProps

Returns a new instance of CfnTaskDefinitionProps.

Parameters:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'ecs/cfn_task_definition_props.rb', line 27

def initialize(container_definitions: nil, cpu: nil, enable_fault_injection: nil, ephemeral_storage: nil, execution_role_arn: nil, family: nil, inference_accelerators: nil, ipc_mode: nil, memory: nil, network_mode: nil, pid_mode: nil, placement_constraints: nil, proxy_configuration: nil, requires_compatibilities: nil, runtime_platform: nil, tags: nil, task_role_arn: nil, volumes: nil)
  @container_definitions = container_definitions
  Jsii::Type.check_type(@container_definitions, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsidW5pb24iOnsidHlwZXMiOlt7ImZxbiI6ImF3cy1jZGstbGliLklSZXNvbHZhYmxlIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNmblRhc2tEZWZpbml0aW9uLkNvbnRhaW5lckRlZmluaXRpb25Qcm9wZXJ0eSJ9XX19LCJraW5kIjoiYXJyYXkifX1dfX0=")), "containerDefinitions") unless @container_definitions.nil?
  @cpu = cpu
  Jsii::Type.check_type(@cpu, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "cpu") unless @cpu.nil?
  @enable_fault_injection = enable_fault_injection
  Jsii::Type.check_type(@enable_fault_injection, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoiYm9vbGVhbiJ9LHsiZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifV19fQ==")), "enableFaultInjection") unless @enable_fault_injection.nil?
  @ephemeral_storage = ephemeral_storage.is_a?(Hash) ? ::AWSCDK::ECS::CfnTaskDefinition::EphemeralStorageProperty.new(**ephemeral_storage.transform_keys(&:to_sym)) : ephemeral_storage
  Jsii::Type.check_type(@ephemeral_storage, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuQ2ZuVGFza0RlZmluaXRpb24uRXBoZW1lcmFsU3RvcmFnZVByb3BlcnR5In1dfX0=")), "ephemeralStorage") unless @ephemeral_storage.nil?
  @execution_role_arn = execution_role_arn
  Jsii::Type.check_type(@execution_role_arn, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoic3RyaW5nIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19pYW0uSVJvbGVSZWYifV19fQ==")), "executionRoleArn") unless @execution_role_arn.nil?
  @family = family
  Jsii::Type.check_type(@family, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "family") unless @family.nil?
  @inference_accelerators = inference_accelerators
  Jsii::Type.check_type(@inference_accelerators, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsidW5pb24iOnsidHlwZXMiOlt7ImZxbiI6ImF3cy1jZGstbGliLklSZXNvbHZhYmxlIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNmblRhc2tEZWZpbml0aW9uLkluZmVyZW5jZUFjY2VsZXJhdG9yUHJvcGVydHkifV19fSwia2luZCI6ImFycmF5In19XX19")), "inferenceAccelerators") unless @inference_accelerators.nil?
  @ipc_mode = ipc_mode
  Jsii::Type.check_type(@ipc_mode, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "ipcMode") unless @ipc_mode.nil?
  @memory = memory
  Jsii::Type.check_type(@memory, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "memory") unless @memory.nil?
  @network_mode = network_mode
  Jsii::Type.check_type(@network_mode, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "networkMode") unless @network_mode.nil?
  @pid_mode = pid_mode
  Jsii::Type.check_type(@pid_mode, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "pidMode") unless @pid_mode.nil?
  @placement_constraints = placement_constraints
  Jsii::Type.check_type(@placement_constraints, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsidW5pb24iOnsidHlwZXMiOlt7ImZxbiI6ImF3cy1jZGstbGliLklSZXNvbHZhYmxlIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNmblRhc2tEZWZpbml0aW9uLlRhc2tEZWZpbml0aW9uUGxhY2VtZW50Q29uc3RyYWludFByb3BlcnR5In1dfX0sImtpbmQiOiJhcnJheSJ9fV19fQ==")), "placementConstraints") unless @placement_constraints.nil?
  @proxy_configuration = proxy_configuration.is_a?(Hash) ? ::AWSCDK::ECS::CfnTaskDefinition::ProxyConfigurationProperty.new(**proxy_configuration.transform_keys(&:to_sym)) : proxy_configuration
  Jsii::Type.check_type(@proxy_configuration, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuQ2ZuVGFza0RlZmluaXRpb24uUHJveHlDb25maWd1cmF0aW9uUHJvcGVydHkifV19fQ==")), "proxyConfiguration") unless @proxy_configuration.nil?
  @requires_compatibilities = requires_compatibilities
  Jsii::Type.check_type(@requires_compatibilities, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "requiresCompatibilities") unless @requires_compatibilities.nil?
  @runtime_platform = runtime_platform.is_a?(Hash) ? ::AWSCDK::ECS::CfnTaskDefinition::RuntimePlatformProperty.new(**runtime_platform.transform_keys(&:to_sym)) : runtime_platform
  Jsii::Type.check_type(@runtime_platform, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuQ2ZuVGFza0RlZmluaXRpb24uUnVudGltZVBsYXRmb3JtUHJvcGVydHkifV19fQ==")), "runtimePlatform") unless @runtime_platform.nil?
  @tags = tags.is_a?(Array) ? tags.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::CfnTag.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : tags
  Jsii::Type.check_type(@tags, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLkNmblRhZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "tags") unless @tags.nil?
  @task_role_arn = task_role_arn
  Jsii::Type.check_type(@task_role_arn, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoic3RyaW5nIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19pYW0uSVJvbGVSZWYifV19fQ==")), "taskRoleArn") unless @task_role_arn.nil?
  @volumes = volumes
  Jsii::Type.check_type(@volumes, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsidW5pb24iOnsidHlwZXMiOlt7ImZxbiI6ImF3cy1jZGstbGliLklSZXNvbHZhYmxlIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNmblRhc2tEZWZpbml0aW9uLlZvbHVtZVByb3BlcnR5In1dfX0sImtpbmQiOiJhcnJheSJ9fV19fQ==")), "volumes") unless @volumes.nil?
end

Instance Attribute Details

#container_definitionsAWSCDK::IResolvable, ... (readonly)

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 .



72
73
74
# File 'ecs/cfn_task_definition_props.rb', line 72

def container_definitions
  @container_definitions
end

#cpuString? (readonly)

The number of cpu units 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 memory parameter.

If you're using the EC2 launch type or the external launch type, this field is optional. Supported values are between 128 CPU units ( 0.125 vCPUs) and 196608 CPU units ( 192 vCPUs).

This field is required for Fargate. For information about the valid values, see Task size in the Amazon Elastic Container Service Developer Guide .



83
84
85
# File 'ecs/cfn_task_definition_props.rb', line 83

def cpu
  @cpu
end

#enable_fault_injectionBoolean, ... (readonly)

Enables fault injection and allows for fault injection requests to be accepted from the task's containers.

The default value is false .



90
91
92
# File 'ecs/cfn_task_definition_props.rb', line 90

def enable_fault_injection
  @enable_fault_injection
end

#ephemeral_storageAWSCDK::IResolvable, ... (readonly)

The ephemeral storage settings to use for tasks run with the task definition.



95
96
97
# File 'ecs/cfn_task_definition_props.rb', line 95

def ephemeral_storage
  @ephemeral_storage
end

#execution_role_arnString, ... (readonly)

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.

For informationabout the required IAM roles for Amazon ECS, see IAM roles for Amazon ECS in the Amazon Elastic Container Service Developer Guide .



102
103
104
# File 'ecs/cfn_task_definition_props.rb', line 102

def execution_role_arn
  @execution_role_arn
end

#familyString? (readonly)

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.

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.



113
114
115
# File 'ecs/cfn_task_definition_props.rb', line 113

def family
  @family
end

#inference_acceleratorsAWSCDK::IResolvable, ... (readonly)

Deprecated.

this property has been deprecated



117
118
119
# File 'ecs/cfn_task_definition_props.rb', line 117

def inference_accelerators
  @inference_accelerators
end

#ipc_modeString? (readonly)

The IPC resource namespace to use for the containers in the task.

The valid values are host , task , or none . If host is specified, then all containers within the tasks that specified the host IPC mode on the same container instance share the same IPC resources with the host Amazon EC2 instance. If task is specified, all containers within the specified task share the same IPC resources. If none is 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.

If the host IPC mode is used, be aware that there is a heightened risk of undesired IPC namespace expose.

If you are setting namespaced kernel parameters using system_controls for 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 host IPC mode, IPC namespace related system_controls are not supported.
  • For tasks that use the task IPC mode, IPC namespace related system_controls will apply to all containers within a task.

This parameter is not supported for Windows containers or tasks run on AWS Fargate .



133
134
135
# File 'ecs/cfn_task_definition_props.rb', line 133

def ipc_mode
  @ipc_mode
end

#memoryString? (readonly)

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 cpu parameter.

  • 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 vCPU)
  • 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 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 cpu values: 1024 (1 vCPU)
  • Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU)
  • Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU)
  • Between 16 GB and 60 GB in 4 GB increments - Available cpu values: 8192 (8 vCPU)

This option requires Linux platform 1.4.0 or later.

  • Between 32GB and 120 GB in 8 GB increments - Available cpu values: 16384 (16 vCPU)

This option requires Linux platform 1.4.0 or later.



155
156
157
# File 'ecs/cfn_task_definition_props.rb', line 155

def memory
  @memory
end

#network_modeString? (readonly)

The Docker networking mode to use for the containers in the task.

The valid values are none , bridge , awsvpc , and host . If no network mode is specified, the default is bridge .

For Amazon ECS tasks on Fargate, the awsvpc network 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> or awsvpc can be used. If the network mode is set to none , you cannot specify port mappings in your container definitions, and the tasks containers do not have external connectivity. The host and awsvpc network modes offer the highest networking performance for containers because they use the EC2 network stack instead of the virtualized network stack provided by the bridge mode.

With the host and awsvpc network modes, exposed container ports are mapped directly to the corresponding host port (for the host network mode) or the attached elastic network interface port (for the awsvpc network mode), so you cannot take advantage of dynamic host port mappings.

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 a NetworkConfiguration value 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.



172
173
174
# File 'ecs/cfn_task_definition_props.rb', line 172

def network_mode
  @network_mode
end

#pid_modeString? (readonly)

The process namespace to use for the containers in the task.

The valid values are host or task . On Fargate for Linux containers, the only valid value is task . For example, monitoring sidecars might need pid_mode to access information about other containers running in the same task.

If host is specified, all containers within the tasks that specified the host PID mode on the same container instance share the same process namespace with the host Amazon EC2 instance.

If task is specified, all containers within the specified task share the same process namespace.

If no value is specified, the The default is a private namespace for each container.

If the host PID mode is used, there's a heightened risk of undesired process namespace exposure.

This parameter is not supported for Windows containers. > This parameter is only supported for tasks that are hosted on AWS Fargate if the tasks are using platform version 1.4.0 or later (Linux). This isn't supported for Windows containers on Fargate.



189
190
191
# File 'ecs/cfn_task_definition_props.rb', line 189

def pid_mode
  @pid_mode
end

#placement_constraintsAWSCDK::IResolvable, ... (readonly)

An array of placement constraint objects to use for tasks.

This parameter isn't supported for tasks run on AWS Fargate .



196
197
198
# File 'ecs/cfn_task_definition_props.rb', line 196

def placement_constraints
  @placement_constraints
end

#proxy_configurationAWSCDK::IResolvable, ... (readonly)

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-init package to use a proxy configuration. If your container instances are launched from the Amazon ECS optimized AMI version 20190301 or later, they contain the required versions of the container agent and ecs-init . For more information, see Amazon ECS-optimized Linux AMI in the Amazon Elastic Container Service Developer Guide .



203
204
205
# File 'ecs/cfn_task_definition_props.rb', line 203

def proxy_configuration
  @proxy_configuration
end

#requires_compatibilitiesArray<String>? (readonly)

The task launch types the task definition was validated against.

The valid values are MANAGED_INSTANCES , EC2 , FARGATE , and EXTERNAL . For more information, see Amazon ECS launch types in the Amazon Elastic Container Service Developer Guide .



210
211
212
# File 'ecs/cfn_task_definition_props.rb', line 210

def requires_compatibilities
  @requires_compatibilities
end

#runtime_platformAWSCDK::IResolvable, ... (readonly)

The operating system that your tasks definitions run on.



215
216
217
# File 'ecs/cfn_task_definition_props.rb', line 215

def runtime_platform
  @runtime_platform
end

#tagsArray<AWSCDK::CfnTag>? (readonly)

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: + - = . _ : /


230
231
232
# File 'ecs/cfn_task_definition_props.rb', line 230

def tags
  @tags
end

#task_role_arnString, ... (readonly)

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 -EnableTaskIAMRole option 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 .

String validation is done on the ECS side. If an invalid string value is given for TaskRoleArn , it may cause the Cloudformation job to hang.



241
242
243
# File 'ecs/cfn_task_definition_props.rb', line 241

def task_role_arn
  @task_role_arn
end

#volumesAWSCDK::IResolvable, ... (readonly)

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 .

The host and source_path parameters aren't supported for tasks run on AWS Fargate .



250
251
252
# File 'ecs/cfn_task_definition_props.rb', line 250

def volumes
  @volumes
end

Class Method Details

.jsii_propertiesObject



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'ecs/cfn_task_definition_props.rb', line 252

def self.jsii_properties
  {
    :container_definitions => "containerDefinitions",
    :cpu => "cpu",
    :enable_fault_injection => "enableFaultInjection",
    :ephemeral_storage => "ephemeralStorage",
    :execution_role_arn => "executionRoleArn",
    :family => "family",
    :inference_accelerators => "inferenceAccelerators",
    :ipc_mode => "ipcMode",
    :memory => "memory",
    :network_mode => "networkMode",
    :pid_mode => "pidMode",
    :placement_constraints => "placementConstraints",
    :proxy_configuration => "proxyConfiguration",
    :requires_compatibilities => "requiresCompatibilities",
    :runtime_platform => "runtimePlatform",
    :tags => "tags",
    :task_role_arn => "taskRoleArn",
    :volumes => "volumes",
  }
end

Instance Method Details

#to_jsiiObject



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'ecs/cfn_task_definition_props.rb', line 275

def to_jsii
  result = {}
  result.merge!({
    "containerDefinitions" => @container_definitions,
    "cpu" => @cpu,
    "enableFaultInjection" => @enable_fault_injection,
    "ephemeralStorage" => @ephemeral_storage,
    "executionRoleArn" => @execution_role_arn,
    "family" => @family,
    "inferenceAccelerators" => @inference_accelerators,
    "ipcMode" => @ipc_mode,
    "memory" => @memory,
    "networkMode" => @network_mode,
    "pidMode" => @pid_mode,
    "placementConstraints" => @placement_constraints,
    "proxyConfiguration" => @proxy_configuration,
    "requiresCompatibilities" => @requires_compatibilities,
    "runtimePlatform" => @runtime_platform,
    "tags" => @tags,
    "taskRoleArn" => @task_role_arn,
    "volumes" => @volumes,
  })
  result.compact
end