Class: AWSCDK::ECS::CfnTaskDefinition::HealthCheckProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
ecs/cfn_task_definition.rb

Overview

The HealthCheck property specifies an object representing a container health check.

Health check parameters that are specified in a container definition override any Docker health checks that exist in the container image (such as those specified in a parent image or from the image's Dockerfile). This configuration maps to the HEALTHCHECK parameter of docker run.

The Amazon ECS container agent only monitors and reports on the health checks specified in the task definition. Amazon ECS does not monitor Docker health checks that are embedded in a container image and not specified in the container definition. Health check parameters that are specified in a container definition override any Docker health checks that exist in the container image.

If a task is run manually, and not as part of a service, the task will continue its lifecycle regardless of its health status. For tasks that are part of a service, if the task reports as unhealthy then the task will be stopped and the service scheduler will replace it.

The following are notes about container health check support:

  • Container health checks require version 1.17.0 or greater of the Amazon ECS container agent. For more information, see Updating the Amazon ECS Container Agent .
  • Container health checks are supported for Fargate tasks if you are using platform version 1.1.0 or greater. For more information, see AWS Fargate Platform Versions .
  • Container health checks are not supported for tasks that are part of a service that is configured to use a Classic Load Balancer.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command: nil, interval: nil, retries: nil, start_period: nil, timeout: nil) ⇒ HealthCheckProperty

Returns a new instance of HealthCheckProperty.

Parameters:

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

    A string array representing the command that the container runs to determine if it is healthy.

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

    The time period in seconds between each health check execution.

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

    The number of times to retry a failed health check before the container is considered unhealthy.

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

    The optional grace period to provide containers time to bootstrap before failed health checks count towards the maximum number of retries.

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

    The time period in seconds to wait for a health check to succeed before it is considered a failure.



2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
# File 'ecs/cfn_task_definition.rb', line 2025

def initialize(command: nil, interval: nil, retries: nil, start_period: nil, timeout: nil)
  @command = command
  Jsii::Type.check_type(@command, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "command") unless @command.nil?
  @interval = interval
  Jsii::Type.check_type(@interval, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "interval") unless @interval.nil?
  @retries = retries
  Jsii::Type.check_type(@retries, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "retries") unless @retries.nil?
  @start_period = start_period
  Jsii::Type.check_type(@start_period, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "startPeriod") unless @start_period.nil?
  @timeout = timeout
  Jsii::Type.check_type(@timeout, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "timeout") unless @timeout.nil?
end

Instance Attribute Details

#commandArray<String>? (readonly)

A string array representing the command that the container runs to determine if it is healthy.

The string array must start with CMD to run the command arguments directly, or CMD-SHELL to run the command with the container's default shell.

When you use the AWS Management Console JSON panel, the AWS Command Line Interface , or the APIs, enclose the list of commands in double quotes and brackets.

[ "CMD-SHELL", "curl -f http://localhost/ || exit 1" ]

You don't include the double quotes and brackets when you use the AWS Management Console.

CMD-SHELL, curl -f http://localhost/ || exit 1

An exit code of 0 indicates success, and non-zero exit code indicates failure. For more information, see HealthCheck in the docker container create command.



2054
2055
2056
# File 'ecs/cfn_task_definition.rb', line 2054

def command
  @command
end

#intervalNumeric? (readonly)

The time period in seconds between each health check execution.

You may specify between 5 and 300 seconds. The default value is 30 seconds. This value applies only when you specify a command .



2061
2062
2063
# File 'ecs/cfn_task_definition.rb', line 2061

def interval
  @interval
end

#retriesNumeric? (readonly)

The number of times to retry a failed health check before the container is considered unhealthy.

You may specify between 1 and 10 retries. The default value is 3. This value applies only when you specify a command .



2068
2069
2070
# File 'ecs/cfn_task_definition.rb', line 2068

def retries
  @retries
end

#start_periodNumeric? (readonly)

The optional grace period to provide containers time to bootstrap before failed health checks count towards the maximum number of retries.

You can specify between 0 and 300 seconds. By default, the start_period is off. This value applies only when you specify a command .

If a health check succeeds within the start_period , then the container is considered healthy and any subsequent failures count toward the maximum number of retries.



2077
2078
2079
# File 'ecs/cfn_task_definition.rb', line 2077

def start_period
  @start_period
end

#timeoutNumeric? (readonly)

The time period in seconds to wait for a health check to succeed before it is considered a failure.

You may specify between 2 and 60 seconds. The default value is 5. This value applies only when you specify a command .



2084
2085
2086
# File 'ecs/cfn_task_definition.rb', line 2084

def timeout
  @timeout
end

Class Method Details

.jsii_propertiesObject



2086
2087
2088
2089
2090
2091
2092
2093
2094
# File 'ecs/cfn_task_definition.rb', line 2086

def self.jsii_properties
  {
    :command => "command",
    :interval => "interval",
    :retries => "retries",
    :start_period => "startPeriod",
    :timeout => "timeout",
  }
end

Instance Method Details

#to_jsiiObject



2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
# File 'ecs/cfn_task_definition.rb', line 2096

def to_jsii
  result = {}
  result.merge!({
    "command" => @command,
    "interval" => @interval,
    "retries" => @retries,
    "startPeriod" => @start_period,
    "timeout" => @timeout,
  })
  result.compact
end