EBS

Client

class EBS.Client

A low-level client representing Amazon Elastic Block Store (EBS):

client = session.create_client('ebs')

These are the available methods:

can_paginate(operation_name)

Check if an operation can be paginated.

Parameters
operation_name (string) -- The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you'd normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator("create_foo").
Returns
True if the operation can be paginated, False otherwise.
complete_snapshot(**kwargs)

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

response = client.complete_snapshot(
    SnapshotId='string',
    ChangedBlocksCount=123,
    Checksum='string',
    ChecksumAlgorithm='SHA256',
    ChecksumAggregationMethod='LINEAR'
)
Parameters
  • SnapshotId (string) --

    [REQUIRED]

    The ID of the snapshot.

  • ChangedBlocksCount (integer) --

    [REQUIRED]

    The number of blocks that were written to the snapshot.

  • Checksum (string) --

    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.

  • ChecksumAlgorithm (string) -- The algorithm used to generate the checksum. Currently, the only supported algorithm is SHA256 .
  • ChecksumAggregationMethod (string) -- The aggregation method used to generate the checksum. Currently, the only supported aggregation method is LINEAR .
Return type

dict

Returns

Response Syntax

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

Response Structure

  • (dict) --

    • Status (string) --

      The status of the snapshot.

Exceptions

generate_presigned_url(ClientMethod, Params=None, ExpiresIn=3600, HttpMethod=None)

Generate a presigned url given a client, its method, and arguments

Parameters
  • ClientMethod (string) -- The client method to presign for
  • Params (dict) -- The parameters normally passed to ClientMethod.
  • ExpiresIn (int) -- The number of seconds the presigned url is valid for. By default it expires in an hour (3600 seconds)
  • HttpMethod (string) -- The http method to use on the generated url. By default, the http method is whatever is used in the method's model.
Returns

The presigned url

get_paginator(operation_name)

Create a paginator for an operation.

Parameters
operation_name (string) -- The operation name. This is the same name as the method name on the client. For example, if the method name is create_foo, and you'd normally invoke the operation as client.create_foo(**kwargs), if the create_foo operation can be paginated, you can use the call client.get_paginator("create_foo").
Raises OperationNotPageableError
Raised if the operation is not pageable. You can use the client.can_paginate method to check if an operation is pageable.
Return type
L{botocore.paginate.Paginator}
Returns
A paginator object.
get_snapshot_block(**kwargs)

Returns the data in a block in an Amazon Elastic Block Store snapshot.

See also: AWS API Documentation

Request Syntax

response = client.get_snapshot_block(
    SnapshotId='string',
    BlockIndex=123,
    BlockToken='string'
)
Parameters
  • SnapshotId (string) --

    [REQUIRED]

    The ID of the snapshot containing the block from which to get data.

  • BlockIndex (integer) --

    [REQUIRED]

    The block index of the block from which to get data.

    Obtain the BlockIndex by running the ListChangedBlocks or ListSnapshotBlocks operations.

  • BlockToken (string) --

    [REQUIRED]

    The block token of the block from which to get data.

    Obtain the BlockToken by running the ListChangedBlocks or ListSnapshotBlocks operations.

Return type

dict

Returns

Response Syntax

{
    'DataLength': 123,
    'BlockData': StreamingBody(),
    'Checksum': 'string',
    'ChecksumAlgorithm': 'SHA256'
}

Response Structure

  • (dict) --

    • DataLength (integer) --

      The size of the data in the block.

    • BlockData (StreamingBody) --

      The data content of the block.

    • Checksum (string) --

      The checksum generated for the block, which is Base64 encoded.

    • ChecksumAlgorithm (string) --

      The algorithm used to generate the checksum for the block, such as SHA256.

Exceptions

get_waiter(waiter_name)

Returns an object that can wait for some condition.

Parameters
waiter_name (str) -- The name of the waiter to get. See the waiters section of the service docs for a list of available waiters.
Returns
The specified waiter object.
Return type
botocore.waiter.Waiter
list_changed_blocks(**kwargs)

Returns information about the blocks that are different between two Amazon Elastic Block Store snapshots of the same volume/snapshot lineage.

See also: AWS API Documentation

Request Syntax

response = client.list_changed_blocks(
    FirstSnapshotId='string',
    SecondSnapshotId='string',
    NextToken='string',
    MaxResults=123,
    StartingBlockIndex=123
)
Parameters
  • FirstSnapshotId (string) --

    The ID of the first snapshot to use for the comparison.

    Warning

    The FirstSnapshotID parameter must be specified with a SecondSnapshotId parameter; otherwise, an error occurs.

  • SecondSnapshotId (string) --

    [REQUIRED]

    The ID of the second snapshot to use for the comparison.

    Warning

    The SecondSnapshotId parameter must be specified with a FirstSnapshotID parameter; otherwise, an error occurs.

  • NextToken (string) -- The token to request the next page of results.
  • MaxResults (integer) -- The number of results to return.
  • StartingBlockIndex (integer) --

    The block index from which the comparison should start.

    The list in the response will start from this block index or the next valid block index in the snapshots.

Return type

dict

Returns

Response Syntax

{
    'ChangedBlocks': [
        {
            'BlockIndex': 123,
            'FirstBlockToken': 'string',
            'SecondBlockToken': 'string'
        },
    ],
    'ExpiryTime': datetime(2015, 1, 1),
    'VolumeSize': 123,
    'BlockSize': 123,
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • ChangedBlocks (list) --

      An array of objects containing information about the changed blocks.

      • (dict) --

        A block of data in an Amazon Elastic Block Store snapshot that is different from another snapshot of the same volume/snapshot lineage.

        • BlockIndex (integer) --

          The block index.

        • FirstBlockToken (string) --

          The block token for the block index of the FirstSnapshotId specified in the ListChangedBlocks operation. This value is absent if the first snapshot does not have the changed block that is on the second snapshot.

        • SecondBlockToken (string) --

          The block token for the block index of the SecondSnapshotId specified in the ListChangedBlocks operation.

    • ExpiryTime (datetime) --

      The time when the BlockToken expires.

    • VolumeSize (integer) --

      The size of the volume in GB.

    • BlockSize (integer) --

      The size of the block.

    • NextToken (string) --

      The token to use to retrieve the next page of results. This value is null when there are no more results to return.

Exceptions

list_snapshot_blocks(**kwargs)

Returns information about the blocks in an Amazon Elastic Block Store snapshot.

See also: AWS API Documentation

Request Syntax

response = client.list_snapshot_blocks(
    SnapshotId='string',
    NextToken='string',
    MaxResults=123,
    StartingBlockIndex=123
)
Parameters
  • SnapshotId (string) --

    [REQUIRED]

    The ID of the snapshot from which to get block indexes and block tokens.

  • NextToken (string) -- The token to request the next page of results.
  • MaxResults (integer) -- The number of results to return.
  • StartingBlockIndex (integer) -- The block index from which the list should start. The list in the response will start from this block index or the next valid block index in the snapshot.
Return type

dict

Returns

Response Syntax

{
    'Blocks': [
        {
            'BlockIndex': 123,
            'BlockToken': 'string'
        },
    ],
    'ExpiryTime': datetime(2015, 1, 1),
    'VolumeSize': 123,
    'BlockSize': 123,
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • Blocks (list) --

      An array of objects containing information about the blocks.

      • (dict) --

        A block of data in an Amazon Elastic Block Store snapshot.

        • BlockIndex (integer) --

          The block index.

        • BlockToken (string) --

          The block token for the block index.

    • ExpiryTime (datetime) --

      The time when the BlockToken expires.

    • VolumeSize (integer) --

      The size of the volume in GB.

    • BlockSize (integer) --

      The size of the block.

    • NextToken (string) --

      The token to use to retrieve the next page of results. This value is null when there are no more results to return.

Exceptions

put_snapshot_block(**kwargs)

Writes a block of data to a 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

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

    [REQUIRED]

    The ID of the snapshot.

  • BlockIndex (integer) --

    [REQUIRED]

    The block index of the block in which to write the data. A block index is a logical index in units of 512 KiB blocks. To identify the block index, divide the logical offset of the data in the logical volume by the block size (logical offset of data/524288 ). The logical offset of the data must be 512 KiB aligned.

  • BlockData (bytes or seekable file-like object) --

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

  • DataLength (integer) --

    [REQUIRED]

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

    Valid values: 524288

  • Progress (integer) -- The progress of the write process, as a percentage.
  • Checksum (string) --

    [REQUIRED]

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

  • ChecksumAlgorithm (string) --

    [REQUIRED]

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

Return type

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.

Exceptions

start_snapshot(**kwargs)

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

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

    [REQUIRED]

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

  • ParentSnapshotId (string) --

    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 .

  • Tags (list) --

    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.

  • Description (string) -- A description for the snapshot.
  • ClientToken (string) --

    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.

  • Encrypted (boolean) --

    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 .

  • KmsKeyArn (string) --

    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.

  • Timeout (integer) --

    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.

Return type

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.

Exceptions

Client Exceptions

Client exceptions are available on a client instance via the exceptions property. For more detailed instructions and examples on the exact usage of client exceptions, see the error handling user guide.

The available client exceptions are:

class EBS.Client.exceptions.AccessDeniedException

You do not have sufficient access to perform this action.

Example

try:
  ...
except client.exceptions.AccessDeniedException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Reason': 'UNAUTHORIZED_ACCOUNT'|'DEPENDENCY_ACCESS_DENIED',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    You do not have sufficient access to perform this action.

    • Message (string) --

    • Reason (string) --

      The reason for the exception.

    • Error (dict) -- Normalized access to common exception attributes.

      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class EBS.Client.exceptions.ConcurrentLimitExceededException

You have reached the limit for concurrent API requests. For more information, see Optimizing performance of the EBS direct APIs in the Amazon Elastic Compute Cloud User Guide .

Example

try:
  ...
except client.exceptions.ConcurrentLimitExceededException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    You have reached the limit for concurrent API requests. For more information, see Optimizing performance of the EBS direct APIs in the Amazon Elastic Compute Cloud User Guide .

    • Message (string) --
    • Error (dict) -- Normalized access to common exception attributes.
      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class EBS.Client.exceptions.ConflictException

The request uses the same client token as a previous, but non-identical request.

Example

try:
  ...
except client.exceptions.ConflictException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    The request uses the same client token as a previous, but non-identical request.

    • Message (string) --
    • Error (dict) -- Normalized access to common exception attributes.
      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class EBS.Client.exceptions.InternalServerException

An internal error has occurred.

Example

try:
  ...
except client.exceptions.InternalServerException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    An internal error has occurred.

    • Message (string) --
    • Error (dict) -- Normalized access to common exception attributes.
      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class EBS.Client.exceptions.RequestThrottledException

The number of API requests has exceed the maximum allowed API request throttling limit.

Example

try:
  ...
except client.exceptions.RequestThrottledException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Reason': 'ACCOUNT_THROTTLED'|'DEPENDENCY_REQUEST_THROTTLED',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    The number of API requests has exceed the maximum allowed API request throttling limit.

    • Message (string) --

    • Reason (string) --

      The reason for the exception.

    • Error (dict) -- Normalized access to common exception attributes.

      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class EBS.Client.exceptions.ResourceNotFoundException

The specified resource does not exist.

Example

try:
  ...
except client.exceptions.ResourceNotFoundException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Reason': 'SNAPSHOT_NOT_FOUND'|'DEPENDENCY_RESOURCE_NOT_FOUND',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    The specified resource does not exist.

    • Message (string) --

    • Reason (string) --

      The reason for the exception.

    • Error (dict) -- Normalized access to common exception attributes.

      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class EBS.Client.exceptions.ServiceQuotaExceededException

Your current service quotas do not allow you to perform this action.

Example

try:
  ...
except client.exceptions.ServiceQuotaExceededException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Reason': 'DEPENDENCY_SERVICE_QUOTA_EXCEEDED',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    Your current service quotas do not allow you to perform this action.

    • Message (string) --

    • Reason (string) --

      The reason for the exception.

    • Error (dict) -- Normalized access to common exception attributes.

      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.
class EBS.Client.exceptions.ValidationException

The input fails to satisfy the constraints of the EBS direct APIs.

Example

try:
  ...
except client.exceptions.ValidationException as e:
  print(e.response)
response

The parsed error response. All exceptions have a top level Error key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.

Syntax

{
    'Message': 'string',
    'Reason': 'INVALID_CUSTOMER_KEY'|'INVALID_PAGE_TOKEN'|'INVALID_BLOCK_TOKEN'|'INVALID_SNAPSHOT_ID'|'UNRELATED_SNAPSHOTS'|'INVALID_BLOCK'|'INVALID_CONTENT_ENCODING'|'INVALID_TAG'|'INVALID_DEPENDENCY_REQUEST'|'INVALID_PARAMETER_VALUE'|'INVALID_VOLUME_SIZE',
    'Error': {
        'Code': 'string',
        'Message': 'string'
    }
}

Structure

  • (dict) --

    The input fails to satisfy the constraints of the EBS direct APIs.

    • Message (string) --

    • Reason (string) --

      The reason for the validation exception.

    • Error (dict) -- Normalized access to common exception attributes.

      • Code (string) -- An identifier specifying the exception type.
      • Message (string) -- A descriptive message explaining why the exception occured.

Paginators

The available paginators are: