Skip to content

copy_db_cluster_snapshot async

copy_db_cluster_snapshot(
    *,
    config_overrides: Optional[AsyncDocDBClientConfig] = None,
    source_db_cluster_snapshot_identifier: Optional[String] = None,
    target_db_cluster_snapshot_identifier: Optional[String] = None,
    kms_key_id: Optional[String] = None,
    pre_signed_url: Optional[String] = None,
    copy_tags: Optional[BooleanOptional] = None,
    tags: Optional[TagList] = None,
) -> CopyDBClusterSnapshotResult

Copies a snapshot of a cluster.

To copy a cluster snapshot from a shared manual cluster snapshot, SourceDBClusterSnapshotIdentifier must be the Amazon Resource Name (ARN) of the shared cluster snapshot. You can only copy a shared DB cluster snapshot, whether encrypted or not, in the same Amazon Web Services Region.

To cancel the copy operation after it is in progress, delete the target cluster snapshot identified by TargetDBClusterSnapshotIdentifier while that cluster snapshot is in the copying status.

Parameters:

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

    The identifier of the cluster snapshot to copy. This parameter is not case sensitive.

    Constraints:

    • Must specify a valid cluster snapshot in the available state.

    • If the source cluster snapshot is in the same Amazon Web Services Region as the copy, specify a valid snapshot identifier.

    • If the source cluster snapshot is in a different Amazon Web Services Region or owned by another Amazon Web Services account, specify the snapshot ARN.

    Example: my-cluster-snapshot1

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

    The identifier of the new cluster snapshot to create from the source cluster snapshot. This parameter is not case sensitive.

    Constraints:

    • Must contain from 1 to 63 letters, numbers, or hyphens.

    • The first character must be a letter.

    • Cannot end with a hyphen or contain two consecutive hyphens.

    Example: my-cluster-snapshot2

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

    The KMS key ID for an encrypted cluster snapshot. The KMS key ID is the Amazon Resource Name (ARN), KMS key identifier, or the KMS key alias for the KMS encryption key.

    If you copy an encrypted cluster snapshot from your Amazon Web Services account, you can specify a value for KmsKeyId to encrypt the copy with a new KMS encryption key. If you don't specify a value for KmsKeyId, then the copy of the cluster snapshot is encrypted with the same KMS key as the source cluster snapshot.

    If you copy an encrypted cluster snapshot that is shared from another Amazon Web Services account, then you must specify a value for KmsKeyId.

    To copy an encrypted cluster snapshot to another Amazon Web Services Region, set KmsKeyId to the KMS key ID that you want to use to encrypt the copy of the cluster snapshot in the destination Region. KMS encryption keys are specific to the Amazon Web Services Region that they are created in, and you can't use encryption keys from one Amazon Web Services Region in another Amazon Web Services Region.

    If you copy an unencrypted cluster snapshot and specify a value for the KmsKeyId parameter, an error is returned.

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

    The URL that contains a Signature Version 4 signed request for theCopyDBClusterSnapshot API action in the Amazon Web Services Region that contains the source cluster snapshot to copy. You must use the PreSignedUrl parameter when copying a cluster snapshot from another Amazon Web Services Region.

    If you are using an Amazon Web Services SDK tool or the CLI, you can specify SourceRegion (or --source-region for the CLI) instead of specifying PreSignedUrl manually. Specifying SourceRegion autogenerates a pre-signed URL that is a valid request for the operation that can be executed in the source Amazon Web Services Region.

    The presigned URL must be a valid request for the CopyDBClusterSnapshot API action that can be executed in the source Amazon Web Services Region that contains the cluster snapshot to be copied. The presigned URL request must contain the following parameter values:

    • SourceRegion - The ID of the region that contains the snapshot to be copied.

    • SourceDBClusterSnapshotIdentifier - The identifier for the the encrypted cluster snapshot to be copied. This identifier must be in the Amazon Resource Name (ARN) format for the source Amazon Web Services Region. For example, if you are copying an encrypted cluster snapshot from the us-east-1 Amazon Web Services Region, then your SourceDBClusterSnapshotIdentifier looks something like the following: arn:aws:rds:us-east-1:12345678012:sample-cluster:sample-cluster-snapshot.

    • TargetDBClusterSnapshotIdentifier - The identifier for the new cluster snapshot to be created. This parameter isn't case sensitive.

  • copy_tags (Optional[BooleanOptional], default: None ) –

    Set to true to copy all tags from the source cluster snapshot to the target cluster snapshot, and otherwise false. The default is false.

  • tags (Optional[TagList], default: None ) –

    The tags to be assigned to the cluster snapshot.

Raises:

Source code in docs_src/capo_docdb/_services/async_doc_db.py
async def copy_db_cluster_snapshot(
    self,
    *,
    config_overrides: Optional[AsyncDocDBClientConfig] = None,
    source_db_cluster_snapshot_identifier: Optional[
        "capo_docdb.types.string.String"
    ] = None,
    target_db_cluster_snapshot_identifier: Optional[
        "capo_docdb.types.string.String"
    ] = None,
    kms_key_id: Optional["capo_docdb.types.string.String"] = None,
    pre_signed_url: Optional["capo_docdb.types.string.String"] = None,
    copy_tags: Optional["capo_docdb.types.boolean_optional.BooleanOptional"] = None,
    tags: Optional["capo_docdb.types.tag_list.TagList"] = None,
) -> "capo_docdb.types.copy_db_cluster_snapshot_result.CopyDBClusterSnapshotResult":
    """<p>Copies a snapshot of a cluster.</p> <p>To copy a cluster snapshot from a shared manual cluster snapshot, <code>SourceDBClusterSnapshotIdentifier</code> must be the Amazon Resource Name (ARN) of the shared cluster snapshot. You can only copy a shared DB cluster snapshot, whether encrypted or not, in the same Amazon Web Services Region.</p> <p>To cancel the copy operation after it is in progress, delete the target cluster snapshot identified by <code>TargetDBClusterSnapshotIdentifier</code> while that cluster snapshot is in the <i>copying</i> status.</p>

    Args:
        source_db_cluster_snapshot_identifier: <p>The identifier of the cluster snapshot to copy. This parameter is not case sensitive.</p> <p>Constraints:</p> <ul> <li> <p>Must specify a valid cluster snapshot in the <i>available</i> state.</p> </li> <li> <p>If the source cluster snapshot is in the same Amazon Web Services Region as the copy, specify a valid snapshot identifier.</p> </li> <li> <p>If the source cluster snapshot is in a different Amazon Web Services Region or owned by another Amazon Web Services account, specify the snapshot ARN.</p> </li> </ul> <p>Example: <code>my-cluster-snapshot1</code> </p>
        target_db_cluster_snapshot_identifier: <p>The identifier of the new cluster snapshot to create from the source cluster snapshot. This parameter is not case sensitive.</p> <p>Constraints:</p> <ul> <li> <p>Must contain from 1 to 63 letters, numbers, or hyphens. </p> </li> <li> <p>The first character must be a letter.</p> </li> <li> <p>Cannot end with a hyphen or contain two consecutive hyphens. </p> </li> </ul> <p>Example: <code>my-cluster-snapshot2</code> </p>
        kms_key_id: <p>The KMS key ID for an encrypted cluster snapshot. The KMS key ID is the Amazon Resource Name (ARN), KMS key identifier, or the KMS key alias for the KMS encryption key. </p> <p>If you copy an encrypted cluster snapshot from your Amazon Web Services account, you can specify a value for <code>KmsKeyId</code> to encrypt the copy with a new KMS encryption key. If you don't specify a value for <code>KmsKeyId</code>, then the copy of the cluster snapshot is encrypted with the same KMS key as the source cluster snapshot.</p> <p>If you copy an encrypted cluster snapshot that is shared from another Amazon Web Services account, then you must specify a value for <code>KmsKeyId</code>.</p> <p>To copy an encrypted cluster snapshot to another Amazon Web Services Region, set <code>KmsKeyId</code> to the KMS key ID that you want to use to encrypt the copy of the cluster snapshot in the destination Region. KMS encryption keys are specific to the Amazon Web Services Region that they are created in, and you can't use encryption keys from one Amazon Web Services Region in another Amazon Web Services Region.</p> <p>If you copy an unencrypted cluster snapshot and specify a value for the <code>KmsKeyId</code> parameter, an error is returned.</p>
        pre_signed_url: <p>The URL that contains a Signature Version 4 signed request for the<code>CopyDBClusterSnapshot</code> API action in the Amazon Web Services Region that contains the source cluster snapshot to copy. You must use the <code>PreSignedUrl</code> parameter when copying a cluster snapshot from another Amazon Web Services Region.</p> <p>If you are using an Amazon Web Services SDK tool or the CLI, you can specify <code>SourceRegion</code> (or <code>--source-region</code> for the CLI) instead of specifying <code>PreSignedUrl</code> manually. Specifying <code>SourceRegion</code> autogenerates a pre-signed URL that is a valid request for the operation that can be executed in the source Amazon Web Services Region.</p> <p>The presigned URL must be a valid request for the <code>CopyDBClusterSnapshot</code> API action that can be executed in the source Amazon Web Services Region that contains the cluster snapshot to be copied. The presigned URL request must contain the following parameter values:</p> <ul> <li> <p> <code>SourceRegion</code> - The ID of the region that contains the snapshot to be copied.</p> </li> <li> <p> <code>SourceDBClusterSnapshotIdentifier</code> - The identifier for the the encrypted cluster snapshot to be copied. This identifier must be in the Amazon Resource Name (ARN) format for the source Amazon Web Services Region. For example, if you are copying an encrypted cluster snapshot from the us-east-1 Amazon Web Services Region, then your <code>SourceDBClusterSnapshotIdentifier</code> looks something like the following: <code>arn:aws:rds:us-east-1:12345678012:sample-cluster:sample-cluster-snapshot</code>.</p> </li> <li> <p> <code>TargetDBClusterSnapshotIdentifier</code> - The identifier for the new cluster snapshot to be created. This parameter isn't case sensitive.</p> </li> </ul>
        copy_tags: <p>Set to <code>true</code> to copy all tags from the source cluster snapshot to the target cluster snapshot, and otherwise <code>false</code>. The default is <code>false</code>.</p>
        tags: <p>The tags to be assigned to the cluster snapshot.</p>

    Raises:
        capo_docdb.errors.db_cluster_snapshot_already_exists_fault.DBClusterSnapshotAlreadyExistsFault: <p>You already have a cluster snapshot with the given identifier.</p>
        capo_docdb.errors.db_cluster_snapshot_not_found_fault.DBClusterSnapshotNotFoundFault: <p> <code>DBClusterSnapshotIdentifier</code> doesn't refer to an existing cluster snapshot. </p>
        capo_docdb.errors.invalid_db_cluster_snapshot_state_fault.InvalidDBClusterSnapshotStateFault: <p>The provided value isn't a valid cluster snapshot state.</p>
        capo_docdb.errors.invalid_db_cluster_state_fault.InvalidDBClusterStateFault: <p>The cluster isn't in a valid state.</p>
        capo_docdb.errors.kms_key_not_accessible_fault.KMSKeyNotAccessibleFault: <p>An error occurred when accessing an KMS key.</p>
        capo_docdb.errors.snapshot_quota_exceeded_fault.SnapshotQuotaExceededFault: <p>The request would cause you to exceed the allowed number of snapshots.</p>
        capo_docdb.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_docdb.types.copy_db_cluster_snapshot_message.CopyDBClusterSnapshotMessage]",
    ) -> AsyncOperationResponse[
        "capo_docdb.types.copy_db_cluster_snapshot_result.CopyDBClusterSnapshotResult"
    ]:
        import capo_docdb._operations.amazon_rd_sv19.copy_db_cluster_snapshot

        (
            output,
            http_response,
        ) = await capo_docdb._operations.amazon_rd_sv19.copy_db_cluster_snapshot.async_copy_db_cluster_snapshot(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CopyDBClusterSnapshot")
    )
    input_: capo_docdb.types.copy_db_cluster_snapshot_message.CopyDBClusterSnapshotMessage = {}
    if source_db_cluster_snapshot_identifier is not None:
        input_["source_db_cluster_snapshot_identifier"] = (
            source_db_cluster_snapshot_identifier
        )
    if target_db_cluster_snapshot_identifier is not None:
        input_["target_db_cluster_snapshot_identifier"] = (
            target_db_cluster_snapshot_identifier
        )
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id
    if pre_signed_url is not None:
        input_["pre_signed_url"] = pre_signed_url
    if copy_tags is not None:
        input_["copy_tags"] = copy_tags
    if tags is not None:
        input_["tags"] = tags

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