Class: AWSCDK::ECS::EC2TaskDefinitionProps

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

Overview

The properties for a task definition run on an EC2 cluster.

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, inference_accelerators: nil, ipc_mode: nil, network_mode: nil, pid_mode: nil, placement_constraints: nil) ⇒ EC2TaskDefinitionProps

Returns a new instance of EC2TaskDefinitionProps.

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.

  • 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.

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

    The Docker 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)

    An array of placement constraint objects to use for the task.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'ecs/ec2_task_definition_props.rb', line 18

def initialize(enable_fault_injection: nil, execution_role: nil, family: nil, proxy_configuration: nil, task_role: nil, volumes: nil, inference_accelerators: nil, ipc_mode: nil, network_mode: nil, pid_mode: nil, placement_constraints: 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?
  @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?
  @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?
end

Instance Attribute Details

#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)


49
50
51
# File 'ecs/ec2_task_definition_props.rb', line 49

def enable_fault_injection
  @enable_fault_injection
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:



56
57
58
# File 'ecs/ec2_task_definition_props.rb', line 56

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)


63
64
65
# File 'ecs/ec2_task_definition_props.rb', line 63

def family
  @family
end

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

Note:

Default: - No inference accelerators.

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

Not supported in Fargate.

Returns:



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

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:



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

def ipc_mode
  @ipc_mode
end

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

Note:

Default: - NetworkMode.BRIDGE for EC2 tasks, AWS_VPC for Fargate tasks.

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

The valid values are NONE, BRIDGE, AWS_VPC, and HOST.

Returns:



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

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.

Not supported in Windows containers.

Returns:



109
110
111
# File 'ecs/ec2_task_definition_props.rb', line 109

def pid_mode
  @pid_mode
end

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

Note:

Default: - No placement constraints.

An array of placement constraint objects to use for the task.

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

Returns:



118
119
120
# File 'ecs/ec2_task_definition_props.rb', line 118

def placement_constraints
  @placement_constraints
end

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

Note:

Default: - No proxy configuration.

The configuration details for the App Mesh proxy.



68
69
70
# File 'ecs/ec2_task_definition_props.rb', line 68

def proxy_configuration
  @proxy_configuration
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:



73
74
75
# File 'ecs/ec2_task_definition_props.rb', line 73

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:



81
82
83
# File 'ecs/ec2_task_definition_props.rb', line 81

def volumes
  @volumes
end

Class Method Details

.jsii_propertiesObject



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'ecs/ec2_task_definition_props.rb', line 120

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

Instance Method Details

#to_jsiiObject



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'ecs/ec2_task_definition_props.rb', line 136

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,
    "inferenceAccelerators" => @inference_accelerators,
    "ipcMode" => @ipc_mode,
    "networkMode" => @network_mode,
    "pidMode" => @pid_mode,
    "placementConstraints" => @placement_constraints,
  })
  result.compact
end