Class: AWSCDK::Batch::ECSEC2ContainerDefinitionProps

Inherits:
ECSContainerDefinitionProps
  • Object
show all
Defined in:
batch/ecsec2_container_definition_props.rb

Overview

Props to configure an EcsEc2ContainerDefinition.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cpu:, image:, memory:, command: nil, enable_execute_command: nil, environment: nil, execution_role: nil, job_role: nil, linux_parameters: nil, logging: nil, readonly_root_filesystem: nil, secrets: nil, user: nil, volumes: nil, gpu: nil, privileged: nil, ulimits: nil) ⇒ ECSEC2ContainerDefinitionProps

Returns a new instance of ECSEC2ContainerDefinitionProps.

Parameters:

  • cpu (Numeric)

    The number of vCPUs reserved for the container.

  • image (AWSCDK::ECS::ContainerImage)

    The image that this container will run.

  • memory (AWSCDK::Size)

    The memory hard limit present to the container.

  • command (Array<String>, nil) (defaults to: nil)

    The command that's passed to the container.

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

    Determines whether execute command functionality is turned on for this task.

  • environment (Hash{String => String}, nil) (defaults to: nil)

    The environment variables to pass to a container.

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

    The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.

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

    The role that the container can assume.

  • linux_parameters (AWSCDK::Batch::LinuxParameters, nil) (defaults to: nil)

    Linux-specific modifications that are applied to the container, such as details for device mappings.

  • logging (AWSCDK::ECS::LogDriver, nil) (defaults to: nil)

    The loging configuration for this Job.

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

    Gives the container readonly access to its root filesystem.

  • secrets (Hash{String => AWSCDK::Batch::Secret}, nil) (defaults to: nil)

    A map from environment variable names to the secrets for the container.

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

    The user name to use inside the container.

  • volumes (Array<AWSCDK::Batch::ECSVolume>, nil) (defaults to: nil)

    The volumes to mount to this container.

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

    The number of physical GPUs to reserve for the container.

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

    When this parameter is true, the container is given elevated permissions on the host container instance (similar to the root user).

  • ulimits (Array<AWSCDK::Batch::Ulimit>, nil) (defaults to: nil)

    Limits to set for the user this docker container will run as.



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
# File 'batch/ecsec2_container_definition_props.rb', line 24

def initialize(cpu:, image:, memory:, command: nil, enable_execute_command: nil, environment: nil, execution_role: nil, job_role: nil, linux_parameters: nil, logging: nil, readonly_root_filesystem: nil, secrets: nil, user: nil, volumes: nil, gpu: nil, privileged: nil, ulimits: nil)
  @cpu = cpu
  Jsii::Type.check_type(@cpu, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "cpu")
  @image = image
  Jsii::Type.check_type(@image, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNvbnRhaW5lckltYWdlIn0=")), "image")
  @memory = memory
  Jsii::Type.check_type(@memory, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplIn0=")), "memory")
  @command = command
  Jsii::Type.check_type(@command, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "command") unless @command.nil?
  @enable_execute_command = enable_execute_command
  Jsii::Type.check_type(@enable_execute_command, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "enableExecuteCommand") unless @enable_execute_command.nil?
  @environment = environment
  Jsii::Type.check_type(@environment, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "environment") unless @environment.nil?
  @execution_role = execution_role
  Jsii::Type.check_type(@execution_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "executionRole") unless @execution_role.nil?
  @job_role = job_role
  Jsii::Type.check_type(@job_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "jobRole") unless @job_role.nil?
  @linux_parameters = linux_parameters
  Jsii::Type.check_type(@linux_parameters, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYmF0Y2guTGludXhQYXJhbWV0ZXJzIn0=")), "linuxParameters") unless @linux_parameters.nil?
  @logging = logging
  Jsii::Type.check_type(@logging, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkxvZ0RyaXZlciJ9")), "logging") unless @logging.nil?
  @readonly_root_filesystem = readonly_root_filesystem
  Jsii::Type.check_type(@readonly_root_filesystem, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "readonlyRootFilesystem") unless @readonly_root_filesystem.nil?
  @secrets = secrets
  Jsii::Type.check_type(@secrets, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19iYXRjaC5TZWNyZXQifSwia2luZCI6Im1hcCJ9fQ==")), "secrets") unless @secrets.nil?
  @user = user
  Jsii::Type.check_type(@user, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "user") unless @user.nil?
  @volumes = volumes
  Jsii::Type.check_type(@volumes, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19iYXRjaC5FY3NWb2x1bWUifSwia2luZCI6ImFycmF5In19")), "volumes") unless @volumes.nil?
  @gpu = gpu
  Jsii::Type.check_type(@gpu, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "gpu") unless @gpu.nil?
  @privileged = privileged
  Jsii::Type.check_type(@privileged, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "privileged") unless @privileged.nil?
  @ulimits = ulimits.is_a?(Array) ? ulimits.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::Batch::Ulimit.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : ulimits
  Jsii::Type.check_type(@ulimits, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19iYXRjaC5VbGltaXQifSwia2luZCI6ImFycmF5In19")), "ulimits") unless @ulimits.nil?
end

Instance Attribute Details

#commandArray<String>? (readonly)

Note:

Default: - no command

The command that's passed to the container.

Returns:

  • (Array<String>, nil)

See Also:



84
85
86
# File 'batch/ecsec2_container_definition_props.rb', line 84

def command
  @command
end

#cpuNumeric (readonly)

The number of vCPUs reserved for the container.

Each vCPU is equivalent to 1,024 CPU shares. For containers running on EC2 resources, you must specify at least one vCPU.

Returns:

  • (Numeric)


67
68
69
# File 'batch/ecsec2_container_definition_props.rb', line 67

def cpu
  @cpu
end

#enable_execute_commandBoolean? (readonly)

Note:

Default: undefined - AWS Batch default is false

Determines whether execute command functionality is turned on for this task.

If true, execute command functionality is turned on all the containers in the task.

This allows you to use ECS Exec to access containers interactively. When enabled, a job role with required SSM permissions will be created automatically if no job role is provided. If a job role is alreadyprovided, the required permissions will be added to it.



96
97
98
# File 'batch/ecsec2_container_definition_props.rb', line 96

def enable_execute_command
  @enable_execute_command
end

#environmentHash{String => String}? (readonly)

Note:

Default: - no environment variables

The environment variables to pass to a container.

Cannot start with AWS_BATCH. We don't recommend using plaintext environment variables for sensitive information, such as credential data.

Returns:

  • (Hash{String => String}, nil)


104
105
106
# File 'batch/ecsec2_container_definition_props.rb', line 104

def environment
  @environment
end

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

Note:

Default: - a Role will be created

The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.



110
111
112
# File 'batch/ecsec2_container_definition_props.rb', line 110

def execution_role
  @execution_role
end

#gpuNumeric? (readonly)

Note:

Default: - no gpus

The number of physical GPUs to reserve for the container.

Make sure that the number of GPUs reserved for all containers in a job doesn't exceed the number of available GPUs on the compute resource that the job is launched on.

Returns:

  • (Numeric, nil)


160
161
162
# File 'batch/ecsec2_container_definition_props.rb', line 160

def gpu
  @gpu
end

#imageAWSCDK::ECS::ContainerImage (readonly)

The image that this container will run.



71
72
73
# File 'batch/ecsec2_container_definition_props.rb', line 71

def image
  @image
end

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

Note:

Default: - no job role

The role that the container can assume.



116
117
118
# File 'batch/ecsec2_container_definition_props.rb', line 116

def job_role
  @job_role
end

#linux_parametersAWSCDK::Batch::LinuxParameters? (readonly)

Note:

Default: none

Linux-specific modifications that are applied to the container, such as details for device mappings.



121
122
123
# File 'batch/ecsec2_container_definition_props.rb', line 121

def linux_parameters
  @linux_parameters
end

#loggingAWSCDK::ECS::LogDriver? (readonly)

Note:

Default: - the log configuration of the Docker daemon

The loging configuration for this Job.

Returns:



126
127
128
# File 'batch/ecsec2_container_definition_props.rb', line 126

def logging
  @logging
end

#memoryAWSCDK::Size (readonly)

The memory hard limit present to the container.

If your container attempts to exceed the memory specified, the container is terminated. You must specify at least 4 MiB of memory for a job.

Returns:



78
79
80
# File 'batch/ecsec2_container_definition_props.rb', line 78

def memory
  @memory
end

#privilegedBoolean? (readonly)

Note:

Default: false

When this parameter is true, the container is given elevated permissions on the host container instance (similar to the root user).

Returns:

  • (Boolean, nil)


165
166
167
# File 'batch/ecsec2_container_definition_props.rb', line 165

def privileged
  @privileged
end

#readonly_root_filesystemBoolean? (readonly)

Note:

Default: false

Gives the container readonly access to its root filesystem.

Returns:

  • (Boolean, nil)


131
132
133
# File 'batch/ecsec2_container_definition_props.rb', line 131

def readonly_root_filesystem
  @readonly_root_filesystem
end

#secretsHash{String => AWSCDK::Batch::Secret}? (readonly)

Note:

Default: - no secrets

A map from environment variable names to the secrets for the container.

Allows your job definitions to reference the secret by the environment variable name defined in this property.



140
141
142
# File 'batch/ecsec2_container_definition_props.rb', line 140

def secrets
  @secrets
end

#ulimitsArray<AWSCDK::Batch::Ulimit>? (readonly)

Note:

Default: - no ulimits

Limits to set for the user this docker container will run as.

Returns:



170
171
172
# File 'batch/ecsec2_container_definition_props.rb', line 170

def ulimits
  @ulimits
end

#userString? (readonly)

Note:

Default: - no user

The user name to use inside the container.

Returns:

  • (String, nil)


145
146
147
# File 'batch/ecsec2_container_definition_props.rb', line 145

def user
  @user
end

#volumesArray<AWSCDK::Batch::ECSVolume>? (readonly)

Note:

Default: - no volumes

The volumes to mount to this container.

Automatically added to the job definition.

Returns:



152
153
154
# File 'batch/ecsec2_container_definition_props.rb', line 152

def volumes
  @volumes
end

Class Method Details

.jsii_propertiesObject



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'batch/ecsec2_container_definition_props.rb', line 172

def self.jsii_properties
  {
    :cpu => "cpu",
    :image => "image",
    :memory => "memory",
    :command => "command",
    :enable_execute_command => "enableExecuteCommand",
    :environment => "environment",
    :execution_role => "executionRole",
    :job_role => "jobRole",
    :linux_parameters => "linuxParameters",
    :logging => "logging",
    :readonly_root_filesystem => "readonlyRootFilesystem",
    :secrets => "secrets",
    :user => "user",
    :volumes => "volumes",
    :gpu => "gpu",
    :privileged => "privileged",
    :ulimits => "ulimits",
  }
end

Instance Method Details

#to_jsiiObject



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'batch/ecsec2_container_definition_props.rb', line 194

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "cpu" => @cpu,
    "image" => @image,
    "memory" => @memory,
    "command" => @command,
    "enableExecuteCommand" => @enable_execute_command,
    "environment" => @environment,
    "executionRole" => @execution_role,
    "jobRole" => @job_role,
    "linuxParameters" => @linux_parameters,
    "logging" => @logging,
    "readonlyRootFilesystem" => @readonly_root_filesystem,
    "secrets" => @secrets,
    "user" => @user,
    "volumes" => @volumes,
    "gpu" => @gpu,
    "privileged" => @privileged,
    "ulimits" => @ulimits,
  })
  result.compact
end