Class: AWSCDK::ECSPatterns::ScheduledEC2TaskImageOptions

Inherits:
ScheduledTaskImageProps
  • Object
show all
Defined in:
ecs_patterns/scheduled_ec2_task_image_options.rb

Overview

The properties for the ScheduledEc2Task using an image.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image:, command: nil, container_name: nil, environment: nil, log_driver: nil, secrets: nil, cpu: nil, memory_limit_mib: nil, memory_reservation_mib: nil) ⇒ ScheduledEC2TaskImageOptions

Returns a new instance of ScheduledEC2TaskImageOptions.

Parameters:

  • image (AWSCDK::ECS::ContainerImage)

    The image used to start a container.

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

    The command that is passed to the container.

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

    Optional name for the container added.

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

    The environment variables to pass to the container.

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

    The log driver to use.

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

    The secret to expose to the container as an environment variable.

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

    The minimum number of CPU units to reserve for the container.

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

    The hard limit (in MiB) of memory to present to the container.

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

    The soft limit (in MiB) of memory to reserve for the container.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 16

def initialize(image:, command: nil, container_name: nil, environment: nil, log_driver: nil, secrets: nil, cpu: nil, memory_limit_mib: nil, memory_reservation_mib: nil)
  @image = image
  Jsii::Type.check_type(@image, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNvbnRhaW5lckltYWdlIn0=")), "image")
  @command = command
  Jsii::Type.check_type(@command, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "command") unless @command.nil?
  @container_name = container_name
  Jsii::Type.check_type(@container_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "containerName") unless @container_name.nil?
  @environment = environment
  Jsii::Type.check_type(@environment, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "environment") unless @environment.nil?
  @log_driver = log_driver
  Jsii::Type.check_type(@log_driver, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkxvZ0RyaXZlciJ9")), "logDriver") unless @log_driver.nil?
  @secrets = secrets
  Jsii::Type.check_type(@secrets, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuU2VjcmV0In0sImtpbmQiOiJtYXAifX0=")), "secrets") unless @secrets.nil?
  @cpu = cpu
  Jsii::Type.check_type(@cpu, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "cpu") unless @cpu.nil?
  @memory_limit_mib = memory_limit_mib
  Jsii::Type.check_type(@memory_limit_mib, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "memoryLimitMiB") unless @memory_limit_mib.nil?
  @memory_reservation_mib = memory_reservation_mib
  Jsii::Type.check_type(@memory_reservation_mib, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "memoryReservationMiB") unless @memory_reservation_mib.nil?
end

Instance Attribute Details

#commandArray<String>? (readonly)

Note:

Default: - CMD value built into container image.

The command that is passed to the container.

If you provide a shell command as a single string, you have to quote command-line arguments.

Returns:

  • (Array<String>, nil)


50
51
52
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 50

def command
  @command
end

#container_nameString? (readonly)

Note:

Default: - ScheduledContainer

Optional name for the container added.

Returns:

  • (String, nil)


55
56
57
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 55

def container_name
  @container_name
end

#cpuNumeric? (readonly)

Note:

Default: none

The minimum number of CPU units to reserve for the container.

Returns:

  • (Numeric, nil)


75
76
77
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 75

def cpu
  @cpu
end

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

Note:

Default: none

The environment variables to pass to the container.

Returns:

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


60
61
62
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 60

def environment
  @environment
end

#imageAWSCDK::ECS::ContainerImage (readonly)

Note:

Default: - none

The image used to start a container.

Image or taskDefinition must be specified, but not both.



43
44
45
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 43

def image
  @image
end

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

Note:

Default: - AwsLogDriver if enableLogging is true

The log driver to use.

Returns:



65
66
67
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 65

def log_driver
  @log_driver
end

#memory_limit_mibNumeric? (readonly)

Note:

Default: - No memory limit.

The hard limit (in MiB) of memory to present to the container.

If your container attempts to exceed the allocated memory, the container is terminated.

At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services.

Returns:

  • (Numeric, nil)


85
86
87
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 85

def memory_limit_mib
  @memory_limit_mib
end

#memory_reservation_mibNumeric? (readonly)

Note:

Default: - No memory reserved.

The soft limit (in MiB) of memory to reserve for the container.

When system memory is under contention, Docker attempts to keep the container memory within the limit. If the container requires more memory, it can consume up to the value specified by the Memory property or all of the available memory on the container instance—whichever comes first.

At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services.

Returns:

  • (Numeric, nil)


97
98
99
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 97

def memory_reservation_mib
  @memory_reservation_mib
end

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

Note:

Default: - No secret environment variables.

The secret to expose to the container as an environment variable.

Returns:



70
71
72
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 70

def secrets
  @secrets
end

Class Method Details

.jsii_propertiesObject



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 99

def self.jsii_properties
  {
    :image => "image",
    :command => "command",
    :container_name => "containerName",
    :environment => "environment",
    :log_driver => "logDriver",
    :secrets => "secrets",
    :cpu => "cpu",
    :memory_limit_mib => "memoryLimitMiB",
    :memory_reservation_mib => "memoryReservationMiB",
  }
end

Instance Method Details

#to_jsiiObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'ecs_patterns/scheduled_ec2_task_image_options.rb', line 113

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "image" => @image,
    "command" => @command,
    "containerName" => @container_name,
    "environment" => @environment,
    "logDriver" => @log_driver,
    "secrets" => @secrets,
    "cpu" => @cpu,
    "memoryLimitMiB" => @memory_limit_mib,
    "memoryReservationMiB" => @memory_reservation_mib,
  })
  result.compact
end