Skip to content

copy_volumes async

copy_volumes(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    source_volume_id: Optional[VolumeId] = None,
    iops: Optional[Integer] = None,
    size: Optional[Integer] = None,
    volume_type: Optional[VolumeType] = None,
    dry_run: Optional[Boolean] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    multi_attach_enabled: Optional[Boolean] = None,
    throughput: Optional[Integer] = None,
    client_token: Optional[String] = None,
    encrypted: Optional[Boolean] = None,
    kms_key_id: Optional[KmsKeyId] = None,
) -> CopyVolumesResult

Creates a crash-consistent, point-in-time copy of an existing Amazon EBS volume within the same Availability Zone. The volume copy can be attached to an Amazon EC2 instance once it reaches the available state. For more information, see Copy an Amazon EBS volume.

Parameters:

  • source_volume_id (Optional[VolumeId], default: None ) –

    The ID of the source EBS volume to copy.

  • iops (Optional[Integer], default: None ) –

    The number of I/O operations per second (IOPS) to provision for the volume copy. Required for io1 and io2 volumes. Optional for gp3 volumes. Omit for all other volume types. Full provisioned IOPS performance can be achieved only once the volume copy is fully initialized.

    Valid ranges:

    • gp3: 3,000 (default) - 80,000 IOPS

    • io1: 100 - 64,000 IOPS

    • io2: 100 - 256,000 IOPS

    Instances built on the Nitro System can support up to 256,000 IOPS. Other instances can support up to 32,000 IOPS.

  • size (Optional[Integer], default: None ) –

    The size of the volume copy, in GiBs. The size must be equal to or greater than the size of the source volume. If not specified, the size defaults to the size of the source volume.

    Maximum supported sizes:

    • gp2: 16,384 GiB

    • gp3: 65,536 GiB

    • io1: 16,384 GiB

    • io2: 65,536 GiB

    • st1 and sc1: 16,384 GiB

    • standard: 1024 GiB

  • volume_type (Optional[VolumeType], default: None ) –

    The volume type for the volume copy. If not specified, the volume type defaults to gp2.

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

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

    The tags to apply to the volume copy during creation.

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

    Indicates whether to enable Amazon EBS Multi-Attach for the volume copy. If you enable Multi-Attach, you can attach the volume to up to 16 Nitro instances in the same Availability Zone simultaneously. Supported with io1 and io2 volumes only. For more information, see Amazon EBS Multi-Attach.

  • throughput (Optional[Integer], default: None ) –

    The throughput to provision for the volume copy, in MiB/s. Supported for gp3 volumes only. Omit for all other volume types. Full provisioned throughput performance can be achieved only once the volume copy is fully initialized.

    Valid Range: 125 - 2000 MiB/s

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

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensure Idempotency.

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

    Indicates whether to encrypt the volume copy. If the source volume is encrypted, the service always encrypts the copy regardless of this value. Set to true to encrypt a copy of an unencrypted source volume during the copy operation. If you set Encrypted to true but do not specify KmsKeyId, the service uses the default KMS key for EBS encryption in your account.

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

    The identifier of the KMS key to use for encryption of the volume copy. Specify a symmetric encryption KMS key. You can specify a KMS key using the key ID, key ARN, alias name, or alias ARN. If you set Encrypted to true but do not specify this parameter, the service uses the default KMS key for EBS encryption in your account. For cross-account volume copies, this must be a KMS key in the calling account.

Raises:

Source code in docs_src/capo_ec2/_services/async_ec2.py
async def copy_volumes(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    source_volume_id: Optional["capo_ec2.types.volume_id.VolumeId"] = None,
    iops: Optional["capo_ec2.types.integer.Integer"] = None,
    size: Optional["capo_ec2.types.integer.Integer"] = None,
    volume_type: Optional["capo_ec2.types.volume_type.VolumeType"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    multi_attach_enabled: Optional["capo_ec2.types.boolean.Boolean"] = None,
    throughput: Optional["capo_ec2.types.integer.Integer"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    encrypted: Optional["capo_ec2.types.boolean.Boolean"] = None,
    kms_key_id: Optional["capo_ec2.types.kms_key_id.KmsKeyId"] = None,
) -> "capo_ec2.types.copy_volumes_result.CopyVolumesResult":
    """<p>Creates a crash-consistent, point-in-time copy of an existing Amazon EBS volume within the same Availability Zone. The volume copy can be attached to an Amazon EC2 instance once it reaches the <code>available</code> state. For more information, see <a href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-copying-volume.html">Copy an Amazon EBS volume</a>.</p>

    Args:
        source_volume_id: <p>The ID of the source EBS volume to copy.</p>
        iops: <p>The number of I/O operations per second (IOPS) to provision for the volume copy. Required for <code>io1</code> and <code>io2</code> volumes. Optional for <code>gp3</code> volumes. Omit for all other volume types. Full provisioned IOPS performance can be achieved only once the volume copy is fully initialized. </p> <p>Valid ranges:</p> <ul> <li> <p>gp3: <code>3,000 </code>(<i>default</i>)<code> - 80,000</code> IOPS</p> </li> <li> <p>io1: <code>100 - 64,000</code> IOPS</p> </li> <li> <p>io2: <code>100 - 256,000</code> IOPS</p> </li> </ul> <note> <p> <a href="https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html"> Instances built on the Nitro System</a> can support up to 256,000 IOPS. Other instances can support up to 32,000 IOPS.</p> </note>
        size: <p>The size of the volume copy, in GiBs. The size must be equal to or greater than the size of the source volume. If not specified, the size defaults to the size of the source volume.</p> <p>Maximum supported sizes:</p> <ul> <li> <p>gp2: <code>16,384</code> GiB</p> </li> <li> <p>gp3: <code>65,536</code> GiB</p> </li> <li> <p>io1: <code>16,384</code> GiB</p> </li> <li> <p>io2: <code>65,536</code> GiB</p> </li> <li> <p>st1 and sc1: <code>16,384</code> GiB</p> </li> <li> <p>standard: <code>1024</code> GiB</p> </li> </ul>
        volume_type: <p>The volume type for the volume copy. If not specified, the volume type defaults to <code>gp2</code>.</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>
        tag_specifications: <p>The tags to apply to the volume copy during creation.</p>
        multi_attach_enabled: <p>Indicates whether to enable Amazon EBS Multi-Attach for the volume copy. If you enable Multi-Attach, you can attach the volume to up to 16 Nitro instances in the same Availability Zone simultaneously. Supported with <code>io1</code> and <code>io2</code> volumes only. For more information, see <a href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-volumes-multi.html"> Amazon EBS Multi-Attach</a>.</p>
        throughput: <p>The throughput to provision for the volume copy, in MiB/s. Supported for <code>gp3</code> volumes only. Omit for all other volume types. Full provisioned throughput performance can be achieved only once the volume copy is fully initialized.</p> <p>Valid Range: <code>125 - 2000</code> MiB/s</p> <p></p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/ec2/latest/devguide/ec2-api-idempotency.html"> Ensure Idempotency</a>.</p>
        encrypted: <p>Indicates whether to encrypt the volume copy. If the source volume is encrypted, the service always encrypts the copy regardless of this value. Set to <code>true</code> to encrypt a copy of an unencrypted source volume during the copy operation. If you set <code>Encrypted</code> to <code>true</code> but do not specify <code>KmsKeyId</code>, the service uses the default KMS key for EBS encryption in your account.</p>
        kms_key_id: <p>The identifier of the KMS key to use for encryption of the volume copy. Specify a symmetric encryption KMS key. You can specify a KMS key using the key ID, key ARN, alias name, or alias ARN. If you set <code>Encrypted</code> to <code>true</code> but do not specify this parameter, the service uses the default KMS key for EBS encryption in your account. For cross-account volume copies, this must be a KMS key in the calling account.</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.copy_volumes_request.CopyVolumesRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.copy_volumes_result.CopyVolumesResult"
    ]:
        import capo_ec2._operations.amazon_ec2.copy_volumes

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CopyVolumes")
    )
    input_: capo_ec2.types.copy_volumes_request.CopyVolumesRequest = {}
    if source_volume_id is not None:
        input_["source_volume_id"] = source_volume_id
    if iops is not None:
        input_["iops"] = iops
    if size is not None:
        input_["size"] = size
    if volume_type is not None:
        input_["volume_type"] = volume_type
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if multi_attach_enabled is not None:
        input_["multi_attach_enabled"] = multi_attach_enabled
    if throughput is not None:
        input_["throughput"] = throughput
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if encrypted is not None:
        input_["encrypted"] = encrypted
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id

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