Skip to content

associate_application_status_check async

associate_application_status_check(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    application_status_check_id: Optional[ApplicationStatusCheckId] = None,
    target_tag_associations: Optional[CustomKeyValuePairRequestSet] = None,
    instance_ids: Optional[InstanceIdList] = None,
    client_token: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
) -> AssociateApplicationStatusCheckResult

Associates an application status check with instances or tags. Once you create an association, health monitoring automatically begins for the specified instances or for instances that match the specified tags. The following rules apply:

  • You must specify either TargetTagAssociations or InstanceIds, but not both. Specifying both results in an InvalidParameterCombination error.

  • You must own the application status check. The check must already exist in your account.

  • You must not leave tag keys blank.

  • You can create a maximum of 50 tag associations for each application status check.

  • You can use DisassociateApplicationStatusCheck to remove associations.

  • You can associate tags so that the application status check automatically monitors all current and future instances that have the specified tags.

Parameters:

  • application_status_check_id (Optional[ApplicationStatusCheckId], default: None ) –

    The ID of the application status check to associate.

  • target_tag_associations (Optional[CustomKeyValuePairRequestSet], default: None ) –

    The tags to associate the application status check with. Each tag is a key-value pair. When you associate tags, the application status check automatically monitors all instances that have the specified tags.

  • instance_ids (Optional[InstanceIdList], default: None ) –

    The IDs of the instances to associate with 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 associate an application status check with tags This example associates an application status check with instances matching the specified tag.

>>> await client.associate_application_status_check(application_status_check_id='asc-0123456789abcdef0', target_tag_associations=[{'Key': 'env', 'Value': 'prod'}])
Source code in docs_src/capo_ec2/_services/async_ec2.py
async def associate_application_status_check(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    application_status_check_id: Optional[
        "capo_ec2.types.application_status_check_id.ApplicationStatusCheckId"
    ] = None,
    target_tag_associations: Optional[
        "capo_ec2.types.custom_key_value_pair_request_set.CustomKeyValuePairRequestSet"
    ] = None,
    instance_ids: Optional["capo_ec2.types.instance_id_list.InstanceIdList"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.associate_application_status_check_result.AssociateApplicationStatusCheckResult":
    """<p>Associates an application status check with instances or <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html">tags</a>. Once you create an association, health monitoring automatically begins for the specified instances or for instances that match the specified tags. The following rules apply:</p> <ul> <li> <p>You must specify either <code>TargetTagAssociations</code> or <code>InstanceIds</code>, but not both. Specifying both results in an <code>InvalidParameterCombination</code> error.</p> </li> <li> <p>You must own the application status check. The check must already exist in your account.</p> </li> <li> <p>You must not leave tag keys blank.</p> </li> <li> <p>You can create a maximum of 50 tag associations for each application status check.</p> </li> <li> <p>You can use <code>DisassociateApplicationStatusCheck</code> to remove associations.</p> </li> <li> <p>You can associate <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html">tags</a> so that the application status check automatically monitors all current and future instances that have the specified tags.</p> </li> </ul>

    Args:
        application_status_check_id: <p>The ID of the application status check to associate.</p>
        target_tag_associations: <p>The <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html">tags</a> to associate the application status check with. Each tag is a key-value pair. When you associate tags, the application status check automatically monitors all instances that have the specified tags.</p>
        instance_ids: <p>The IDs of the instances to associate with 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 associate an application status check with tags
        This example associates an application status check with instances matching the specified tag.

        >>> await client.associate_application_status_check(application_status_check_id='asc-0123456789abcdef0', target_tag_associations=[{'Key': 'env', 'Value': 'prod'}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.associate_application_status_check_request.AssociateApplicationStatusCheckRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.associate_application_status_check_result.AssociateApplicationStatusCheckResult"
    ]:
        import capo_ec2._operations.amazon_ec2.associate_application_status_check

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.associate_application_status_check.async_associate_application_status_check(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssociateApplicationStatusCheck")
    )
    input_: capo_ec2.types.associate_application_status_check_request.AssociateApplicationStatusCheckRequest = {}
    if application_status_check_id is not None:
        input_["application_status_check_id"] = application_status_check_id
    if target_tag_associations is not None:
        input_["target_tag_associations"] = target_tag_associations
    if instance_ids is not None:
        input_["instance_ids"] = instance_ids
    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 = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output