Skip to content

export_image

export_image(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    client_token: Optional[String] = None,
    description: Optional[String] = None,
    disk_image_format: Optional[DiskImageFormat] = None,
    dry_run: Optional[Boolean] = None,
    image_id: Optional[ImageId] = None,
    s3_export_location: Optional[ExportTaskS3LocationRequest] = None,
    role_name: Optional[String] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
) -> ExportImageResult

Exports an Amazon Machine Image (AMI) to a VM file. For more information, see Exporting a VM directly from an Amazon Machine Image (AMI) in the VM Import/Export User Guide.

Parameters:

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

    Token to enable idempotency for export image requests.

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

    A description of the image being exported. The maximum length is 255 characters.

  • disk_image_format (Optional[DiskImageFormat], default: None ) –

    The disk image format.

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

    Checks whether you have the required permissions for the action, 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.

  • image_id (Optional[ImageId], default: None ) –

    The ID of the image.

  • s3_export_location (Optional[ExportTaskS3LocationRequest], default: None ) –

    The Amazon S3 bucket for the destination image. The destination bucket must exist.

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

    The name of the role that grants VM Import/Export permission to export images to your Amazon S3 bucket. If this parameter is not specified, the default role is named 'vmimport'.

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

    The tags to apply to the export image task during creation.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def export_image(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    description: Optional["capo_ec2.types.string.String"] = None,
    disk_image_format: Optional[
        "capo_ec2.types.disk_image_format.DiskImageFormat"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    image_id: Optional["capo_ec2.types.image_id.ImageId"] = None,
    s3_export_location: Optional[
        "capo_ec2.types.export_task_s3_location_request.ExportTaskS3LocationRequest"
    ] = None,
    role_name: Optional["capo_ec2.types.string.String"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
) -> "capo_ec2.types.export_image_result.ExportImageResult":
    """<p>Exports an Amazon Machine Image (AMI) to a VM file. For more information, see <a href="https://docs.aws.amazon.com/vm-import/latest/userguide/vmexport_image.html">Exporting a VM directly from an Amazon Machine Image (AMI)</a> in the <i>VM Import/Export User Guide</i>.</p>

    Args:
        client_token: <p>Token to enable idempotency for export image requests.</p>
        description: <p>A description of the image being exported. The maximum length is 255 characters.</p>
        disk_image_format: <p>The disk image format.</p>
        dry_run: <p>Checks whether you have the required permissions for the action, 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>
        image_id: <p>The ID of the image.</p>
        s3_export_location: <p>The Amazon S3 bucket for the destination image. The destination bucket must exist.</p>
        role_name: <p>The name of the role that grants VM Import/Export permission to export images to your Amazon S3 bucket. If this parameter is not specified, the default role is named 'vmimport'.</p>
        tag_specifications: <p>The tags to apply to the export image task during creation.</p>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.export_image_request.ExportImageRequest]",
    ) -> OperationResponse["capo_ec2.types.export_image_result.ExportImageResult"]:
        import capo_ec2._operations.amazon_ec2.export_image

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ExportImage")
    )
    input_: capo_ec2.types.export_image_request.ExportImageRequest = {}
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if disk_image_format is not None:
        input_["disk_image_format"] = disk_image_format
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if image_id is not None:
        input_["image_id"] = image_id
    if s3_export_location is not None:
        input_["s3_export_location"] = s3_export_location
    if role_name is not None:
        input_["role_name"] = role_name
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications

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