Skip to content

cancel_lifecycle_execution async

cancel_lifecycle_execution(
    lifecycle_execution_id: LifecycleExecutionId,
    client_token: ClientToken,
    *,
    config_overrides: Optional[AsyncimagebuilderClientConfig] = None,
) -> CancelLifecycleExecutionResponse

Cancels a lifecycle execution – a single run of lifecycle actions that a lifecycle policy or a StartResourceStateUpdate request started. You can only cancel an execution that hasn't reached a terminal state. Cancellation is asynchronous and doesn't undo completed lifecycle actions.

Parameters:

  • lifecycle_execution_id (LifecycleExecutionId) –

    Identifies the specific runtime instance of the image lifecycle to cancel.

  • client_token (ClientToken) –

    A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see Ensuring idempotency in the Amazon EC2 API Reference.

Raises:

  • CallRateLimitExceededException –

    You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.

  • ClientException –

    A generic client error. This error usually indicates that the request failed a validation check, such as when a downstream service rejects a configured value.

  • ForbiddenException –

    You are not authorized to perform the requested operation.

  • IdempotentParameterMismatchException –

    You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.

  • InvalidRequestException –

    The request is malformed or otherwise invalid. Verify the request and try again.

  • ResourceInUseException –

    The resource that you are trying to operate on is currently in use. Review the message details and retry later.

  • ServiceException –

    An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.

  • ServiceUnavailableException –

    The service is unable to process your request at this time.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Cancel a lifecycle execution The following example cancels the scheduled resource state update associated with the specified lifecycle execution ID before it runs.

>>> await client.cancel_lifecycle_execution(lifecycle_execution_id='lce-401aefc3-a829-46f6-8fc2-91497988a503', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE97531')
Source code in docs_src/capo_imagebuilder/_services/async_imagebuilder.py
async def cancel_lifecycle_execution(
    self,
    lifecycle_execution_id: "capo_imagebuilder.types.lifecycle_execution_id.LifecycleExecutionId",
    client_token: "capo_imagebuilder.types.client_token.ClientToken",
    *,
    config_overrides: Optional[AsyncimagebuilderClientConfig] = None,
) -> "capo_imagebuilder.types.cancel_lifecycle_execution_response.CancelLifecycleExecutionResponse":
    """<p>Cancels a lifecycle execution – a single run of lifecycle actions that a lifecycle policy or a <a>StartResourceStateUpdate</a> request started. You can only cancel an execution that hasn't reached a terminal state. Cancellation is asynchronous and doesn't undo completed lifecycle actions.</p>

    Args:
        lifecycle_execution_id: <p>Identifies the specific runtime instance of the image lifecycle to cancel.</p>
        client_token: <p>A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a> in the <i>Amazon EC2 API Reference</i>.</p>

    Raises:
        capo_imagebuilder.errors.call_rate_limit_exceeded_exception.CallRateLimitExceededException: <p>You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.</p>
        capo_imagebuilder.errors.client_exception.ClientException: <p>A generic client error. This error usually indicates that the request failed a validation check, such as when a downstream service rejects a configured value.</p>
        capo_imagebuilder.errors.forbidden_exception.ForbiddenException: <p>You are not authorized to perform the requested operation.</p>
        capo_imagebuilder.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.</p>
        capo_imagebuilder.errors.invalid_request_exception.InvalidRequestException: <p>The request is malformed or otherwise invalid. Verify the request and try again.</p>
        capo_imagebuilder.errors.resource_in_use_exception.ResourceInUseException: <p>The resource that you are trying to operate on is currently in use. Review the message details and retry later.</p>
        capo_imagebuilder.errors.service_exception.ServiceException: <p>An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.</p>
        capo_imagebuilder.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is unable to process your request at this time.</p>
        capo_imagebuilder.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Cancel a lifecycle execution
        The following example cancels the scheduled resource state update associated with the specified lifecycle execution ID before it runs.

        >>> await client.cancel_lifecycle_execution(lifecycle_execution_id='lce-401aefc3-a829-46f6-8fc2-91497988a503', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE97531')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_imagebuilder.types.cancel_lifecycle_execution_request.CancelLifecycleExecutionRequest]",
    ) -> AsyncOperationResponse[
        "capo_imagebuilder.types.cancel_lifecycle_execution_response.CancelLifecycleExecutionResponse"
    ]:
        import capo_imagebuilder._operations.imagebuilder.cancel_lifecycle_execution

        (
            output,
            http_response,
        ) = await capo_imagebuilder._operations.imagebuilder.cancel_lifecycle_execution.async_cancel_lifecycle_execution(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CancelLifecycleExecution")
    )
    input_: capo_imagebuilder.types.cancel_lifecycle_execution_request.CancelLifecycleExecutionRequest = {
        "lifecycle_execution_id": lifecycle_execution_id,
        "client_token": client_token,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output