Skip to content

import_snapshot async

import_snapshot(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    client_data: Optional[ClientData] = None,
    client_token: Optional[String] = None,
    description: Optional[String] = None,
    disk_container: Optional[SnapshotDiskContainer] = None,
    dry_run: Optional[Boolean] = None,
    encrypted: Optional[Boolean] = None,
    kms_key_id: Optional[KmsKeyId] = None,
    role_name: Optional[String] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
) -> ImportSnapshotResult

Imports a disk into an EBS snapshot.

For more information, see Importing a disk as a snapshot using VM Import/Export in the VM Import/Export User Guide.

Parameters:

  • client_data (Optional[ClientData], default: None ) –

    The client-specific data.

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

    Token to enable idempotency for VM import requests.

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

    The description string for the import snapshot task.

  • disk_container (Optional[SnapshotDiskContainer], default: None ) –

    Information about the disk container.

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

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

    Specifies whether the destination snapshot of the imported image should be encrypted. The default KMS key for EBS is used unless you specify a non-default KMS key using KmsKeyId. For more information, see Amazon EBS Encryption in the Amazon Elastic Compute Cloud User Guide.

  • kms_key_id (Optional[KmsKeyId], default: None ) –

    An identifier for the symmetric KMS key to use when creating the encrypted snapshot. This parameter is only required if you want to use a non-default KMS key; if this parameter is not specified, the default KMS key for EBS is used. If a KmsKeyId is specified, the Encrypted flag must also be set.

    The KMS key identifier may be provided in any of the following formats:

    • Key ID

    • Key alias

    • ARN using key ID. The ID ARN contains the arn:aws:kms namespace, followed by the Region of the key, the Amazon Web Services account ID of the key owner, the key namespace, and then the key ID. For example, arn:aws:kms:us-east-1:012345678910:key/abcd1234-a123-456a-a12b-a123b4cd56ef.

    • ARN using key alias. The alias ARN contains the arn:aws:kms namespace, followed by the Region of the key, the Amazon Web Services account ID of the key owner, the alias namespace, and then the key alias. For example, arn:aws:kms:us-east-1:012345678910:alias/ExampleAlias.

    Amazon Web Services parses KmsKeyId asynchronously, meaning that the action you call may appear to complete even though you provided an invalid identifier. This action will eventually report failure.

    The specified KMS key must exist in the Region that the snapshot is being copied to.

    Amazon EBS does not support asymmetric KMS keys.

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

    The name of the role to use when not using the default role, 'vmimport'.

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

    The tags to apply to the import snapshot task during creation.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def import_snapshot(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    client_data: Optional["capo_ec2.types.client_data.ClientData"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    description: Optional["capo_ec2.types.string.String"] = None,
    disk_container: Optional[
        "capo_ec2.types.snapshot_disk_container.SnapshotDiskContainer"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    encrypted: Optional["capo_ec2.types.boolean.Boolean"] = None,
    kms_key_id: Optional["capo_ec2.types.kms_key_id.KmsKeyId"] = None,
    role_name: Optional["capo_ec2.types.string.String"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
) -> "capo_ec2.types.import_snapshot_result.ImportSnapshotResult":
    """<p>Imports a disk into an EBS snapshot.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-import-snapshot.html">Importing a disk as a snapshot using VM Import/Export</a> in the <i>VM Import/Export User Guide</i>.</p>

    Args:
        client_data: <p>The client-specific data.</p>
        client_token: <p>Token to enable idempotency for VM import requests.</p>
        description: <p>The description string for the import snapshot task.</p>
        disk_container: <p>Information about the disk container.</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>
        encrypted: <p>Specifies whether the destination snapshot of the imported image should be encrypted. The default KMS key for EBS is used unless you specify a non-default KMS key using <code>KmsKeyId</code>. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html">Amazon EBS Encryption</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
        kms_key_id: <p>An identifier for the symmetric KMS key to use when creating the encrypted snapshot. This parameter is only required if you want to use a non-default KMS key; if this parameter is not specified, the default KMS key for EBS is used. If a <code>KmsKeyId</code> is specified, the <code>Encrypted</code> flag must also be set. </p> <p>The KMS key identifier may be provided in any of the following formats: </p> <ul> <li> <p>Key ID</p> </li> <li> <p>Key alias</p> </li> <li> <p>ARN using key ID. The ID ARN contains the <code>arn:aws:kms</code> namespace, followed by the Region of the key, the Amazon Web Services account ID of the key owner, the <code>key</code> namespace, and then the key ID. For example, arn:aws:kms:<i>us-east-1</i>:<i>012345678910</i>:key/<i>abcd1234-a123-456a-a12b-a123b4cd56ef</i>.</p> </li> <li> <p>ARN using key alias. The alias ARN contains the <code>arn:aws:kms</code> namespace, followed by the Region of the key, the Amazon Web Services account ID of the key owner, the <code>alias</code> namespace, and then the key alias. For example, arn:aws:kms:<i>us-east-1</i>:<i>012345678910</i>:alias/<i>ExampleAlias</i>. </p> </li> </ul> <p>Amazon Web Services parses <code>KmsKeyId</code> asynchronously, meaning that the action you call may appear to complete even though you provided an invalid identifier. This action will eventually report failure. </p> <p>The specified KMS key must exist in the Region that the snapshot is being copied to.</p> <p>Amazon EBS does not support asymmetric KMS keys.</p>
        role_name: <p>The name of the role to use when not using the default role, 'vmimport'.</p>
        tag_specifications: <p>The tags to apply to the import snapshot task during creation.</p>

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

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.import_snapshot_request.ImportSnapshotRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.import_snapshot_result.ImportSnapshotResult"
    ]:
        import capo_ec2._operations.amazon_ec2.import_snapshot

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.import_snapshot.async_import_snapshot(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

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

        return capo_ec2.types.import_snapshot_request.redact_sensitive(input_)

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

        return capo_ec2.types.import_snapshot_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "ImportSnapshot",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_ec2.types.import_snapshot_request.ImportSnapshotRequest = {}
    if client_data is not None:
        input_["client_data"] = client_data
    if client_token is not None:
        input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if disk_container is not None:
        input_["disk_container"] = disk_container
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if encrypted is not None:
        input_["encrypted"] = encrypted
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id
    if role_name is not None:
        input_["role_name"] = role_name
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output