Deletes an Image Builder image resource. This does not delete any EC2 AMIs or ECR container images that are created during the image build process. You must clean those up separately, using the appropriate Amazon EC2 or Amazon ECR console actions, or API or CLI commands.
The request fails with ResourceDependencyException if the image is shared with other accounts, or if other resources depend on it. It also fails while the image build is still running. Cancel an in-progress build with CancelImageCreation before you delete the image.
Parameters:
-
image_build_version_arn
(ImageBuildVersionArn)
–
The Amazon Resource Name (ARN) of the Image Builder image resource to delete.
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.
-
InvalidRequestException
–
The request is malformed or otherwise invalid. Verify the request and try again.
-
ResourceDependencyException
–
You have attempted to mutate or delete a resource with a dependency that prohibits this action. See the error message for more details.
-
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:
Delete an image build version
The following example deletes the Image Builder image record for the specified build version - EC2 AMIs or ECR container images that the build created aren't removed.
>>> client.delete_image(image_build_version_arn='arn:aws:imagebuilder:us-west-2:111122223333:image/my-example-recipe/1.0.0/1')
Source code in docs_src/capo_imagebuilder/_services/imagebuilder.py
| def delete_image(
self,
image_build_version_arn: "capo_imagebuilder.types.image_build_version_arn.ImageBuildVersionArn",
*,
config_overrides: Optional[imagebuilderClientConfig] = None,
) -> "capo_imagebuilder.types.delete_image_response.DeleteImageResponse":
"""<p>Deletes an Image Builder image resource. This does not delete any EC2 AMIs or ECR container images that are created during the image build process. You must clean those up separately, using the appropriate Amazon EC2 or Amazon ECR console actions, or API or CLI commands.</p> <p>The request fails with <code>ResourceDependencyException</code> if the image is shared with other accounts, or if other resources depend on it. It also fails while the image build is still running. Cancel an in-progress build with <a>CancelImageCreation</a> before you delete the image.</p> <ul> <li> <p>To deregister an EC2 Linux AMI, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/deregister-ami.html">Deregister your Linux AMI</a> in the <i> <i>Amazon EC2 User Guide</i> </i>.</p> </li> <li> <p>To deregister an EC2 Windows AMI, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/deregister-ami.html">Deregister your Windows AMI</a> in the <i> <i>Amazon EC2 Windows Guide</i> </i>.</p> </li> <li> <p>To delete a container image from Amazon ECR, see <a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/delete_image.html">Deleting an image</a> in the <i>Amazon ECR User Guide</i>.</p> </li> </ul>
Args:
image_build_version_arn: <p>The Amazon Resource Name (ARN) of the Image Builder image resource to delete.</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.invalid_request_exception.InvalidRequestException: <p>The request is malformed or otherwise invalid. Verify the request and try again.</p>
capo_imagebuilder.errors.resource_dependency_exception.ResourceDependencyException: <p>You have attempted to mutate or delete a resource with a dependency that prohibits this action. See the error message for more details.</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:
Delete an image build version
The following example deletes the Image Builder image record for the specified build version - EC2 AMIs or ECR container images that the build created aren't removed.
>>> client.delete_image(image_build_version_arn='arn:aws:imagebuilder:us-west-2:111122223333:image/my-example-recipe/1.0.0/1')
"""
def _handler(
req: "OperationRequest[capo_imagebuilder.types.delete_image_request.DeleteImageRequest]",
) -> OperationResponse[
"capo_imagebuilder.types.delete_image_response.DeleteImageResponse"
]:
import capo_imagebuilder._operations.imagebuilder.delete_image
output, http_response = (
capo_imagebuilder._operations.imagebuilder.delete_image.delete_image(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("DeleteImage")
)
input_: capo_imagebuilder.types.delete_image_request.DeleteImageRequest = {
"image_build_version_arn": image_build_version_arn
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|