Skip to content

cancel_image_creation async

cancel_image_creation(
    image_build_version_arn: ImageBuildVersionArn,
    client_token: ClientToken,
    *,
    config_overrides: Optional[AsyncimagebuilderClientConfig] = None,
) -> CancelImageCreationResponse

Cancels the creation of an image. This operation can only be used on images in a non-terminal state. Cancellation is asynchronous: the request returns immediately, then Image Builder stops the running build and moves the image to the CANCELLED state. Output resources that the build already created, such as AMIs and snapshots, aren't removed.

Parameters:

  • image_build_version_arn (ImageBuildVersionArn) –

    The Amazon Resource Name (ARN) of the image that you want to cancel creation for.

  • 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 an image build The following example cancels a build that is in progress for the specified image build version.

>>> await client.cancel_image_creation(image_build_version_arn='arn:aws:imagebuilder:us-west-2:111122223333:image/my-example-recipe/1.0.0/1', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE77777')
Source code in docs_src/capo_imagebuilder/_services/async_imagebuilder.py
async def cancel_image_creation(
    self,
    image_build_version_arn: "capo_imagebuilder.types.image_build_version_arn.ImageBuildVersionArn",
    client_token: "capo_imagebuilder.types.client_token.ClientToken",
    *,
    config_overrides: Optional[AsyncimagebuilderClientConfig] = None,
) -> "capo_imagebuilder.types.cancel_image_creation_response.CancelImageCreationResponse":
    """<p>Cancels the creation of an image. This operation can only be used on images in a non-terminal state. Cancellation is asynchronous: the request returns immediately, then Image Builder stops the running build and moves the image to the <code>CANCELLED</code> state. Output resources that the build already created, such as AMIs and snapshots, aren't removed.</p>

    Args:
        image_build_version_arn: <p>The Amazon Resource Name (ARN) of the image that you want to cancel creation for.</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 an image build
        The following example cancels a build that is in progress for the specified image build version.

        >>> await client.cancel_image_creation(image_build_version_arn='arn:aws:imagebuilder:us-west-2:111122223333:image/my-example-recipe/1.0.0/1', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE77777')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_imagebuilder.types.cancel_image_creation_request.CancelImageCreationRequest]",
    ) -> AsyncOperationResponse[
        "capo_imagebuilder.types.cancel_image_creation_response.CancelImageCreationResponse"
    ]:
        import capo_imagebuilder._operations.imagebuilder.cancel_image_creation

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CancelImageCreation")
    )
    input_: capo_imagebuilder.types.cancel_image_creation_request.CancelImageCreationRequest = {
        "image_build_version_arn": image_build_version_arn,
        "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