Read Amazon EBS snapshots with EBS direct APIs
The following steps describe how to use the EBS direct APIs to read snapshots:
-
Use the ListSnapshotBlocks action to view all block indexes and block tokens of blocks in a snapshot. Or use the ListChangedBlocks action to view only the block indexes and block tokens of blocks that are different between two snapshots of the same volume and snapshot lineage. These actions help you identify the block tokens and block indexes of blocks for which you might want to get data.
-
Use the GetSnapshotBlock action, and specify the block index and block token of the block for which you want to get data.
Note
You can't use EBS direct APIs with archived snapshots.
The following examples show how to read snapshots using the EBS direct APIs.
Topics
List blocks in a snapshot
List blocks that are different between two snapshots
Keep the following in mind when making paginated requests to list the changed blocks between two snapshots:
-
The response can include one or more empty
ChangedBlocks
arrays. For example:-
Snapshot 1 — full snapshot with 1000 blocks with block indexes
0
-999
. -
Snapshot 2 — incremental snapshot with only one changed block with block index
999
.
Listing the changed blocks for these snapshots with
StartingBlockIndex = 0
andMaxResults = 100
returns an empty array ofChangedBlocks
. You must request the remaining results usingnextToken
until the changed block is returned in the tenth result set, which includes blocks with block indexes900
-999
. -
-
The response can skip unwritten blocks in the snapshots. For example:
-
Snapshot 1 — full snapshot with 1000 blocks with block indexes
2000
-2999
. -
Snapshot 2 — incremental snapshot with only one changed block with block index
2000
.
Listing the changed blocks for these snapshots with
StartingBlockIndex = 0
andMaxResults = 100
, the response skips block indexes0
-1999
and includes block index2000
. The response will not include emptyChangedBlocks
arrays. -