Skip to content

modify_snapshot_attribute async

modify_snapshot_attribute(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    attribute: Optional[SnapshotAttributeName] = None,
    create_volume_permission: Optional[CreateVolumePermissionModifications] = None,
    group_names: Optional[GroupNameStringList] = None,
    operation_type: Optional[OperationType] = None,
    snapshot_id: Optional[SnapshotId] = None,
    user_ids: Optional[UserIdStringList] = None,
    dry_run: Optional[Boolean] = None,
) -> None

Adds or removes permission settings for the specified snapshot. You may add or remove specified Amazon Web Services account IDs from a snapshot's list of create volume permissions, but you cannot do both in a single operation. If you need to both add and remove account IDs for a snapshot, you must use multiple operations. You can make up to 500 modifications to a snapshot in a single operation.

Encrypted snapshots and snapshots with Amazon Web Services Marketplace product codes cannot be made public. Snapshots encrypted with your default KMS key cannot be shared with other accounts.

For more information about modifying snapshot permissions, see Share a snapshot in the Amazon EBS User Guide.

Parameters:

  • attribute (Optional[SnapshotAttributeName], default: None ) –

    The snapshot attribute to modify. Only volume creation permissions can be modified.

  • create_volume_permission (Optional[CreateVolumePermissionModifications], default: None ) –

    A JSON representation of the snapshot attribute modification.

  • group_names (Optional[GroupNameStringList], default: None ) –

    The group to modify for the snapshot.

  • operation_type (Optional[OperationType], default: None ) –

    The type of operation to perform to the attribute.

  • snapshot_id (Optional[SnapshotId], default: None ) –

    The ID of the snapshot.

  • user_ids (Optional[UserIdStringList], default: None ) –

    The account ID to modify for the snapshot.

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

Raises:

Examples:

To make a snapshot public This example makes the snapshot snap-1234567890abcdef0 public.

>>> await client.modify_snapshot_attribute(snapshot_id='snap-1234567890abcdef0', attribute='createVolumePermission', operation_type='add', group_names=['all'])
To modify a snapshot attribute
This example modifies snapshot ``snap-1234567890abcdef0`` to remove the create volume permission for a user with the account ID ``123456789012``. If the command succeeds, no output is returned.
>>> await client.modify_snapshot_attribute(snapshot_id='snap-1234567890abcdef0', attribute='createVolumePermission', operation_type='remove', user_ids=['123456789012'])
Source code in docs_src/capo_ec2/_services/async_ec2.py
async def modify_snapshot_attribute(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    attribute: Optional[
        "capo_ec2.types.snapshot_attribute_name.SnapshotAttributeName"
    ] = None,
    create_volume_permission: Optional[
        "capo_ec2.types.create_volume_permission_modifications.CreateVolumePermissionModifications"
    ] = None,
    group_names: Optional[
        "capo_ec2.types.group_name_string_list.GroupNameStringList"
    ] = None,
    operation_type: Optional["capo_ec2.types.operation_type.OperationType"] = None,
    snapshot_id: Optional["capo_ec2.types.snapshot_id.SnapshotId"] = None,
    user_ids: Optional[
        "capo_ec2.types.user_id_string_list.UserIdStringList"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> None:
    """<p>Adds or removes permission settings for the specified snapshot. You may add or remove specified Amazon Web Services account IDs from a snapshot's list of create volume permissions, but you cannot do both in a single operation. If you need to both add and remove account IDs for a snapshot, you must use multiple operations. You can make up to 500 modifications to a snapshot in a single operation.</p> <p>Encrypted snapshots and snapshots with Amazon Web Services Marketplace product codes cannot be made public. Snapshots encrypted with your default KMS key cannot be shared with other accounts.</p> <p>For more information about modifying snapshot permissions, see <a href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-modifying-snapshot-permissions.html">Share a snapshot</a> in the <i>Amazon EBS User Guide</i>.</p>

    Args:
        attribute: <p>The snapshot attribute to modify. Only volume creation permissions can be modified.</p>
        create_volume_permission: <p>A JSON representation of the snapshot attribute modification.</p>
        group_names: <p>The group to modify for the snapshot.</p>
        operation_type: <p>The type of operation to perform to the attribute.</p>
        snapshot_id: <p>The ID of the snapshot.</p>
        user_ids: <p>The account ID to modify for the snapshot.</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>

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

    Examples:
        To make a snapshot public
        This example makes the snapshot ``snap-1234567890abcdef0`` public.

        >>> await client.modify_snapshot_attribute(snapshot_id='snap-1234567890abcdef0', attribute='createVolumePermission', operation_type='add', group_names=['all'])
        To modify a snapshot attribute
        This example modifies snapshot ``snap-1234567890abcdef0`` to remove the create volume permission for a user with the account ID ``123456789012``. If the command succeeds, no output is returned.

        >>> await client.modify_snapshot_attribute(snapshot_id='snap-1234567890abcdef0', attribute='createVolumePermission', operation_type='remove', user_ids=['123456789012'])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.modify_snapshot_attribute_request.ModifySnapshotAttributeRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_ec2._operations.amazon_ec2.modify_snapshot_attribute

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifySnapshotAttribute")
    )
    input_: capo_ec2.types.modify_snapshot_attribute_request.ModifySnapshotAttributeRequest = {}
    if attribute is not None:
        input_["attribute"] = attribute
    if create_volume_permission is not None:
        input_["create_volume_permission"] = create_volume_permission
    if group_names is not None:
        input_["group_names"] = group_names
    if operation_type is not None:
        input_["operation_type"] = operation_type
    if snapshot_id is not None:
        input_["snapshot_id"] = snapshot_id
    if user_ids is not None:
        input_["user_ids"] = user_ids
    if dry_run is not None:
        input_["dry_run"] = dry_run

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