Skip to content

import_volume

import_volume(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    availability_zone_id: Optional[AvailabilityZoneId] = None,
    dry_run: Optional[Boolean] = None,
    availability_zone: Optional[String] = None,
    image: Optional[DiskImageDetail] = None,
    description: Optional[String] = None,
    volume: Optional[VolumeDetail] = None,
) -> ImportVolumeResult

This API action supports only single-volume VMs. To import multi-volume VMs, use ImportImage instead. To import a disk to a snapshot, use ImportSnapshot instead.

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

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:

  • availability_zone_id (Optional[AvailabilityZoneId], default: None ) –

    The ID of the Availability Zone for the resulting EBS volume.

    Either AvailabilityZone or AvailabilityZoneId must be specified, but not both.

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

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

    The Availability Zone for the resulting EBS volume.

    Either AvailabilityZone or AvailabilityZoneId must be specified, but not both.

  • image (Optional[DiskImageDetail], default: None ) –

    The disk image.

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

    A description of the volume.

  • volume (Optional[VolumeDetail], default: None ) –

    The volume size.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def import_volume(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    availability_zone_id: Optional[
        "capo_ec2.types.availability_zone_id.AvailabilityZoneId"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    availability_zone: Optional["capo_ec2.types.string.String"] = None,
    image: Optional["capo_ec2.types.disk_image_detail.DiskImageDetail"] = None,
    description: Optional["capo_ec2.types.string.String"] = None,
    volume: Optional["capo_ec2.types.volume_detail.VolumeDetail"] = None,
) -> "capo_ec2.types.import_volume_result.ImportVolumeResult":
    """<note> <p>This API action supports only single-volume VMs. To import multi-volume VMs, use <a>ImportImage</a> instead. To import a disk to a snapshot, use <a>ImportSnapshot</a> instead.</p> </note> <p>Creates an import volume task using metadata from the specified disk image.</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:
        availability_zone_id: <p>The ID of the Availability Zone for the resulting EBS volume.</p> <p>Either <code>AvailabilityZone</code> or <code>AvailabilityZoneId</code> must be specified, but not both.</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>
        availability_zone: <p>The Availability Zone for the resulting EBS volume.</p> <p>Either <code>AvailabilityZone</code> or <code>AvailabilityZoneId</code> must be specified, but not both.</p>
        image: <p>The disk image.</p>
        description: <p>A description of the volume.</p>
        volume: <p>The volume size.</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_volume_request.ImportVolumeRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.import_volume_result.ImportVolumeResult"
    ]:
        import capo_ec2._operations.amazon_ec2.import_volume

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

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

        return capo_ec2.types.import_volume_request.redact_sensitive(input_)

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

        return capo_ec2.types.import_volume_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "ImportVolume", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_ec2.types.import_volume_request.ImportVolumeRequest = {}
    if availability_zone_id is not None:
        input_["availability_zone_id"] = availability_zone_id
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if availability_zone is not None:
        input_["availability_zone"] = availability_zone
    if image is not None:
        input_["image"] = image
    if description is not None:
        input_["description"] = description
    if volume is not None:
        input_["volume"] = volume

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