Class: AWSCDK::Batch::ECSContainerDefinitionProps

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
batch/ecs_container_definition_props.rb

Overview

Props to configure an EcsContainerDefinition.

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) ⇒ ECSContainerDefinitionProps

Returns a new instance of ECSContainerDefinitionProps.

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.



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

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)
  @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?
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:



75
76
77
# File 'batch/ecs_container_definition_props.rb', line 75

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)


58
59
60
# File 'batch/ecs_container_definition_props.rb', line 58

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.



87
88
89
# File 'batch/ecs_container_definition_props.rb', line 87

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)


95
96
97
# File 'batch/ecs_container_definition_props.rb', line 95

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.



101
102
103
# File 'batch/ecs_container_definition_props.rb', line 101

def execution_role
  @execution_role
end

#imageAWSCDK::ECS::ContainerImage (readonly)

The image that this container will run.



62
63
64
# File 'batch/ecs_container_definition_props.rb', line 62

def image
  @image
end

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

Note:

Default: - no job role

The role that the container can assume.



107
108
109
# File 'batch/ecs_container_definition_props.rb', line 107

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.



112
113
114
# File 'batch/ecs_container_definition_props.rb', line 112

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:



117
118
119
# File 'batch/ecs_container_definition_props.rb', line 117

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:



69
70
71
# File 'batch/ecs_container_definition_props.rb', line 69

def memory
  @memory
end

#readonly_root_filesystemBoolean? (readonly)

Note:

Default: false

Gives the container readonly access to its root filesystem.

Returns:

  • (Boolean, nil)


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

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.



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

def secrets
  @secrets
end

#userString? (readonly)

Note:

Default: - no user

The user name to use inside the container.

Returns:

  • (String, nil)


136
137
138
# File 'batch/ecs_container_definition_props.rb', line 136

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:



143
144
145
# File 'batch/ecs_container_definition_props.rb', line 143

def volumes
  @volumes
end

Class Method Details

.jsii_propertiesObject



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'batch/ecs_container_definition_props.rb', line 145

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",
  }
end

Instance Method Details

#to_jsiiObject



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'batch/ecs_container_definition_props.rb', line 164

def to_jsii
  result = {}
  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,
  })
  result.compact
end