Class: AWSCDK::ECS::TaskDefinitionProps

Inherits:
CommonTaskDefinitionProps
  • Object
show all
Defined in:
ecs/task_definition_props.rb

Overview

The properties for task definitions.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enable_fault_injection: nil, execution_role: nil, family: nil, proxy_configuration: nil, task_role: nil, volumes: nil, compatibility:, cpu: nil, ephemeral_storage_gib: nil, inference_accelerators: nil, ipc_mode: nil, memory_mib: nil, network_mode: nil, pid_mode: nil, placement_constraints: nil, runtime_platform: nil) ⇒ TaskDefinitionProps

Returns a new instance of TaskDefinitionProps.

Parameters:

  • enable_fault_injection (Boolean, nil) (defaults to: nil)

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

  • execution_role (AWSCDK::IAM::IRole, nil) (defaults to: nil)

    The name of the IAM task execution role that grants the ECS agent permission to call AWS APIs on your behalf.

  • family (String, nil) (defaults to: nil)

    The name of a family that this task definition is registered to.

  • proxy_configuration (AWSCDK::ECS::ProxyConfiguration, nil) (defaults to: nil)

    The configuration details for the App Mesh proxy.

  • task_role (AWSCDK::IAM::IRole, nil) (defaults to: nil)

    The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.

  • volumes (Array<AWSCDK::ECS::Volume>, nil) (defaults to: nil)

    The list of volume definitions for the task.

  • compatibility (AWSCDK::ECS::Compatibility)

    The task launch type compatibility requirement.

  • cpu (String, nil) (defaults to: nil)

    The number of cpu units used by the task.

  • ephemeral_storage_gib (Numeric, nil) (defaults to: nil)

    The amount (in GiB) of ephemeral storage to be allocated to the task.

  • inference_accelerators (Array<AWSCDK::ECS::InferenceAccelerator>, nil) (defaults to: nil)

    The inference accelerators to use for the containers in the task.

  • ipc_mode (AWSCDK::ECS::IpcMode, nil) (defaults to: nil)

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

  • memory_mib (String, nil) (defaults to: nil)

    The amount (in MiB) of memory used by the task.

  • network_mode (AWSCDK::ECS::NetworkMode, nil) (defaults to: nil)

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

  • pid_mode (AWSCDK::ECS::PidMode, nil) (defaults to: nil)

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

  • placement_constraints (Array<AWSCDK::ECS::PlacementConstraint>, nil) (defaults to: nil)

    The placement constraints to use for tasks in the service.

  • runtime_platform (AWSCDK::ECS::RuntimePlatform, nil) (defaults to: nil)

    The operating system that your task definitions are running on.



23
24
25
26
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
# File 'ecs/task_definition_props.rb', line 23

def initialize(enable_fault_injection: nil, execution_role: nil, family: nil, proxy_configuration: nil, task_role: nil, volumes: nil, compatibility:, cpu: nil, ephemeral_storage_gib: nil, inference_accelerators: nil, ipc_mode: nil, memory_mib: nil, network_mode: nil, pid_mode: nil, placement_constraints: nil, runtime_platform: nil)
  @enable_fault_injection = enable_fault_injection
  Jsii::Type.check_type(@enable_fault_injection, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "enableFaultInjection") unless @enable_fault_injection.nil?
  @execution_role = execution_role
  Jsii::Type.check_type(@execution_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "executionRole") unless @execution_role.nil?
  @family = family
  Jsii::Type.check_type(@family, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "family") unless @family.nil?
  @proxy_configuration = proxy_configuration
  Jsii::Type.check_type(@proxy_configuration, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlByb3h5Q29uZmlndXJhdGlvbiJ9")), "proxyConfiguration") unless @proxy_configuration.nil?
  @task_role = task_role
  Jsii::Type.check_type(@task_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "taskRole") unless @task_role.nil?
  @volumes = volumes.is_a?(Array) ? volumes.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::Volume.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : volumes
  Jsii::Type.check_type(@volumes, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuVm9sdW1lIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "volumes") unless @volumes.nil?
  @compatibility = compatibility
  Jsii::Type.check_type(@compatibility, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNvbXBhdGliaWxpdHkifQ==")), "compatibility")
  @cpu = cpu
  Jsii::Type.check_type(@cpu, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "cpu") unless @cpu.nil?
  @ephemeral_storage_gib = ephemeral_storage_gib
  Jsii::Type.check_type(@ephemeral_storage_gib, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "ephemeralStorageGiB") unless @ephemeral_storage_gib.nil?
  @inference_accelerators = inference_accelerators.is_a?(Array) ? inference_accelerators.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::InferenceAccelerator.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : inference_accelerators
  Jsii::Type.check_type(@inference_accelerators, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuSW5mZXJlbmNlQWNjZWxlcmF0b3IifSwia2luZCI6ImFycmF5In19")), "inferenceAccelerators") unless @inference_accelerators.nil?
  @ipc_mode = ipc_mode
  Jsii::Type.check_type(@ipc_mode, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLklwY01vZGUifQ==")), "ipcMode") unless @ipc_mode.nil?
  @memory_mib = memory_mib
  Jsii::Type.check_type(@memory_mib, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "memoryMiB") unless @memory_mib.nil?
  @network_mode = network_mode
  Jsii::Type.check_type(@network_mode, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLk5ldHdvcmtNb2RlIn0=")), "networkMode") unless @network_mode.nil?
  @pid_mode = pid_mode
  Jsii::Type.check_type(@pid_mode, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlBpZE1vZGUifQ==")), "pidMode") unless @pid_mode.nil?
  @placement_constraints = placement_constraints
  Jsii::Type.check_type(@placement_constraints, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuUGxhY2VtZW50Q29uc3RyYWludCJ9LCJraW5kIjoiYXJyYXkifX0=")), "placementConstraints") unless @placement_constraints.nil?
  @runtime_platform = runtime_platform.is_a?(Hash) ? ::AWSCDK::ECS::RuntimePlatform.new(**runtime_platform.transform_keys(&:to_sym)) : runtime_platform
  Jsii::Type.check_type(@runtime_platform, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlJ1bnRpbWVQbGF0Zm9ybSJ9")), "runtimePlatform") unless @runtime_platform.nil?
end

Instance Attribute Details

#compatibilityAWSCDK::ECS::Compatibility (readonly)

The task launch type compatibility requirement.



100
101
102
# File 'ecs/task_definition_props.rb', line 100

def compatibility
  @compatibility
end

#cpuString? (readonly)

Note:

Default: - CPU units are not specified.

The number of cpu units used by the task.

If you are using the EC2 launch type, this field is optional and any value can be used. If you are using the Fargate launch type, this field is required and you must use one of the following values, which determines your range of valid values for the memory parameter:

256 (.25 vCPU) - Available memory values: 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB)

512 (.5 vCPU) - Available memory values: 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB)

1024 (1 vCPU) - Available memory values: 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 memory values: Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB)

4096 (4 vCPU) - Available memory values: Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB)

8192 (8 vCPU) - Available memory values: Between 16384 (16 GB) and 61440 (60 GB) in increments of 4096 (4 GB)

16384 (16 vCPU) - Available memory values: Between 32768 (32 GB) and 122880 (120 GB) in increments of 8192 (8 GB)

Returns:

  • (String, nil)


123
124
125
# File 'ecs/task_definition_props.rb', line 123

def cpu
  @cpu
end

#enable_fault_injectionBoolean? (readonly)

Note:

Default: undefined - ECS default setting is false

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

Fault injection only works with tasks using the NetworkMode.AWS_VPC or NetworkMode.HOST network modes.

Returns:

  • (Boolean, nil)


64
65
66
# File 'ecs/task_definition_props.rb', line 64

def enable_fault_injection
  @enable_fault_injection
end

#ephemeral_storage_gibNumeric? (readonly)

Note:

Default: - Undefined, in which case, the task will receive 20GiB ephemeral storage.

The amount (in GiB) of ephemeral storage to be allocated to the task.

Only supported in Fargate platform version 1.4.0 or later.

Returns:

  • (Numeric, nil)


130
131
132
# File 'ecs/task_definition_props.rb', line 130

def ephemeral_storage_gib
  @ephemeral_storage_gib
end

#execution_roleAWSCDK::IAM::IRole? (readonly)

Note:

Default: - An execution role will be automatically created if you use ECR images in your task definition.

The name of the IAM task execution role that grants the ECS agent permission to call AWS APIs on your behalf.

The role will be used to retrieve container images from ECR and create CloudWatch log groups.

Returns:



71
72
73
# File 'ecs/task_definition_props.rb', line 71

def execution_role
  @execution_role
end

#familyString? (readonly)

Note:

Default: - Automatically generated name.

The name of a family that this task definition is registered to.

A family groups multiple versions of a task definition.

Returns:

  • (String, nil)


78
79
80
# File 'ecs/task_definition_props.rb', line 78

def family
  @family
end

#inference_acceleratorsArray<AWSCDK::ECS::InferenceAccelerator>? (readonly)

Deprecated.

ECS TaskDefinition's inferenceAccelerator is EOL since April 2024

Note:

Default: - No inference accelerators.

The inference accelerators to use for the containers in the task.

Not supported in Fargate.

Returns:



138
139
140
# File 'ecs/task_definition_props.rb', line 138

def inference_accelerators
  @inference_accelerators
end

#ipc_modeAWSCDK::ECS::IpcMode? (readonly)

Note:

Default: - IpcMode used by the task is not specified

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

Not supported in Fargate and Windows containers.

Returns:



145
146
147
# File 'ecs/task_definition_props.rb', line 145

def ipc_mode
  @ipc_mode
end

#memory_mibString? (readonly)

Note:

Default: - Memory used by task is not specified.

The amount (in MiB) of memory used by the task.

If using the EC2 launch type, this field is optional and any value can be used. If using the Fargate launch type, this field is required and you must use one of the following values, which 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 16384 (16 GB) and 61440 (60 GB) in increments of 4096 (4 GB) - Available cpu values: 8192 (8 vCPU)

Between 32768 (32 GB) and 122880 (120 GB) in increments of 8192 (8 GB) - Available cpu values: 16384 (16 vCPU)

Returns:

  • (String, nil)


168
169
170
# File 'ecs/task_definition_props.rb', line 168

def memory_mib
  @memory_mib
end

#network_modeAWSCDK::ECS::NetworkMode? (readonly)

Note:

Default: - NetworkMode.Bridge for EC2 & External tasks, AwsVpc for Fargate tasks.

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

On Fargate, the only supported networking mode is AwsVpc.

Returns:



175
176
177
# File 'ecs/task_definition_props.rb', line 175

def network_mode
  @network_mode
end

#pid_modeAWSCDK::ECS::PidMode? (readonly)

Note:

Default: - PidMode used by the task is not specified

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

Only supported for tasks that are hosted on AWS Fargate if the tasks are using platform version 1.4.0 or later (Linux). Only the TASK option is supported for Linux-based Fargate containers. Not supported in Windows containers. If pidMode is specified for a Fargate task, then runtimePlatform.operatingSystemFamily must also be specified. For more information, see Task Definition Parameters.

Returns:



187
188
189
# File 'ecs/task_definition_props.rb', line 187

def pid_mode
  @pid_mode
end

#placement_constraintsArray<AWSCDK::ECS::PlacementConstraint>? (readonly)

Note:

Default: - No placement constraints.

The placement constraints to use for tasks in the service.

You can specify a maximum of 10 constraints per task (this limit includes constraints in the task definition and those specified at run time).

Not supported in Fargate.

Returns:



197
198
199
# File 'ecs/task_definition_props.rb', line 197

def placement_constraints
  @placement_constraints
end

#proxy_configurationAWSCDK::ECS::ProxyConfiguration? (readonly)

Note:

Default: - No proxy configuration.

The configuration details for the App Mesh proxy.



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

def proxy_configuration
  @proxy_configuration
end

#runtime_platformAWSCDK::ECS::RuntimePlatform? (readonly)

Note:

Default: - Undefined.

The operating system that your task definitions are running on.

A runtimePlatform is supported only for tasks using the Fargate launch type.



204
205
206
# File 'ecs/task_definition_props.rb', line 204

def runtime_platform
  @runtime_platform
end

#task_roleAWSCDK::IAM::IRole? (readonly)

Note:

Default: - A task role is automatically created for you.

The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.

Returns:



88
89
90
# File 'ecs/task_definition_props.rb', line 88

def task_role
  @task_role
end

#volumesArray<AWSCDK::ECS::Volume>? (readonly)

Note:

Default: - No volumes are passed to the Docker daemon on a container instance.

The list of volume definitions for the task.

For more information, see Task Definition Parameter Volumes.

Returns:



96
97
98
# File 'ecs/task_definition_props.rb', line 96

def volumes
  @volumes
end

Class Method Details

.jsii_propertiesObject



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'ecs/task_definition_props.rb', line 206

def self.jsii_properties
  {
    :enable_fault_injection => "enableFaultInjection",
    :execution_role => "executionRole",
    :family => "family",
    :proxy_configuration => "proxyConfiguration",
    :task_role => "taskRole",
    :volumes => "volumes",
    :compatibility => "compatibility",
    :cpu => "cpu",
    :ephemeral_storage_gib => "ephemeralStorageGiB",
    :inference_accelerators => "inferenceAccelerators",
    :ipc_mode => "ipcMode",
    :memory_mib => "memoryMiB",
    :network_mode => "networkMode",
    :pid_mode => "pidMode",
    :placement_constraints => "placementConstraints",
    :runtime_platform => "runtimePlatform",
  }
end

Instance Method Details

#to_jsiiObject



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'ecs/task_definition_props.rb', line 227

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "enableFaultInjection" => @enable_fault_injection,
    "executionRole" => @execution_role,
    "family" => @family,
    "proxyConfiguration" => @proxy_configuration,
    "taskRole" => @task_role,
    "volumes" => @volumes,
    "compatibility" => @compatibility,
    "cpu" => @cpu,
    "ephemeralStorageGiB" => @ephemeral_storage_gib,
    "inferenceAccelerators" => @inference_accelerators,
    "ipcMode" => @ipc_mode,
    "memoryMiB" => @memory_mib,
    "networkMode" => @network_mode,
    "pidMode" => @pid_mode,
    "placementConstraints" => @placement_constraints,
    "runtimePlatform" => @runtime_platform,
  })
  result.compact
end