Class: AWSCDK::Batch::ECSFargateContainerDefinitionProps

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

Overview

Props to configure an EcsFargateContainerDefinition.

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, assign_public_ip: nil, ephemeral_storage_size: nil, fargate_cpu_architecture: nil, fargate_operating_system_family: nil, fargate_platform_version: nil) ⇒ ECSFargateContainerDefinitionProps

Returns a new instance of ECSFargateContainerDefinitionProps.

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.

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

    Indicates whether the job has a public IP address.

  • ephemeral_storage_size (AWSCDK::Size, nil) (defaults to: nil)

    The size for ephemeral storage.

  • fargate_cpu_architecture (AWSCDK::ECS::CpuArchitecture, nil) (defaults to: nil)

    The vCPU architecture of Fargate Runtime.

  • fargate_operating_system_family (AWSCDK::ECS::OperatingSystemFamily, nil) (defaults to: nil)

    The operating system for the compute environment.

  • fargate_platform_version (AWSCDK::ECS::FargatePlatformVersion, nil) (defaults to: nil)

    Which version of Fargate to use when running this container.



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
62
63
64
65
# File 'batch/ecs_fargate_container_definition_props.rb', line 26

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, assign_public_ip: nil, ephemeral_storage_size: nil, fargate_cpu_architecture: nil, fargate_operating_system_family: nil, fargate_platform_version: 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?
  @assign_public_ip = assign_public_ip
  Jsii::Type.check_type(@assign_public_ip, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "assignPublicIp") unless @assign_public_ip.nil?
  @ephemeral_storage_size = ephemeral_storage_size
  Jsii::Type.check_type(@ephemeral_storage_size, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplIn0=")), "ephemeralStorageSize") unless @ephemeral_storage_size.nil?
  @fargate_cpu_architecture = fargate_cpu_architecture
  Jsii::Type.check_type(@fargate_cpu_architecture, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNwdUFyY2hpdGVjdHVyZSJ9")), "fargateCpuArchitecture") unless @fargate_cpu_architecture.nil?
  @fargate_operating_system_family = fargate_operating_system_family
  Jsii::Type.check_type(@fargate_operating_system_family, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLk9wZXJhdGluZ1N5c3RlbUZhbWlseSJ9")), "fargateOperatingSystemFamily") unless @fargate_operating_system_family.nil?
  @fargate_platform_version = fargate_platform_version
  Jsii::Type.check_type(@fargate_platform_version, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkZhcmdhdGVQbGF0Zm9ybVZlcnNpb24ifQ==")), "fargatePlatformVersion") unless @fargate_platform_version.nil?
end

Instance Attribute Details

#assign_public_ipBoolean? (readonly)

Note:

Default: false

Indicates whether the job has a public IP address.

For a job that's running on Fargate resources in a private subnet to send outbound traffic to the internet (for example, to pull container images), the private subnet requires a NAT gateway be attached to route requests to the internet.



167
168
169
# File 'batch/ecs_fargate_container_definition_props.rb', line 167

def assign_public_ip
  @assign_public_ip
end

#commandArray<String>? (readonly)

Note:

Default: - no command

The command that's passed to the container.

Returns:

  • (Array<String>, nil)

See Also:



90
91
92
# File 'batch/ecs_fargate_container_definition_props.rb', line 90

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)


73
74
75
# File 'batch/ecs_fargate_container_definition_props.rb', line 73

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.



102
103
104
# File 'batch/ecs_fargate_container_definition_props.rb', line 102

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)


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

def environment
  @environment
end

#ephemeral_storage_sizeAWSCDK::Size? (readonly)

Note:

Default: - 20 GiB

The size for ephemeral storage.

Returns:



172
173
174
# File 'batch/ecs_fargate_container_definition_props.rb', line 172

def ephemeral_storage_size
  @ephemeral_storage_size
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.



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

def execution_role
  @execution_role
end

#fargate_cpu_architectureAWSCDK::ECS::CpuArchitecture? (readonly)

Note:

Default: - X86_64

The vCPU architecture of Fargate Runtime.



177
178
179
# File 'batch/ecs_fargate_container_definition_props.rb', line 177

def fargate_cpu_architecture
  @fargate_cpu_architecture
end

#fargate_operating_system_familyAWSCDK::ECS::OperatingSystemFamily? (readonly)

Note:

Default: - LINUX

The operating system for the compute environment.



182
183
184
# File 'batch/ecs_fargate_container_definition_props.rb', line 182

def fargate_operating_system_family
  @fargate_operating_system_family
end

#fargate_platform_versionAWSCDK::ECS::FargatePlatformVersion? (readonly)

Note:

Default: LATEST

Which version of Fargate to use when running this container.



187
188
189
# File 'batch/ecs_fargate_container_definition_props.rb', line 187

def fargate_platform_version
  @fargate_platform_version
end

#imageAWSCDK::ECS::ContainerImage (readonly)

The image that this container will run.



77
78
79
# File 'batch/ecs_fargate_container_definition_props.rb', line 77

def image
  @image
end

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

Note:

Default: - no job role

The role that the container can assume.



122
123
124
# File 'batch/ecs_fargate_container_definition_props.rb', line 122

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.



127
128
129
# File 'batch/ecs_fargate_container_definition_props.rb', line 127

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:



132
133
134
# File 'batch/ecs_fargate_container_definition_props.rb', line 132

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:



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

def memory
  @memory
end

#readonly_root_filesystemBoolean? (readonly)

Note:

Default: false

Gives the container readonly access to its root filesystem.

Returns:

  • (Boolean, nil)


137
138
139
# File 'batch/ecs_fargate_container_definition_props.rb', line 137

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.



146
147
148
# File 'batch/ecs_fargate_container_definition_props.rb', line 146

def secrets
  @secrets
end

#userString? (readonly)

Note:

Default: - no user

The user name to use inside the container.

Returns:

  • (String, nil)


151
152
153
# File 'batch/ecs_fargate_container_definition_props.rb', line 151

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:



158
159
160
# File 'batch/ecs_fargate_container_definition_props.rb', line 158

def volumes
  @volumes
end

Class Method Details

.jsii_propertiesObject



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'batch/ecs_fargate_container_definition_props.rb', line 189

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",
    :assign_public_ip => "assignPublicIp",
    :ephemeral_storage_size => "ephemeralStorageSize",
    :fargate_cpu_architecture => "fargateCpuArchitecture",
    :fargate_operating_system_family => "fargateOperatingSystemFamily",
    :fargate_platform_version => "fargatePlatformVersion",
  }
end

Instance Method Details

#to_jsiiObject



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'batch/ecs_fargate_container_definition_props.rb', line 213

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,
    "assignPublicIp" => @assign_public_ip,
    "ephemeralStorageSize" => @ephemeral_storage_size,
    "fargateCpuArchitecture" => @fargate_cpu_architecture,
    "fargateOperatingSystemFamily" => @fargate_operating_system_family,
    "fargatePlatformVersion" => @fargate_platform_version,
  })
  result.compact
end