Amazon Elastic Block Store

2020/07/09 - Amazon Elastic Block Store - 3 new api methods

Changes  This release introduces the following set of actions for the EBS direct APIs: 1. StartSnapshot, which creates a new Amazon EBS snapshot. 2. PutSnapshotBlock, which writes a block of data to a snapshot. 3. CompleteSnapshot, which seals and completes a snapshot after blocks of data have been written to it.

PutSnapshotBlock (new) Link ¶

Writes a block of data to a block in the snapshot. If the specified block contains data, the existing data is overwritten. The target snapshot must be in the pending state.

Data written to a snapshot must be aligned with 512-byte sectors.

See also: AWS API Documentation

Request Syntax

client.put_snapshot_block(
    SnapshotId='string',
    BlockIndex=123,
    BlockData=b'bytes'|file,
    DataLength=123,
    Progress=123,
    Checksum='string',
    ChecksumAlgorithm='SHA256'
)
type SnapshotId

string

param SnapshotId

[REQUIRED]

The ID of the snapshot.

type BlockIndex

integer

param BlockIndex

[REQUIRED]

The block index of the block in which to write the data. A block index is the offset position of a block within a snapshot, and it is used to identify the block. To identify the logical offset of the data in the logical volume, multiply the block index with the block size (Block index * 512 bytes).

type BlockData

bytes or seekable file-like object

param BlockData

[REQUIRED]

The data to write to the block.

The block data is not signed as part of the Signature Version 4 signing process. As a result, you must generate and provide a Base64-encoded SHA256 checksum for the block data using the x-amz-Checksum header. Also, you must specify the checksum algorithm using the x-amz-Checksum-Algorithm header. The checksum that you provide is part of the Signature Version 4 signing process. It is validated against a checksum generated by Amazon EBS to ensure the validity and authenticity of the data. If the checksums do not correspond, the request fails. For more information, see Using checksums with the EBS direct APIs in the Amazon Elastic Compute Cloud User Guide .

type DataLength

integer

param DataLength

[REQUIRED]

The size of the data to write to the block, in bytes. Currently, the only supported size is 524288 .

Valid values: 524288

type Progress

integer

param Progress

The progress of the write process, as a percentage.

type Checksum

string

param Checksum

[REQUIRED]

A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are supported.

type ChecksumAlgorithm

string

param ChecksumAlgorithm

[REQUIRED]

The algorithm used to generate the checksum. Currently, the only supported algorithm is SHA256 .

rtype

dict

returns

Response Syntax

{
    'Checksum': 'string',
    'ChecksumAlgorithm': 'SHA256'
}

Response Structure

  • (dict) --

    • Checksum (string) --

      The SHA256 checksum generated for the block data by Amazon EBS.

    • ChecksumAlgorithm (string) --

      The algorithm used by Amazon EBS to generate the checksum.

StartSnapshot (new) Link ¶

Creates a new Amazon EBS snapshot. The new snapshot enters the pending state after the request completes.

After creating the snapshot, use PutSnapshotBlock to write blocks of data to the snapshot.

See also: AWS API Documentation

Request Syntax

client.start_snapshot(
    VolumeSize=123,
    ParentSnapshotId='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    Description='string',
    ClientToken='string',
    Encrypted=True|False,
    KmsKeyArn='string',
    Timeout=123
)
type VolumeSize

integer

param VolumeSize

[REQUIRED]

The size of the volume, in GiB. The maximum size is 16384 GiB (16 TiB).

type ParentSnapshotId

string

param ParentSnapshotId

The ID of the parent snapshot. If there is no parent snapshot, or if you are creating the first snapshot for an on-premises volume, omit this parameter.

If your account is enabled for encryption by default, you cannot use an unencrypted snapshot as a parent snapshot. You must first create an encrypted copy of the parent snapshot using CopySnapshot.

type Tags

list

param Tags

The tags to apply to the snapshot.

  • (dict) --

    Describes a tag.

    • Key (string) --

      The key of the tag.

    • Value (string) --

      The value of the tag.

type Description

string

param Description

A description for the snapshot.

type ClientToken

string

param ClientToken

A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Idempotency ensures that an API request completes only once. With an idempotent request, if the original request completes successfully. The subsequent retries with the same client token return the result from the original successful request and they have no additional effect.

If you do not specify a client token, one is automatically generated by the AWS SDK.

For more information, see Idempotency for StartSnapshot API in the Amazon Elastic Compute Cloud User Guide .

This field is autopopulated if not provided.

type Encrypted

boolean

param Encrypted

Indicates whether to encrypt the snapshot. To create an encrypted snapshot, specify true . To create an unencrypted snapshot, omit this parameter.

If you specify a value for ParentSnapshotId , omit this parameter.

If you specify true , the snapshot is encrypted using the CMK specified using the KmsKeyArn parameter. If no value is specified for KmsKeyArn , the default CMK for your account is used. If no default CMK has been specified for your account, the AWS managed CMK is used. To set a default CMK for your account, use ModifyEbsDefaultKmsKeyId.

If your account is enabled for encryption by default, you cannot set this parameter to false . In this case, you can omit this parameter.

For more information, see Using encryption in the Amazon Elastic Compute Cloud User Guide .

type KmsKeyArn

string

param KmsKeyArn

The Amazon Resource Name (ARN) of the AWS Key Management Service (AWS KMS) customer master key (CMK) to be used to encrypt the snapshot. If you do not specify a CMK, the default AWS managed CMK is used.

If you specify a ParentSnapshotId , omit this parameter; the snapshot will be encrypted using the same CMK that was used to encrypt the parent snapshot.

If Encrypted is set to true , you must specify a CMK ARN.

type Timeout

integer

param Timeout

The amount of time (in minutes) after which the snapshot is automatically cancelled if:

  • No blocks are written to the snapshot.

  • The snapshot is not completed after writing the last block of data.

If no value is specified, the timeout defaults to 60 minutes.

rtype

dict

returns

Response Syntax

{
    'Description': 'string',
    'SnapshotId': 'string',
    'OwnerId': 'string',
    'Status': 'completed'|'pending'|'error',
    'StartTime': datetime(2015, 1, 1),
    'VolumeSize': 123,
    'BlockSize': 123,
    'Tags': [
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    'ParentSnapshotId': 'string',
    'KmsKeyArn': 'string'
}

Response Structure

  • (dict) --

    • Description (string) --

      The description of the snapshot.

    • SnapshotId (string) --

      The ID of the snapshot.

    • OwnerId (string) --

      The AWS account ID of the snapshot owner.

    • Status (string) --

      The status of the snapshot.

    • StartTime (datetime) --

      The timestamp when the snapshot was created.

    • VolumeSize (integer) --

      The size of the volume, in GiB.

    • BlockSize (integer) --

      The size of the blocks in the snapshot, in bytes.

    • Tags (list) --

      The tags applied to the snapshot. You can specify up to 50 tags per snapshot. For more information, see Tagging your Amazon EC2 resources in the Amazon Elastic Compute Cloud User Guide .

      • (dict) --

        Describes a tag.

        • Key (string) --

          The key of the tag.

        • Value (string) --

          The value of the tag.

    • ParentSnapshotId (string) --

      The ID of the parent snapshot.

    • KmsKeyArn (string) --

      The Amazon Resource Name (ARN) of the AWS Key Management Service (AWS KMS) customer master key (CMK) used to encrypt the snapshot.

CompleteSnapshot (new) Link ¶

Seals and completes the snapshot after all of the required blocks of data have been written to it. Completing the snapshot changes the status to completed . You cannot write new blocks to a snapshot after it has been completed.

See also: AWS API Documentation

Request Syntax

client.complete_snapshot(
    SnapshotId='string',
    ChangedBlocksCount=123,
    Checksum='string',
    ChecksumAlgorithm='SHA256',
    ChecksumAggregationMethod='LINEAR'
)
type SnapshotId

string

param SnapshotId

[REQUIRED]

The ID of the snapshot.

type ChangedBlocksCount

integer

param ChangedBlocksCount

[REQUIRED]

The number of blocks that were written to the snapshot.

type Checksum

string

param Checksum

An aggregated Base-64 SHA256 checksum based on the checksums of each written block.

To generate the aggregated checksum using the linear aggregation method, arrange the checksums for each written block in ascending order of their block index, concatenate them to form a single string, and then generate the checksum on the entire string using the SHA256 algorithm.

type ChecksumAlgorithm

string

param ChecksumAlgorithm

The algorithm used to generate the checksum. Currently, the only supported algorithm is SHA256 .

type ChecksumAggregationMethod

string

param ChecksumAggregationMethod

The aggregation method used to generate the checksum. Currently, the only supported aggregation method is LINEAR .

rtype

dict

returns

Response Syntax

{
    'Status': 'completed'|'pending'|'error'
}

Response Structure

  • (dict) --

    • Status (string) --

      The status of the snapshot.