Skip to content

create_snapshot async

create_snapshot(
    volume_arn: VolumeARN,
    snapshot_description: SnapshotDescription,
    *,
    config_overrides: Optional[AsyncStorageGatewayClientConfig] = None,
    tags: Optional[Tags] = None,
) -> CreateSnapshotOutput

Initiates a snapshot of a volume.

Storage Gateway provides the ability to back up point-in-time snapshots of your data to Amazon Simple Storage (Amazon S3) for durable off-site recovery, and also import the data to an Amazon Elastic Block Store (EBS) volume in Amazon Elastic Compute Cloud (EC2). You can take snapshots of your gateway volume on a scheduled or ad hoc basis. This API enables you to take an ad hoc snapshot. For more information, see Editing a snapshot schedule.

In the CreateSnapshot request, you identify the volume by providing its Amazon Resource Name (ARN). You must also provide description for the snapshot. When Storage Gateway takes the snapshot of specified volume, the snapshot and description appears in the Storage Gateway console. In response, Storage Gateway returns you a snapshot ID. You can use this snapshot ID to check the snapshot progress or later use it when you want to create a volume from a snapshot. This operation is only supported in stored and cached volume gateway type.

To list or delete a snapshot, you must use the Amazon EC2 API. For more information, see DescribeSnapshots or DeleteSnapshot in the Amazon Elastic Compute Cloud API Reference.

Volume and snapshot IDs are changing to a longer length ID format. For more information, see the important note on the Welcome page.

Parameters:

  • volume_arn (VolumeARN) –

    The Amazon Resource Name (ARN) of the volume. Use the ListVolumes operation to return a list of gateway volumes.

  • snapshot_description (SnapshotDescription) –

    Textual description of the snapshot that appears in the Amazon EC2 console, Elastic Block Store snapshots panel in the Description field, and in the Storage Gateway snapshot Details pane, Description field.

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

    A list of up to 50 tags that can be assigned to a snapshot. Each tag is a key-value pair.

    Valid characters for key and value are letters, spaces, and numbers representable in UTF-8 format, and the following special characters: + - = . _ : / @. The maximum length of a tag's key is 128 characters, and the maximum length for a tag's value is 256.

Raises:

  • InternalServerError –

    An internal server error has occurred during the request. For more information, see the error and message fields.

  • InvalidGatewayRequestException –

    An exception occurred because an invalid gateway request was issued to the service. For more information, see the error and message fields.

  • ServiceUnavailableError –

    An internal server error has occurred because the service is unavailable. For more information, see the error and message fields.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To create a snapshot of a gateway volume Initiates an ad-hoc snapshot of a gateway volume.

>>> await client.create_snapshot(volume_arn='arn:aws:storagegateway:us-east-1:111122223333:gateway/sgw-12A3456B/volume/vol-1122AABB', snapshot_description='My root volume snapshot as of 10/03/2017')
Source code in docs_src/capo_storage_gateway/_services/async_storage_gateway.py
async def create_snapshot(
    self,
    volume_arn: "capo_storage_gateway.types.volume_arn.VolumeARN",
    snapshot_description: "capo_storage_gateway.types.snapshot_description.SnapshotDescription",
    *,
    config_overrides: Optional[AsyncStorageGatewayClientConfig] = None,
    tags: Optional["capo_storage_gateway.types.tags.Tags"] = None,
) -> "capo_storage_gateway.types.create_snapshot_output.CreateSnapshotOutput":
    """<p>Initiates a snapshot of a volume.</p> <p>Storage Gateway provides the ability to back up point-in-time snapshots of your data to Amazon Simple Storage (Amazon S3) for durable off-site recovery, and also import the data to an Amazon Elastic Block Store (EBS) volume in Amazon Elastic Compute Cloud (EC2). You can take snapshots of your gateway volume on a scheduled or ad hoc basis. This API enables you to take an ad hoc snapshot. For more information, see <a href="https://docs.aws.amazon.com/storagegateway/latest/userguide/managing-volumes.html#SchedulingSnapshot">Editing a snapshot schedule</a>.</p> <p>In the <code>CreateSnapshot</code> request, you identify the volume by providing its Amazon Resource Name (ARN). You must also provide description for the snapshot. When Storage Gateway takes the snapshot of specified volume, the snapshot and description appears in the Storage Gateway console. In response, Storage Gateway returns you a snapshot ID. You can use this snapshot ID to check the snapshot progress or later use it when you want to create a volume from a snapshot. This operation is only supported in stored and cached volume gateway type.</p> <note> <p>To list or delete a snapshot, you must use the Amazon EC2 API. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeSnapshots.html">DescribeSnapshots</a> or <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DeleteSnapshot.html">DeleteSnapshot</a> in the <i>Amazon Elastic Compute Cloud API Reference</i>.</p> </note> <important> <p>Volume and snapshot IDs are changing to a longer length ID format. For more information, see the important note on the <a href="https://docs.aws.amazon.com/storagegateway/latest/APIReference/Welcome.html">Welcome</a> page.</p> </important>

    Args:
        volume_arn: <p>The Amazon Resource Name (ARN) of the volume. Use the <a>ListVolumes</a> operation to return a list of gateway volumes.</p>
        snapshot_description: <p>Textual description of the snapshot that appears in the Amazon EC2 console, Elastic Block Store snapshots panel in the <b>Description</b> field, and in the Storage Gateway snapshot <b>Details</b> pane, <b>Description</b> field.</p>
        tags: <p>A list of up to 50 tags that can be assigned to a snapshot. Each tag is a key-value pair.</p> <note> <p>Valid characters for key and value are letters, spaces, and numbers representable in UTF-8 format, and the following special characters: + - = . _ : / @. The maximum length of a tag's key is 128 characters, and the maximum length for a tag's value is 256.</p> </note>

    Raises:
        capo_storage_gateway.errors.internal_server_error.InternalServerError: <p>An internal server error has occurred during the request. For more information, see the error and message fields.</p>
        capo_storage_gateway.errors.invalid_gateway_request_exception.InvalidGatewayRequestException: <p>An exception occurred because an invalid gateway request was issued to the service. For more information, see the error and message fields.</p>
        capo_storage_gateway.errors.service_unavailable_error.ServiceUnavailableError: <p>An internal server error has occurred because the service is unavailable. For more information, see the error and message fields.</p>
        capo_storage_gateway.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a snapshot of a gateway volume
        Initiates an ad-hoc snapshot of a gateway volume.

        >>> await client.create_snapshot(volume_arn='arn:aws:storagegateway:us-east-1:111122223333:gateway/sgw-12A3456B/volume/vol-1122AABB', snapshot_description='My root volume snapshot as of 10/03/2017')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_storage_gateway.types.create_snapshot_input.CreateSnapshotInput]",
    ) -> AsyncOperationResponse[
        "capo_storage_gateway.types.create_snapshot_output.CreateSnapshotOutput"
    ]:
        import capo_storage_gateway._operations.storage_gateway_20130630.create_snapshot

        (
            output,
            http_response,
        ) = await capo_storage_gateway._operations.storage_gateway_20130630.create_snapshot.async_create_snapshot(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSnapshot")
    )
    input_: capo_storage_gateway.types.create_snapshot_input.CreateSnapshotInput = {
        "volume_arn": volume_arn,
        "snapshot_description": snapshot_description,
    }
    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