Skip to content

import_instance

import_instance(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    description: Optional[String] = None,
    launch_specification: Optional[ImportInstanceLaunchSpecification] = None,
    disk_images: Optional[DiskImageList] = None,
    platform: Optional[PlatformValues] = None,
) -> ImportInstanceResult

We recommend that you use the ImportImage API instead. For more information, see Importing a VM as an image using VM Import/Export in the VM Import/Export User Guide.

Creates an import instance task using metadata from the specified disk image.

This API action supports only single-volume VMs. To import multi-volume VMs, use ImportImage instead.

For information about the import manifest referenced by this API action, see VM Import Manifest.

This API action is not supported by the Command Line Interface (CLI).

Parameters:

  • 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.

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

    A description for the instance being imported.

  • launch_specification (Optional[ImportInstanceLaunchSpecification], default: None ) –

    The launch specification.

  • disk_images (Optional[DiskImageList], default: None ) –

    The disk image.

  • platform (Optional[PlatformValues], default: None ) –

    The instance operating system.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def import_instance(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    description: Optional["capo_ec2.types.string.String"] = None,
    launch_specification: Optional[
        "capo_ec2.types.import_instance_launch_specification.ImportInstanceLaunchSpecification"
    ] = None,
    disk_images: Optional["capo_ec2.types.disk_image_list.DiskImageList"] = None,
    platform: Optional["capo_ec2.types.platform_values.PlatformValues"] = None,
) -> "capo_ec2.types.import_instance_result.ImportInstanceResult":
    """<note> <p>We recommend that you use the <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ImportImage.html"> <code>ImportImage</code> </a> API instead. For more information, see <a href="https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html">Importing a VM as an image using VM Import/Export</a> in the <i>VM Import/Export User Guide</i>.</p> </note> <p>Creates an import instance task using metadata from the specified disk image.</p> <p>This API action supports only single-volume VMs. To import multi-volume VMs, use <a>ImportImage</a> instead.</p> <p>For information about the import manifest referenced by this API action, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/manifest.html">VM Import Manifest</a>.</p> <p>This API action is not supported by the Command Line Interface (CLI).</p>

    Args:
        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>
        description: <p>A description for the instance being imported.</p>
        launch_specification: <p>The launch specification.</p>
        disk_images: <p>The disk image.</p>
        platform: <p>The instance operating system.</p>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.import_instance_request.ImportInstanceRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.import_instance_result.ImportInstanceResult"
    ]:
        import capo_ec2._operations.amazon_ec2.import_instance

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

    def _redact_input(
        input_: "capo_ec2.types.import_instance_request.ImportInstanceRequest",
    ) -> dict[str, Any]:
        import capo_ec2.types.import_instance_request

        return capo_ec2.types.import_instance_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_ec2.types.import_instance_result.ImportInstanceResult",
    ) -> dict[str, Any]:
        import capo_ec2.types.import_instance_result

        return capo_ec2.types.import_instance_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "ImportInstance",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_ec2.types.import_instance_request.ImportInstanceRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if description is not None:
        input_["description"] = description
    if launch_specification is not None:
        input_["launch_specification"] = launch_specification
    if disk_images is not None:
        input_["disk_images"] = disk_images
    if platform is not None:
        input_["platform"] = platform

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