Skip to content

modify_db_snapshot_attribute async

modify_db_snapshot_attribute(
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_snapshot_identifier: Optional[String] = None,
    attribute_name: Optional[String] = None,
    values_to_add: Optional[AttributeValueList] = None,
    values_to_remove: Optional[AttributeValueList] = None,
) -> ModifyDBSnapshotAttributeResult

Adds an attribute and values to, or removes an attribute and values from, a manual DB snapshot.

To share a manual DB snapshot with other Amazon Web Services accounts, specify restore as the AttributeName and use the ValuesToAdd parameter to add a list of IDs of the Amazon Web Services accounts that are authorized to restore the manual DB snapshot. Uses the value all to make the manual DB snapshot public, which means it can be copied or restored by all Amazon Web Services accounts.

Don't add the all value for any manual DB snapshots that contain private information that you don't want available to all Amazon Web Services accounts.

If the manual DB snapshot is encrypted, it can be shared, but only by specifying a list of authorized Amazon Web Services account IDs for the ValuesToAdd parameter. You can't use all as a value for that parameter in this case.

To view which Amazon Web Services accounts have access to copy or restore a manual DB snapshot, or whether a manual DB snapshot public or private, use the DescribeDBSnapshotAttributes API operation. The accounts are returned as values for the restore attribute.

Parameters:

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

    The identifier for the DB snapshot to modify the attributes for.

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

    The name of the DB snapshot attribute to modify.

    To manage authorization for other Amazon Web Services accounts to copy or restore a manual DB snapshot, set this value to restore.

    To view the list of attributes available to modify, use the DescribeDBSnapshotAttributes API operation.

  • values_to_add (Optional[AttributeValueList], default: None ) –

    A list of DB snapshot attributes to add to the attribute specified by AttributeName.

    To authorize other Amazon Web Services accounts to copy or restore a manual snapshot, set this list to include one or more Amazon Web Services account IDs, or all to make the manual DB snapshot restorable by any Amazon Web Services account. Do not add the all value for any manual DB snapshots that contain private information that you don't want available to all Amazon Web Services accounts.

  • values_to_remove (Optional[AttributeValueList], default: None ) –

    A list of DB snapshot attributes to remove from the attribute specified by AttributeName.

    To remove authorization for other Amazon Web Services accounts to copy or restore a manual snapshot, set this list to include one or more Amazon Web Services account identifiers, or all to remove authorization for any Amazon Web Services account to copy or restore the DB snapshot. If you specify all, an Amazon Web Services account whose account ID is explicitly added to the restore attribute can still copy or restore the manual DB snapshot.

Raises:

Examples:

To allow two AWS accounts to restore a DB snapshot The following example grants permission to two AWS accounts, with the identifiers 111122223333 and 444455556666, to restore the DB snapshot named mydbsnapshot.

>>> await client.modify_db_snapshot_attribute(db_snapshot_identifier='mydbsnapshot', attribute_name='restore', values_to_add=['111122223333', '444455556666'])
To prevent an AWS account from restoring a DB snapshot
The following example removes permission from the AWS account with the identifier 444455556666 to restore the DB snapshot named mydbsnapshot.
>>> await client.modify_db_snapshot_attribute(db_snapshot_identifier='mydbsnapshot', attribute_name='restore', values_to_remove=['444455556666'])
Source code in docs_src/capo_rds/_services/async_rds.py
async def modify_db_snapshot_attribute(
    self,
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_snapshot_identifier: Optional["capo_rds.types.string.String"] = None,
    attribute_name: Optional["capo_rds.types.string.String"] = None,
    values_to_add: Optional[
        "capo_rds.types.attribute_value_list.AttributeValueList"
    ] = None,
    values_to_remove: Optional[
        "capo_rds.types.attribute_value_list.AttributeValueList"
    ] = None,
) -> "capo_rds.types.modify_db_snapshot_attribute_result.ModifyDBSnapshotAttributeResult":
    """<p>Adds an attribute and values to, or removes an attribute and values from, a manual DB snapshot.</p> <p>To share a manual DB snapshot with other Amazon Web Services accounts, specify <code>restore</code> as the <code>AttributeName</code> and use the <code>ValuesToAdd</code> parameter to add a list of IDs of the Amazon Web Services accounts that are authorized to restore the manual DB snapshot. Uses the value <code>all</code> to make the manual DB snapshot public, which means it can be copied or restored by all Amazon Web Services accounts.</p> <note> <p>Don't add the <code>all</code> value for any manual DB snapshots that contain private information that you don't want available to all Amazon Web Services accounts.</p> </note> <p>If the manual DB snapshot is encrypted, it can be shared, but only by specifying a list of authorized Amazon Web Services account IDs for the <code>ValuesToAdd</code> parameter. You can't use <code>all</code> as a value for that parameter in this case.</p> <p>To view which Amazon Web Services accounts have access to copy or restore a manual DB snapshot, or whether a manual DB snapshot public or private, use the <a>DescribeDBSnapshotAttributes</a> API operation. The accounts are returned as values for the <code>restore</code> attribute.</p>

    Args:
        db_snapshot_identifier: <p>The identifier for the DB snapshot to modify the attributes for.</p>
        attribute_name: <p>The name of the DB snapshot attribute to modify.</p> <p>To manage authorization for other Amazon Web Services accounts to copy or restore a manual DB snapshot, set this value to <code>restore</code>.</p> <note> <p>To view the list of attributes available to modify, use the <a>DescribeDBSnapshotAttributes</a> API operation.</p> </note>
        values_to_add: <p>A list of DB snapshot attributes to add to the attribute specified by <code>AttributeName</code>.</p> <p>To authorize other Amazon Web Services accounts to copy or restore a manual snapshot, set this list to include one or more Amazon Web Services account IDs, or <code>all</code> to make the manual DB snapshot restorable by any Amazon Web Services account. Do not add the <code>all</code> value for any manual DB snapshots that contain private information that you don't want available to all Amazon Web Services accounts.</p>
        values_to_remove: <p>A list of DB snapshot attributes to remove from the attribute specified by <code>AttributeName</code>.</p> <p>To remove authorization for other Amazon Web Services accounts to copy or restore a manual snapshot, set this list to include one or more Amazon Web Services account identifiers, or <code>all</code> to remove authorization for any Amazon Web Services account to copy or restore the DB snapshot. If you specify <code>all</code>, an Amazon Web Services account whose account ID is explicitly added to the <code>restore</code> attribute can still copy or restore the manual DB snapshot.</p>

    Raises:
        capo_rds.errors.db_snapshot_not_found_fault.DBSnapshotNotFoundFault: <p> <code>DBSnapshotIdentifier</code> doesn't refer to an existing DB snapshot.</p>
        capo_rds.errors.invalid_db_snapshot_state_fault.InvalidDBSnapshotStateFault: <p>The state of the DB snapshot doesn't allow deletion.</p>
        capo_rds.errors.shared_snapshot_quota_exceeded_fault.SharedSnapshotQuotaExceededFault: <p>You have exceeded the maximum number of accounts that you can share a manual DB snapshot with.</p>
        capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To allow two AWS accounts to restore a DB snapshot
        The following example grants permission to two AWS accounts, with the identifiers 111122223333 and 444455556666, to restore the DB snapshot named mydbsnapshot.

        >>> await client.modify_db_snapshot_attribute(db_snapshot_identifier='mydbsnapshot', attribute_name='restore', values_to_add=['111122223333', '444455556666'])
        To prevent an AWS account from restoring a DB snapshot
        The following example removes permission from the AWS account with the identifier 444455556666 to restore the DB snapshot named mydbsnapshot.

        >>> await client.modify_db_snapshot_attribute(db_snapshot_identifier='mydbsnapshot', attribute_name='restore', values_to_remove=['444455556666'])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_rds.types.modify_db_snapshot_attribute_message.ModifyDBSnapshotAttributeMessage]",
    ) -> AsyncOperationResponse[
        "capo_rds.types.modify_db_snapshot_attribute_result.ModifyDBSnapshotAttributeResult"
    ]:
        import capo_rds._operations.amazon_rd_sv19.modify_db_snapshot_attribute

        (
            output,
            http_response,
        ) = await capo_rds._operations.amazon_rd_sv19.modify_db_snapshot_attribute.async_modify_db_snapshot_attribute(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyDBSnapshotAttribute")
    )
    input_: capo_rds.types.modify_db_snapshot_attribute_message.ModifyDBSnapshotAttributeMessage = {}
    if db_snapshot_identifier is not None:
        input_["db_snapshot_identifier"] = db_snapshot_identifier
    if attribute_name is not None:
        input_["attribute_name"] = attribute_name
    if values_to_add is not None:
        input_["values_to_add"] = values_to_add
    if values_to_remove is not None:
        input_["values_to_remove"] = values_to_remove

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