Class: AWSCDK::ECS::ContainerDefinition

Inherits:
Constructs::Construct
  • Object
show all
Defined in:
ecs/container_definition.rb

Overview

A container definition is used in a task definition to describe the containers that are launched as part of a task.

Direct Known Subclasses

FirelensLogRouter

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props) ⇒ ContainerDefinition

Constructs a new instance of the ContainerDefinition class.

Parameters:



13
14
15
16
17
18
19
# File 'ecs/container_definition.rb', line 13

def initialize(scope, id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::ECS::ContainerDefinitionProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNvbnRhaW5lckRlZmluaXRpb25Qcm9wcyJ9")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.CONTAINER_PORT_USE_RANGENumeric

Returns:

  • (Numeric)


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

def self.CONTAINER_PORT_USE_RANGE()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_ecs.ContainerDefinition", "CONTAINER_PORT_USE_RANGE")
end

.jsii_overridable_methodsObject



21
22
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
57
58
59
60
61
# File 'ecs/container_definition.rb', line 21

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :container_dependencies => { kind: :property, name: "containerDependencies", is_optional: false },
    :container_name => { kind: :property, name: "containerName", is_optional: false },
    :container_port => { kind: :property, name: "containerPort", is_optional: false },
    :essential => { kind: :property, name: "essential", is_optional: false },
    :image_name => { kind: :property, name: "imageName", is_optional: false },
    :ingress_port => { kind: :property, name: "ingressPort", is_optional: false },
    :memory_limit_specified => { kind: :property, name: "memoryLimitSpecified", is_optional: false },
    :mount_points => { kind: :property, name: "mountPoints", is_optional: false },
    :port_mappings => { kind: :property, name: "portMappings", is_optional: false },
    :task_definition => { kind: :property, name: "taskDefinition", is_optional: false },
    :ulimits => { kind: :property, name: "ulimits", is_optional: false },
    :volumes_from => { kind: :property, name: "volumesFrom", is_optional: false },
    :cpu => { kind: :property, name: "cpu", is_optional: true },
    :credential_specs => { kind: :property, name: "credentialSpecs", is_optional: true },
    :environment_files => { kind: :property, name: "environmentFiles", is_optional: true },
    :linux_parameters => { kind: :property, name: "linuxParameters", is_optional: true },
    :log_driver_config => { kind: :property, name: "logDriverConfig", is_optional: true },
    :pseudo_terminal => { kind: :property, name: "pseudoTerminal", is_optional: true },
    :references_secret_json_field => { kind: :property, name: "referencesSecretJsonField", is_optional: true },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :add_container_dependencies => { kind: :method, name: "addContainerDependencies", is_optional: false },
    :add_docker_label => { kind: :method, name: "addDockerLabel", is_optional: false },
    :add_environment => { kind: :method, name: "addEnvironment", is_optional: false },
    :add_inference_accelerator_resource => { kind: :method, name: "addInferenceAcceleratorResource", is_optional: false },
    :add_link => { kind: :method, name: "addLink", is_optional: false },
    :add_mount_points => { kind: :method, name: "addMountPoints", is_optional: false },
    :add_port_mappings => { kind: :method, name: "addPortMappings", is_optional: false },
    :add_scratch => { kind: :method, name: "addScratch", is_optional: false },
    :add_secret => { kind: :method, name: "addSecret", is_optional: false },
    :add_to_execution_policy => { kind: :method, name: "addToExecutionPolicy", is_optional: false },
    :add_ulimits => { kind: :method, name: "addUlimits", is_optional: false },
    :add_volumes_from => { kind: :method, name: "addVolumesFrom", is_optional: false },
    :find_port_mapping => { kind: :method, name: "findPortMapping", is_optional: false },
    :find_port_mapping_by_name => { kind: :method, name: "findPortMappingByName", is_optional: false },
    :render_container_definition => { kind: :method, name: "renderContainerDefinition", is_optional: false },
  }
end

.PROPERTY_INJECTION_IDString

Uniquely identifies this class.

Returns:

  • (String)


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

def self.PROPERTY_INJECTION_ID()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_ecs.ContainerDefinition", "PROPERTY_INJECTION_ID")
end

Instance Method Details

#add_container_dependencies(*container_dependencies) ⇒ void

This method returns an undefined value.

This method adds one or more container dependencies to the container.

Parameters:



254
255
256
257
258
259
260
# File 'ecs/container_definition.rb', line 254

def add_container_dependencies(*container_dependencies)
  container_dependencies.map! { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::ContainerDependency.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 }
  container_dependencies.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNvbnRhaW5lckRlcGVuZGVuY3kifQ==")), "containerDependencies[#{index}]")
  end
  jsii_call_method("addContainerDependencies", [*container_dependencies])
end

#add_docker_label(name, value) ⇒ void

This method returns an undefined value.

This method adds a Docker label to the container.

Parameters:

  • name (String)
  • value (String)


267
268
269
270
271
# File 'ecs/container_definition.rb', line 267

def add_docker_label(name, value)
  Jsii::Type.check_type(name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name")
  Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "value")
  jsii_call_method("addDockerLabel", [name, value])
end

#add_environment(name, value) ⇒ void

This method returns an undefined value.

This method adds an environment variable to the container.

Parameters:

  • name (String)
  • value (String)


278
279
280
281
282
# File 'ecs/container_definition.rb', line 278

def add_environment(name, value)
  Jsii::Type.check_type(name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name")
  Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "value")
  jsii_call_method("addEnvironment", [name, value])
end

#add_inference_accelerator_resource(*inference_accelerator_resources) ⇒ void

This method returns an undefined value.

This method adds one or more resources to the container.

Parameters:

  • inference_accelerator_resources (Array<String>)


288
289
290
291
292
293
# File 'ecs/container_definition.rb', line 288

def add_inference_accelerator_resource(*inference_accelerator_resources)
  inference_accelerator_resources.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "inferenceAcceleratorResources[#{index}]")
  end
  jsii_call_method("addInferenceAcceleratorResource", [*inference_accelerator_resources])
end

This method returns an undefined value.

This method adds a link which allows containers to communicate with each other without the need for port mappings.

This parameter is only supported if the task definition is using the bridge network mode. Warning: The --link flag is a legacy feature of Docker. It may eventually be removed.

Parameters:

  • container (AWSCDK::ECS::ContainerDefinition)
  • _alias (String, nil) (defaults to: nil)


303
304
305
306
307
# File 'ecs/container_definition.rb', line 303

def add_link(container, _alias = nil)
  Jsii::Type.check_type(container, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNvbnRhaW5lckRlZmluaXRpb24ifQ==")), "container")
  Jsii::Type.check_type(_alias, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "alias") unless _alias.nil?
  jsii_call_method("addLink", [container, _alias])
end

#add_mount_points(*mount_points) ⇒ void

This method returns an undefined value.

This method adds one or more mount points for data volumes to the container.

Parameters:



313
314
315
316
317
318
319
# File 'ecs/container_definition.rb', line 313

def add_mount_points(*mount_points)
  mount_points.map! { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::MountPoint.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 }
  mount_points.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLk1vdW50UG9pbnQifQ==")), "mountPoints[#{index}]")
  end
  jsii_call_method("addMountPoints", [*mount_points])
end

#add_port_mappings(*port_mappings) ⇒ void

This method returns an undefined value.

This method adds one or more port mappings to the container.

Parameters:



325
326
327
328
329
330
331
# File 'ecs/container_definition.rb', line 325

def add_port_mappings(*port_mappings)
  port_mappings.map! { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::PortMapping.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 }
  port_mappings.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlBvcnRNYXBwaW5nIn0=")), "portMappings[#{index}]")
  end
  jsii_call_method("addPortMappings", [*port_mappings])
end

#add_scratch(scratch) ⇒ void

This method returns an undefined value.

This method mounts temporary disk space to the container.

This adds the correct container mountPoint and task definition volume.

Parameters:



339
340
341
342
343
# File 'ecs/container_definition.rb', line 339

def add_scratch(scratch)
  scratch = scratch.is_a?(Hash) ? ::AWSCDK::ECS::ScratchSpace.new(**scratch.transform_keys(&:to_sym)) : scratch
  Jsii::Type.check_type(scratch, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlNjcmF0Y2hTcGFjZSJ9")), "scratch")
  jsii_call_method("addScratch", [scratch])
end

#add_secret(name, secret) ⇒ void

This method returns an undefined value.

This method adds a secret as environment variable to the container.

Parameters:



350
351
352
353
354
# File 'ecs/container_definition.rb', line 350

def add_secret(name, secret)
  Jsii::Type.check_type(name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name")
  Jsii::Type.check_type(secret, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlNlY3JldCJ9")), "secret")
  jsii_call_method("addSecret", [name, secret])
end

#add_to_execution_policy(statement) ⇒ void

This method returns an undefined value.

This method adds the specified statement to the IAM task execution policy in the task definition.

Parameters:



360
361
362
363
# File 'ecs/container_definition.rb', line 360

def add_to_execution_policy(statement)
  Jsii::Type.check_type(statement, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLlBvbGljeVN0YXRlbWVudCJ9")), "statement")
  jsii_call_method("addToExecutionPolicy", [statement])
end

#add_ulimits(*ulimits) ⇒ void

This method returns an undefined value.

This method adds one or more ulimits to the container.

Parameters:



369
370
371
372
373
374
375
# File 'ecs/container_definition.rb', line 369

def add_ulimits(*ulimits)
  ulimits.map! { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::Ulimit.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 }
  ulimits.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlVsaW1pdCJ9")), "ulimits[#{index}]")
  end
  jsii_call_method("addUlimits", [*ulimits])
end

#add_volumes_from(*volumes_from) ⇒ void

This method returns an undefined value.

This method adds one or more volumes to the container.

Parameters:



381
382
383
384
385
386
387
# File 'ecs/container_definition.rb', line 381

def add_volumes_from(*volumes_from)
  volumes_from.map! { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::VolumeFrom.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 }
  volumes_from.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlZvbHVtZUZyb20ifQ==")), "volumesFrom[#{index}]")
  end
  jsii_call_method("addVolumesFrom", [*volumes_from])
end

#container_dependenciesArray<AWSCDK::ECS::ContainerDependency>

An array dependencies defined for container startup and shutdown.



85
86
87
# File 'ecs/container_definition.rb', line 85

def container_dependencies()
  jsii_get_property("containerDependencies")
end

#container_nameString

The name of this container.

Returns:

  • (String)


92
93
94
# File 'ecs/container_definition.rb', line 92

def container_name()
  jsii_get_property("containerName")
end

#container_portNumeric

The port the container will listen on.

Returns:

  • (Numeric)


99
100
101
# File 'ecs/container_definition.rb', line 99

def container_port()
  jsii_get_property("containerPort")
end

#cpuNumeric?

The number of cpu units reserved for the container.

Returns:

  • (Numeric, nil)


181
182
183
# File 'ecs/container_definition.rb', line 181

def cpu()
  jsii_get_property("cpu")
end

#credential_specsArray<AWSCDK::ECS::CredentialSpecConfig>?

The crdential specifications for this container.

Returns:



188
189
190
# File 'ecs/container_definition.rb', line 188

def credential_specs()
  jsii_get_property("credentialSpecs")
end

#environment_filesArray<AWSCDK::ECS::EnvironmentFileConfig>?

The environment files for this container.

Returns:



195
196
197
# File 'ecs/container_definition.rb', line 195

def environment_files()
  jsii_get_property("environmentFiles")
end

#essentialBoolean

Specifies whether the container will be marked essential.

If the essential parameter of a container is marked as true, and that container fails or stops for any reason, all other containers that are part of the task are stopped. If the essential parameter of a container is marked as false, then its failure does not affect the rest of the containers in a task.

If this parameter is omitted, a container is assumed to be essential.

Returns:

  • (Boolean)


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

def essential()
  jsii_get_property("essential")
end

#find_port_mapping(container_port, protocol) ⇒ AWSCDK::ECS::PortMapping?

Returns the host port for the requested container port if it exists.

Parameters:

Returns:



394
395
396
397
398
# File 'ecs/container_definition.rb', line 394

def find_port_mapping(container_port, protocol)
  Jsii::Type.check_type(container_port, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "containerPort")
  Jsii::Type.check_type(protocol, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlByb3RvY29sIn0=")), "protocol")
  jsii_call_method("findPortMapping", [container_port, protocol])
end

#find_port_mapping_by_name(name) ⇒ AWSCDK::ECS::PortMapping?

Returns the port mapping with the given name, if it exists.

Parameters:

  • name (String)

Returns:



404
405
406
407
# File 'ecs/container_definition.rb', line 404

def find_port_mapping_by_name(name)
  Jsii::Type.check_type(name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name")
  jsii_call_method("findPortMappingByName", [name])
end

#image_nameString

The name of the image referenced by this container.

Returns:

  • (String)


120
121
122
# File 'ecs/container_definition.rb', line 120

def image_name()
  jsii_get_property("imageName")
end

#ingress_portNumeric

The inbound rules associated with the security group the task or service will use.

This property is only used for tasks that use the awsvpc network mode.

Returns:

  • (Numeric)


129
130
131
# File 'ecs/container_definition.rb', line 129

def ingress_port()
  jsii_get_property("ingressPort")
end

#linux_parametersAWSCDK::ECS::LinuxParameters?

The Linux-specific modifications that are applied to the container, such as Linux kernel capabilities.



202
203
204
# File 'ecs/container_definition.rb', line 202

def linux_parameters()
  jsii_get_property("linuxParameters")
end

#log_driver_configAWSCDK::ECS::LogDriverConfig?

The log configuration specification for the container.



209
210
211
# File 'ecs/container_definition.rb', line 209

def log_driver_config()
  jsii_get_property("logDriverConfig")
end

#memory_limit_specifiedBoolean

Whether there was at least one memory limit specified in this definition.

Returns:

  • (Boolean)


136
137
138
# File 'ecs/container_definition.rb', line 136

def memory_limit_specified()
  jsii_get_property("memoryLimitSpecified")
end

#mount_pointsArray<AWSCDK::ECS::MountPoint>

The mount points for data volumes in your container.

Returns:



143
144
145
# File 'ecs/container_definition.rb', line 143

def mount_points()
  jsii_get_property("mountPoints")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


66
67
68
# File 'ecs/container_definition.rb', line 66

def node()
  jsii_get_property("node")
end

#port_mappingsArray<AWSCDK::ECS::PortMapping>

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.

Returns:



153
154
155
# File 'ecs/container_definition.rb', line 153

def port_mappings()
  jsii_get_property("portMappings")
end

#pseudo_terminalBoolean?

Specifies whether a TTY must be allocated for this container.

Returns:

  • (Boolean, nil)


216
217
218
# File 'ecs/container_definition.rb', line 216

def pseudo_terminal()
  jsii_get_property("pseudoTerminal")
end

#references_secret_json_fieldBoolean?

Whether this container definition references a specific JSON field of a secret stored in Secrets Manager.

Returns:

  • (Boolean, nil)


223
224
225
# File 'ecs/container_definition.rb', line 223

def references_secret_json_field()
  jsii_get_property("referencesSecretJsonField")
end

#render_container_definition(_task_definition = nil) ⇒ AWSCDK::ECS::CfnTaskDefinition::ContainerDefinitionProperty

Render this container definition to a CloudFormation object.



413
414
415
416
# File 'ecs/container_definition.rb', line 413

def render_container_definition(_task_definition = nil)
  Jsii::Type.check_type(_task_definition, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlRhc2tEZWZpbml0aW9uIn0=")), "_taskDefinition") unless _task_definition.nil?
  jsii_call_method("renderContainerDefinition", [_task_definition])
end

#task_definitionAWSCDK::ECS::TaskDefinition

The name of the task definition that includes this container definition.



160
161
162
# File 'ecs/container_definition.rb', line 160

def task_definition()
  jsii_get_property("taskDefinition")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


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

def to_string()
  jsii_call_method("toString", [])
end

#ulimitsArray<AWSCDK::ECS::Ulimit>

An array of ulimits to set in the container.

Returns:



167
168
169
# File 'ecs/container_definition.rb', line 167

def ulimits()
  jsii_get_property("ulimits")
end

#volumes_fromArray<AWSCDK::ECS::VolumeFrom>

The data volumes to mount from another container in the same task definition.

Returns:



174
175
176
# File 'ecs/container_definition.rb', line 174

def volumes_from()
  jsii_get_property("volumesFrom")
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



243
244
245
246
247
248
# File 'ecs/container_definition.rb', line 243

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end