Skip to content

create_application_status_check

create_application_status_check(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    health_check_paths: Optional[HealthCheckPathRequestList] = None,
    aggregation: Optional[AggregationStatusEnum] = None,
    protocol: Optional[NetworkProtocolEnum] = None,
    port: Optional[PortNumber] = None,
    path: Optional[String] = None,
    device_index: Optional[Integer] = None,
    ip_version: Optional[IpVersionEnum] = None,
    ip_scope: Optional[IpScopeEnum] = None,
    interval: Optional[Integer] = None,
    timeout: Optional[Integer] = None,
    failure_threshold: Optional[Integer] = None,
    success_threshold: Optional[Integer] = None,
    status_code_matcher: Optional[String] = None,
    initialization_grace_period_seconds: Optional[
        InitializationGracePeriodSeconds
    ] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    client_token: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
) -> CreateApplicationStatusCheckResult

Creates an application status check for monitoring the health of applications running on your instances. You can configure the protocol, port, path, and thresholds for the health check. The following rules apply:

  • You can create a maximum of 50 application status checks for each account.

  • You must associate the check with instances or tags using AssociateApplicationStatusCheck before health checks start.

  • You must set the Timeout value to less than the Interval value.

  • You must start the Path with a forward slash (/). Default: /.

  • You can specify Aggregation as included or excluded. If you do not specify a value, it defaults to included, which means the check contributes to the instance-level application status.

  • You can use the following default values: Interval is 60 seconds, Timeout is 6 seconds, FailureThreshold is 2, SuccessThreshold is 2, StatusCodeMatcher is 200, InitializationGracePeriodSeconds is 300 seconds.

  • You can tag the application status check during creation. For more information, see Tag your Amazon EC2 resources.

Parameters:

  • health_check_paths (Optional[HealthCheckPathRequestList], default: None ) –

    The health check paths to use for the application status check. Health check paths define the network path from a source subnet to one or more destination subnets for cross-Availability Zone or Availability Zone to Local Zone health checking. If omitted, health checks are performed in the same subnet as the instance.

  • aggregation (Optional[AggregationStatusEnum], default: None ) –

    The aggregation setting for the application status check. When set to included, the result of this check contributes to the instance-level application status reported by DescribeApplicationStatus. When set to excluded, the check runs independently and does not affect the instance-level status. Valid values: included | excluded.

  • protocol (Optional[NetworkProtocolEnum], default: None ) –

    The protocol to use for the health check. Valid values: http | https.

  • port (Optional[PortNumber], default: None ) –

    The port to use for the health check. Valid values: 1 to 65535.

  • path (Optional[String], default: None ) –

    The URL path to use for the health check HTTP request (for example, /health or /status).

  • device_index (Optional[Integer], default: None ) –

    The index of the network device to use for the health check. The value must be greater than or equal to 0.

  • ip_version (Optional[IpVersionEnum], default: None ) –

    The IP version to use for the health check. Valid values: ipv4 and ipv6.

  • ip_scope (Optional[IpScopeEnum], default: None ) –

    The IP scope to use for the health check. Valid value: private.

  • interval (Optional[Integer], default: None ) –

    The interval, in seconds, between health checks. Valid value: 60.

  • timeout (Optional[Integer], default: None ) –

    The amount of time, in seconds, to wait for a health check response before considering it failed. Valid values: 1 to 30. The value must be less than Interval.

  • failure_threshold (Optional[Integer], default: None ) –

    The number of consecutive failed health checks before the application status is considered impaired. The value must be greater than 0.

  • success_threshold (Optional[Integer], default: None ) –

    The number of consecutive successful health checks before the application status is considered healthy. The value must be greater than 0.

  • status_code_matcher (Optional[String], default: None ) –

    The HTTP status codes that indicate a successful health check response. Specify a comma-separated list of individual status codes or ranges, for example, 200,202,300-399. For a range, the first value must be less than the second value. Maximum length: 64 characters. Default: 200.

  • initialization_grace_period_seconds (Optional[InitializationGracePeriodSeconds], default: None ) –

    The number of seconds to wait before starting health checks after an instance is launched. Valid values: 1 to 600.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to apply to the application status check.

  • client_token (Optional[String], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure that the operation completes no more than one time. If you retry a request with the same token, the service ignores the request but does not return an error. For more information, see Ensuring idempotency.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Raises:

Examples:

To create an application status check This example creates an application status check that monitors HTTP health on port 80.

>>> client.create_application_status_check(protocol='http', port=80, path='/health', aggregation='included')
Source code in docs_src/capo_ec2/_services/ec2.py
def create_application_status_check(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    health_check_paths: Optional[
        "capo_ec2.types.health_check_path_request_list.HealthCheckPathRequestList"
    ] = None,
    aggregation: Optional[
        "capo_ec2.types.aggregation_status_enum.AggregationStatusEnum"
    ] = None,
    protocol: Optional[
        "capo_ec2.types.network_protocol_enum.NetworkProtocolEnum"
    ] = None,
    port: Optional["capo_ec2.types.port_number.PortNumber"] = None,
    path: Optional["capo_ec2.types.string.String"] = None,
    device_index: Optional["capo_ec2.types.integer.Integer"] = None,
    ip_version: Optional["capo_ec2.types.ip_version_enum.IpVersionEnum"] = None,
    ip_scope: Optional["capo_ec2.types.ip_scope_enum.IpScopeEnum"] = None,
    interval: Optional["capo_ec2.types.integer.Integer"] = None,
    timeout: Optional["capo_ec2.types.integer.Integer"] = None,
    failure_threshold: Optional["capo_ec2.types.integer.Integer"] = None,
    success_threshold: Optional["capo_ec2.types.integer.Integer"] = None,
    status_code_matcher: Optional["capo_ec2.types.string.String"] = None,
    initialization_grace_period_seconds: Optional[
        "capo_ec2.types.initialization_grace_period_seconds.InitializationGracePeriodSeconds"
    ] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.create_application_status_check_result.CreateApplicationStatusCheckResult":
    """<p>Creates an application status check for monitoring the health of applications running on your instances. You can configure the protocol, port, path, and thresholds for the health check. The following rules apply:</p> <ul> <li> <p>You can create a maximum of 50 application status checks for each account.</p> </li> <li> <p>You must associate the check with instances or tags using <code>AssociateApplicationStatusCheck</code> before health checks start.</p> </li> <li> <p>You must set the <code>Timeout</code> value to less than the <code>Interval</code> value.</p> </li> <li> <p>You must start the <code>Path</code> with a forward slash (<code>/</code>). Default: <code>/</code>.</p> </li> <li> <p>You can specify <code>Aggregation</code> as <code>included</code> or <code>excluded</code>. If you do not specify a value, it defaults to <code>included</code>, which means the check contributes to the instance-level application status.</p> </li> <li> <p>You can use the following default values: <code>Interval</code> is 60 seconds, <code>Timeout</code> is 6 seconds, <code>FailureThreshold</code> is 2, <code>SuccessThreshold</code> is 2, <code>StatusCodeMatcher</code> is <code>200</code>, <code>InitializationGracePeriodSeconds</code> is 300 seconds.</p> </li> <li> <p>You can tag the application status check during creation. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html">Tag your Amazon EC2 resources</a>.</p> </li> </ul>

    Args:
        health_check_paths: <p>The health check paths to use for the application status check. Health check paths define the network path from a source subnet to one or more destination subnets for cross-Availability Zone or Availability Zone to Local Zone health checking. If omitted, health checks are performed in the same subnet as the instance.</p>
        aggregation: <p>The aggregation setting for the application status check. When set to <code>included</code>, the result of this check contributes to the instance-level application status reported by <code>DescribeApplicationStatus</code>. When set to <code>excluded</code>, the check runs independently and does not affect the instance-level status. Valid values: <code>included</code> | <code>excluded</code>.</p>
        protocol: <p>The protocol to use for the health check. Valid values: <code>http</code> | <code>https</code>.</p>
        port: <p>The port to use for the health check. Valid values: 1 to 65535.</p>
        path: <p>The URL path to use for the health check HTTP request (for example, <code>/health</code> or <code>/status</code>).</p>
        device_index: <p>The index of the network device to use for the health check. The value must be greater than or equal to 0.</p>
        ip_version: <p>The IP version to use for the health check. Valid values: <code>ipv4</code> and <code>ipv6</code>.</p>
        ip_scope: <p>The IP scope to use for the health check. Valid value: <code>private</code>.</p>
        interval: <p>The interval, in seconds, between health checks. Valid value: 60.</p>
        timeout: <p>The amount of time, in seconds, to wait for a health check response before considering it failed. Valid values: 1 to 30. The value must be less than <code>Interval</code>.</p>
        failure_threshold: <p>The number of consecutive failed health checks before the application status is considered impaired. The value must be greater than 0.</p>
        success_threshold: <p>The number of consecutive successful health checks before the application status is considered healthy. The value must be greater than 0.</p>
        status_code_matcher: <p>The HTTP status codes that indicate a successful health check response. Specify a comma-separated list of individual status codes or ranges, for example, <code>200,202,300-399</code>. For a range, the first value must be less than the second value. Maximum length: 64 characters. Default: <code>200</code>.</p>
        initialization_grace_period_seconds: <p>The number of seconds to wait before starting health checks after an instance is launched. Valid values: 1 to 600.</p>
        tag_specifications: <p>The tags to apply to the application status check.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure that the operation completes no more than one time. If you retry a request with the same token, the service ignores the request but does not return an error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a>.</p>
        dry_run: <p>Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create an application status check
        This example creates an application status check that monitors HTTP health on port 80.

        >>> client.create_application_status_check(protocol='http', port=80, path='/health', aggregation='included')
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.create_application_status_check_request.CreateApplicationStatusCheckRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_application_status_check_result.CreateApplicationStatusCheckResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_application_status_check

        output, http_response = (
            capo_ec2._operations.amazon_ec2.create_application_status_check.create_application_status_check(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateApplicationStatusCheck")
    )
    input_: capo_ec2.types.create_application_status_check_request.CreateApplicationStatusCheckRequest = {}
    if health_check_paths is not None:
        input_["health_check_paths"] = health_check_paths
    if aggregation is not None:
        input_["aggregation"] = aggregation
    if protocol is not None:
        input_["protocol"] = protocol
    if port is not None:
        input_["port"] = port
    if path is not None:
        input_["path"] = path
    if device_index is not None:
        input_["device_index"] = device_index
    if ip_version is not None:
        input_["ip_version"] = ip_version
    if ip_scope is not None:
        input_["ip_scope"] = ip_scope
    if interval is not None:
        input_["interval"] = interval
    if timeout is not None:
        input_["timeout"] = timeout
    if failure_threshold is not None:
        input_["failure_threshold"] = failure_threshold
    if success_threshold is not None:
        input_["success_threshold"] = success_threshold
    if status_code_matcher is not None:
        input_["status_code_matcher"] = status_code_matcher
    if initialization_grace_period_seconds is not None:
        input_["initialization_grace_period_seconds"] = (
            initialization_grace_period_seconds
        )
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if dry_run is not None:
        input_["dry_run"] = dry_run

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output