Skip to content

Instantly share code, notes, and snippets.

@RajputVaibhav
Last active May 15, 2020 10:48
Show Gist options
  • Save RajputVaibhav/346251592922fefd5a855aebef6c7342 to your computer and use it in GitHub Desktop.
Save RajputVaibhav/346251592922fefd5a855aebef6c7342 to your computer and use it in GitHub Desktop.
Python program syntax for using EBS APIs
import boto3
import json
client = boto3.client("ebs")
def get_snapshot_block():
response = client.get_snapshot_block(
SnapshotId='',
BlockIndex=0,
BlockToken=''
)
print(response['BlockData'].read())
#------------------------------------------------
def list_snapshot_blocks():
response = client.list_snapshot_blocks(
SnapshotId=''
)
for item in response['Blocks']:
for key,value in item.items():
print('{} : {}'.format(key,value))
print('\n')
#------------------------------------------------
def list_changed_blocks():
response = client.list_changed_blocks(
FirstSnapshotId='',
SecondSnapshotId=''
)
for item in response['ChangedBlocks']:
if('FirstBlockToken' in item.keys()):
for key,value in item.items():
print('{} : {}'.format(key,value))
print('\n')
# get_snapshot_block()
# list_snapshot_blocks()
# list_changed_blocks()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment