Amazon DynamoDB

2018/03/26 - Amazon DynamoDB - 2 new1 updated api methods

Changes  Update dynamodb client to latest version

RestoreTableToPointInTime (new) Link ¶

Restores the specified table to the specified point in time within EarliestRestorableDateTime and LatestRestorableDateTime. You can restore your table to any point in time during the last 35 days with a 1-minute granularity. Any number of users can execute up to 4 concurrent restores (any type of restore) in a given account.

You must manually set up the following on the restored table:

  • Auto scaling policies

  • IAM policies

  • Cloudwatch metrics and alarms

  • Tags

  • Stream settings

  • Time to Live (TTL) settings

  • Point in time recovery settings

See also: AWS API Documentation

Request Syntax

client.restore_table_to_point_in_time(
    SourceTableName='string',
    TargetTableName='string',
    UseLatestRestorableTime=True|False,
    RestoreDateTime=datetime(2015, 1, 1)
)
type SourceTableName:

string

param SourceTableName:

[REQUIRED]

Name of the source table that is being restored.

type TargetTableName:

string

param TargetTableName:

[REQUIRED]

The name of the new table to which it must be restored to.

type UseLatestRestorableTime:

boolean

param UseLatestRestorableTime:

Restore the table to the latest possible time. LatestRestorableDateTime is typically 5 minutes before the current time.

type RestoreDateTime:

datetime

param RestoreDateTime:

Time in the past to restore the table to.

rtype:

dict

returns:

Response Syntax

{
    'TableDescription': {
        'AttributeDefinitions': [
            {
                'AttributeName': 'string',
                'AttributeType': 'S'|'N'|'B'
            },
        ],
        'TableName': 'string',
        'KeySchema': [
            {
                'AttributeName': 'string',
                'KeyType': 'HASH'|'RANGE'
            },
        ],
        'TableStatus': 'CREATING'|'UPDATING'|'DELETING'|'ACTIVE',
        'CreationDateTime': datetime(2015, 1, 1),
        'ProvisionedThroughput': {
            'LastIncreaseDateTime': datetime(2015, 1, 1),
            'LastDecreaseDateTime': datetime(2015, 1, 1),
            'NumberOfDecreasesToday': 123,
            'ReadCapacityUnits': 123,
            'WriteCapacityUnits': 123
        },
        'TableSizeBytes': 123,
        'ItemCount': 123,
        'TableArn': 'string',
        'TableId': 'string',
        'LocalSecondaryIndexes': [
            {
                'IndexName': 'string',
                'KeySchema': [
                    {
                        'AttributeName': 'string',
                        'KeyType': 'HASH'|'RANGE'
                    },
                ],
                'Projection': {
                    'ProjectionType': 'ALL'|'KEYS_ONLY'|'INCLUDE',
                    'NonKeyAttributes': [
                        'string',
                    ]
                },
                'IndexSizeBytes': 123,
                'ItemCount': 123,
                'IndexArn': 'string'
            },
        ],
        'GlobalSecondaryIndexes': [
            {
                'IndexName': 'string',
                'KeySchema': [
                    {
                        'AttributeName': 'string',
                        'KeyType': 'HASH'|'RANGE'
                    },
                ],
                'Projection': {
                    'ProjectionType': 'ALL'|'KEYS_ONLY'|'INCLUDE',
                    'NonKeyAttributes': [
                        'string',
                    ]
                },
                'IndexStatus': 'CREATING'|'UPDATING'|'DELETING'|'ACTIVE',
                'Backfilling': True|False,
                'ProvisionedThroughput': {
                    'LastIncreaseDateTime': datetime(2015, 1, 1),
                    'LastDecreaseDateTime': datetime(2015, 1, 1),
                    'NumberOfDecreasesToday': 123,
                    'ReadCapacityUnits': 123,
                    'WriteCapacityUnits': 123
                },
                'IndexSizeBytes': 123,
                'ItemCount': 123,
                'IndexArn': 'string'
            },
        ],
        'StreamSpecification': {
            'StreamEnabled': True|False,
            'StreamViewType': 'NEW_IMAGE'|'OLD_IMAGE'|'NEW_AND_OLD_IMAGES'|'KEYS_ONLY'
        },
        'LatestStreamLabel': 'string',
        'LatestStreamArn': 'string',
        'RestoreSummary': {
            'SourceBackupArn': 'string',
            'SourceTableArn': 'string',
            'RestoreDateTime': datetime(2015, 1, 1),
            'RestoreInProgress': True|False
        },
        'SSEDescription': {
            'Status': 'ENABLING'|'ENABLED'|'DISABLING'|'DISABLED'
        }
    }
}

Response Structure

  • (dict) --

    • TableDescription (dict) --

      Represents the properties of a table.

      • AttributeDefinitions (list) --

        An array of AttributeDefinition objects. Each of these objects describes one attribute in the table and index key schema.

        Each AttributeDefinition object in this array is composed of:

        • AttributeName - The name of the attribute.

        • AttributeType - The data type for the attribute.

        • (dict) --

          Represents an attribute for describing the key schema for the table and indexes.

          • AttributeName (string) --

            A name for the attribute.

          • AttributeType (string) --

            The data type for the attribute, where:

            • S - the attribute is of type String

            • N - the attribute is of type Number

            • B - the attribute is of type Binary

      • TableName (string) --

        The name of the table.

      • KeySchema (list) --

        The primary key structure for the table. Each KeySchemaElement consists of:

        • AttributeName - The name of the attribute.

        • KeyType - The role of the attribute:

          • HASH - partition key

          • RANGE - sort key

        For more information about primary keys, see Primary Key in the Amazon DynamoDB Developer Guide.

        • (dict) --

          Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.

          A KeySchemaElement represents exactly one attribute of the primary key. For example, a simple primary key would be represented by one KeySchemaElement (for the partition key). A composite primary key would require one KeySchemaElement for the partition key, and another KeySchemaElement for the sort key.

          A KeySchemaElement must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.

          • AttributeName (string) --

            The name of a key attribute.

          • KeyType (string) --

            The role that this key attribute will assume:

            • HASH - partition key

            • RANGE - sort key

      • TableStatus (string) --

        The current state of the table:

        • CREATING - The table is being created.

        • UPDATING - The table is being updated.

        • DELETING - The table is being deleted.

        • ACTIVE - The table is ready for use.

      • CreationDateTime (datetime) --

        The date and time when the table was created, in UNIX epoch time format.

      • ProvisionedThroughput (dict) --

        The provisioned throughput settings for the table, consisting of read and write capacity units, along with data about increases and decreases.

        • LastIncreaseDateTime (datetime) --

          The date and time of the last provisioned throughput increase for this table.

        • LastDecreaseDateTime (datetime) --

          The date and time of the last provisioned throughput decrease for this table.

        • NumberOfDecreasesToday (integer) --

          The number of provisioned throughput decreases for this table during this UTC calendar day. For current maximums on provisioned throughput decreases, see Limits in the Amazon DynamoDB Developer Guide.

        • ReadCapacityUnits (integer) --

          The maximum number of strongly consistent reads consumed per second before DynamoDB returns a ThrottlingException. Eventually consistent reads require less effort than strongly consistent reads, so a setting of 50 ReadCapacityUnits per second provides 100 eventually consistent ReadCapacityUnits per second.

        • WriteCapacityUnits (integer) --

          The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException.

      • TableSizeBytes (integer) --

        The total size of the specified table, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

      • ItemCount (integer) --

        The number of items in the specified table. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

      • TableArn (string) --

        The Amazon Resource Name (ARN) that uniquely identifies the table.

      • TableId (string) --

        Unique identifier for the table for which the backup was created.

      • LocalSecondaryIndexes (list) --

        Represents one or more local secondary indexes on the table. Each index is scoped to a given partition key value. Tables with one or more local secondary indexes are subject to an item collection size limit, where the amount of data within a given item collection cannot exceed 10 GB. Each element is composed of:

        • IndexName - The name of the local secondary index.

        • KeySchema - Specifies the complete index key schema. The attribute names in the key schema must be between 1 and 255 characters (inclusive). The key schema must begin with the same partition key as the table.

        • Projection - Specifies attributes that are copied (projected) from the table into the index. These are in addition to the primary key attributes and index key attributes, which are automatically projected. Each attribute specification is composed of:

          • ProjectionType - One of the following:

            • KEYS_ONLY - Only the index and primary keys are projected into the index.

            • INCLUDE - Only the specified table attributes are projected into the index. The list of projected attributes are in NonKeyAttributes.

            • ALL - All of the table attributes are projected into the index.

          • NonKeyAttributes - A list of one or more non-key attribute names that are projected into the secondary index. The total count of attributes provided in NonKeyAttributes, summed across all of the secondary indexes, must not exceed 20. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.

        • IndexSizeBytes - Represents the total size of the index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

        • ItemCount - Represents the number of items in the index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

        If the table is in the DELETING state, no information about indexes will be returned.

        • (dict) --

          Represents the properties of a local secondary index.

          • IndexName (string) --

            Represents the name of the local secondary index.

          • KeySchema (list) --

            The complete key schema for the local secondary index, consisting of one or more pairs of attribute names and key types:

            • HASH - partition key

            • RANGE - sort key

            • (dict) --

              Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.

              A KeySchemaElement represents exactly one attribute of the primary key. For example, a simple primary key would be represented by one KeySchemaElement (for the partition key). A composite primary key would require one KeySchemaElement for the partition key, and another KeySchemaElement for the sort key.

              A KeySchemaElement must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.

              • AttributeName (string) --

                The name of a key attribute.

              • KeyType (string) --

                The role that this key attribute will assume:

                • HASH - partition key

                • RANGE - sort key

          • Projection (dict) --

            Represents attributes that are copied (projected) from the table into the global secondary index. These are in addition to the primary key attributes and index key attributes, which are automatically projected.

            • ProjectionType (string) --

              The set of attributes that are projected into the index:

              • KEYS_ONLY - Only the index and primary keys are projected into the index.

              • INCLUDE - Only the specified table attributes are projected into the index. The list of projected attributes are in NonKeyAttributes.

              • ALL - All of the table attributes are projected into the index.

            • NonKeyAttributes (list) --

              Represents the non-key attribute names which will be projected into the index.

              For local secondary indexes, the total count of NonKeyAttributes summed across all of the local secondary indexes, must not exceed 20. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.

              • (string) --

          • IndexSizeBytes (integer) --

            The total size of the specified index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

          • ItemCount (integer) --

            The number of items in the specified index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

          • IndexArn (string) --

            The Amazon Resource Name (ARN) that uniquely identifies the index.

      • GlobalSecondaryIndexes (list) --

        The global secondary indexes, if any, on the table. Each index is scoped to a given partition key value. Each element is composed of:

        • Backfilling - If true, then the index is currently in the backfilling phase. Backfilling occurs only when a new global secondary index is added to the table; it is the process by which DynamoDB populates the new index with data from the table. (This attribute does not appear for indexes that were created during a CreateTable operation.)

        • IndexName - The name of the global secondary index.

        • IndexSizeBytes - The total size of the global secondary index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

        • IndexStatus - The current status of the global secondary index:

          • CREATING - The index is being created.

          • UPDATING - The index is being updated.

          • DELETING - The index is being deleted.

          • ACTIVE - The index is ready for use.

        • ItemCount - The number of items in the global secondary index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

        • KeySchema - Specifies the complete index key schema. The attribute names in the key schema must be between 1 and 255 characters (inclusive). The key schema must begin with the same partition key as the table.

        • Projection - Specifies attributes that are copied (projected) from the table into the index. These are in addition to the primary key attributes and index key attributes, which are automatically projected. Each attribute specification is composed of:

          • ProjectionType - One of the following:

            • KEYS_ONLY - Only the index and primary keys are projected into the index.

            • INCLUDE - Only the specified table attributes are projected into the index. The list of projected attributes are in NonKeyAttributes.

            • ALL - All of the table attributes are projected into the index.

          • NonKeyAttributes - A list of one or more non-key attribute names that are projected into the secondary index. The total count of attributes provided in NonKeyAttributes, summed across all of the secondary indexes, must not exceed 20. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.

        • ProvisionedThroughput - The provisioned throughput settings for the global secondary index, consisting of read and write capacity units, along with data about increases and decreases.

        If the table is in the DELETING state, no information about indexes will be returned.

        • (dict) --

          Represents the properties of a global secondary index.

          • IndexName (string) --

            The name of the global secondary index.

          • KeySchema (list) --

            The complete key schema for a global secondary index, which consists of one or more pairs of attribute names and key types:

            • HASH - partition key

            • RANGE - sort key

            • (dict) --

              Represents a single element of a key schema. A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.

              A KeySchemaElement represents exactly one attribute of the primary key. For example, a simple primary key would be represented by one KeySchemaElement (for the partition key). A composite primary key would require one KeySchemaElement for the partition key, and another KeySchemaElement for the sort key.

              A KeySchemaElement must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.

              • AttributeName (string) --

                The name of a key attribute.

              • KeyType (string) --

                The role that this key attribute will assume:

                • HASH - partition key

                • RANGE - sort key

          • Projection (dict) --

            Represents attributes that are copied (projected) from the table into the global secondary index. These are in addition to the primary key attributes and index key attributes, which are automatically projected.

            • ProjectionType (string) --

              The set of attributes that are projected into the index:

              • KEYS_ONLY - Only the index and primary keys are projected into the index.

              • INCLUDE - Only the specified table attributes are projected into the index. The list of projected attributes are in NonKeyAttributes.

              • ALL - All of the table attributes are projected into the index.

            • NonKeyAttributes (list) --

              Represents the non-key attribute names which will be projected into the index.

              For local secondary indexes, the total count of NonKeyAttributes summed across all of the local secondary indexes, must not exceed 20. If you project the same attribute into two different indexes, this counts as two distinct attributes when determining the total.

              • (string) --

          • IndexStatus (string) --

            The current state of the global secondary index:

            • CREATING - The index is being created.

            • UPDATING - The index is being updated.

            • DELETING - The index is being deleted.

            • ACTIVE - The index is ready for use.

          • Backfilling (boolean) --

            Indicates whether the index is currently backfilling. Backfilling is the process of reading items from the table and determining whether they can be added to the index. (Not all items will qualify: For example, a partition key cannot have any duplicate values.) If an item can be added to the index, DynamoDB will do so. After all items have been processed, the backfilling operation is complete and Backfilling is false.

          • ProvisionedThroughput (dict) --

            Represents the provisioned throughput settings for the specified global secondary index.

            For current minimum and maximum provisioned throughput values, see Limits in the Amazon DynamoDB Developer Guide.

            • LastIncreaseDateTime (datetime) --

              The date and time of the last provisioned throughput increase for this table.

            • LastDecreaseDateTime (datetime) --

              The date and time of the last provisioned throughput decrease for this table.

            • NumberOfDecreasesToday (integer) --

              The number of provisioned throughput decreases for this table during this UTC calendar day. For current maximums on provisioned throughput decreases, see Limits in the Amazon DynamoDB Developer Guide.

            • ReadCapacityUnits (integer) --

              The maximum number of strongly consistent reads consumed per second before DynamoDB returns a ThrottlingException. Eventually consistent reads require less effort than strongly consistent reads, so a setting of 50 ReadCapacityUnits per second provides 100 eventually consistent ReadCapacityUnits per second.

            • WriteCapacityUnits (integer) --

              The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException.

          • IndexSizeBytes (integer) --

            The total size of the specified index, in bytes. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

          • ItemCount (integer) --

            The number of items in the specified index. DynamoDB updates this value approximately every six hours. Recent changes might not be reflected in this value.

          • IndexArn (string) --

            The Amazon Resource Name (ARN) that uniquely identifies the index.

      • StreamSpecification (dict) --

        The current DynamoDB Streams configuration for the table.

        • StreamEnabled (boolean) --

          Indicates whether DynamoDB Streams is enabled (true) or disabled (false) on the table.

        • StreamViewType (string) --

          When an item in the table is modified, StreamViewType determines what information is written to the stream for this table. Valid values for StreamViewType are:

          • KEYS_ONLY - Only the key attributes of the modified item are written to the stream.

          • NEW_IMAGE - The entire item, as it appears after it was modified, is written to the stream.

          • OLD_IMAGE - The entire item, as it appeared before it was modified, is written to the stream.

          • NEW_AND_OLD_IMAGES - Both the new and the old item images of the item are written to the stream.

      • LatestStreamLabel (string) --

        A timestamp, in ISO 8601 format, for this stream.

        Note that LatestStreamLabel is not a unique identifier for the stream, because it is possible that a stream from another table might have the same timestamp. However, the combination of the following three elements is guaranteed to be unique:

        • the AWS customer ID.

        • the table name.

        • the StreamLabel.

      • LatestStreamArn (string) --

        The Amazon Resource Name (ARN) that uniquely identifies the latest stream for this table.

      • RestoreSummary (dict) --

        Contains details for the restore.

        • SourceBackupArn (string) --

          ARN of the backup from which the table was restored.

        • SourceTableArn (string) --

          ARN of the source table of the backup that is being restored.

        • RestoreDateTime (datetime) --

          Point in time or source backup time.

        • RestoreInProgress (boolean) --

          Indicates if a restore is in progress or not.

      • SSEDescription (dict) --

        The description of the server-side encryption status on the specified table.

        • Status (string) --

          The current state of server-side encryption:

          • ENABLING - Server-side encryption is being enabled.

          • ENABLED - Server-side encryption is enabled.

          • DISABLING - Server-side encryption is being disabled.

          • DISABLED - Server-side encryption is disabled.

UpdateContinuousBackups (new) Link ¶

UpdateContinuousBackups enables or disables point in time recovery for the specified table. A successful UpdateContinuousBackups call returns the current ContinuousBackupsDescription. Continuous backups are ENABLED on all tables at table creation. If point in time recovery is enabled, PointInTimeRecoveryStatus will be set to ENABLED.

Once continuous backups and point in time recovery are enabled, you can restore to any point in time within EarliestRestorableDateTime and LatestRestorableDateTime.

LatestRestorableDateTime is typically 5 minutes before the current time. You can restore your table to any point in time during the last 35 days with a 1-minute granularity.

See also: AWS API Documentation

Request Syntax

client.update_continuous_backups(
    TableName='string',
    PointInTimeRecoverySpecification={
        'PointInTimeRecoveryEnabled': True|False
    }
)
type TableName:

string

param TableName:

[REQUIRED]

The name of the table.

type PointInTimeRecoverySpecification:

dict

param PointInTimeRecoverySpecification:

[REQUIRED]

Represents the settings used to enable point in time recovery.

  • PointInTimeRecoveryEnabled (boolean) -- [REQUIRED]

    Indicates whether point in time recovery is enabled (true) or disabled (false) on the table.

rtype:

dict

returns:

Response Syntax

{
    'ContinuousBackupsDescription': {
        'ContinuousBackupsStatus': 'ENABLED'|'DISABLED',
        'PointInTimeRecoveryDescription': {
            'PointInTimeRecoveryStatus': 'ENABLED'|'DISABLED',
            'EarliestRestorableDateTime': datetime(2015, 1, 1),
            'LatestRestorableDateTime': datetime(2015, 1, 1)
        }
    }
}

Response Structure

  • (dict) --

    • ContinuousBackupsDescription (dict) --

      Represents the continuous backups and point in time recovery settings on the table.

      • ContinuousBackupsStatus (string) --

        ContinuousBackupsStatus can be one of the following states : ENABLED, DISABLED

      • PointInTimeRecoveryDescription (dict) --

        The description of the point in time recovery settings applied to the table.

        • PointInTimeRecoveryStatus (string) --

          The current state of point in time recovery:

          • ENABLING - Point in time recovery is being enabled.

          • ENABLED - Point in time recovery is enabled.

          • DISABLED - Point in time recovery is disabled.

        • EarliestRestorableDateTime (datetime) --

          Specifies the earliest point in time you can restore your table to. It is equal to the maximum of point in time recovery enabled time and CurrentTime - PointInTimeRecoveryPeriod.

        • LatestRestorableDateTime (datetime) --

          LatestRestorableDateTime is 5 minutes from now and there is a +/- 1 minute fuzziness on the restore times.

DescribeContinuousBackups (updated) Link ¶
Changes (response)
{'ContinuousBackupsDescription': {'PointInTimeRecoveryDescription': {'EarliestRestorableDateTime': 'timestamp',
                                                                     'LatestRestorableDateTime': 'timestamp',
                                                                     'PointInTimeRecoveryStatus': 'ENABLED '
                                                                                                  '| '
                                                                                                  'DISABLED'}}}

Checks the status of continuous backups and point in time recovery on the specified table. Continuous backups are ENABLED on all tables at table creation. If point in time recovery is enabled, PointInTimeRecoveryStatus will be set to ENABLED.

Once continuous backups and point in time recovery are enabled, you can restore to any point in time within EarliestRestorableDateTime and LatestRestorableDateTime.

LatestRestorableDateTime is typically 5 minutes before the current time. You can restore your table to any point in time during the last 35 days with a 1-minute granularity.

You can call DescribeContinuousBackups at a maximum rate of 10 times per second.

See also: AWS API Documentation

Request Syntax

client.describe_continuous_backups(
    TableName='string'
)
type TableName:

string

param TableName:

[REQUIRED]

Name of the table for which the customer wants to check the continuous backups and point in time recovery settings.

rtype:

dict

returns:

Response Syntax

{
    'ContinuousBackupsDescription': {
        'ContinuousBackupsStatus': 'ENABLED'|'DISABLED',
        'PointInTimeRecoveryDescription': {
            'PointInTimeRecoveryStatus': 'ENABLED'|'DISABLED',
            'EarliestRestorableDateTime': datetime(2015, 1, 1),
            'LatestRestorableDateTime': datetime(2015, 1, 1)
        }
    }
}

Response Structure

  • (dict) --

    • ContinuousBackupsDescription (dict) --

      ContinuousBackupsDescription can be one of the following : ENABLED, DISABLED.

      • ContinuousBackupsStatus (string) --

        ContinuousBackupsStatus can be one of the following states : ENABLED, DISABLED

      • PointInTimeRecoveryDescription (dict) --

        The description of the point in time recovery settings applied to the table.

        • PointInTimeRecoveryStatus (string) --

          The current state of point in time recovery:

          • ENABLING - Point in time recovery is being enabled.

          • ENABLED - Point in time recovery is enabled.

          • DISABLED - Point in time recovery is disabled.

        • EarliestRestorableDateTime (datetime) --

          Specifies the earliest point in time you can restore your table to. It is equal to the maximum of point in time recovery enabled time and CurrentTime - PointInTimeRecoveryPeriod.

        • LatestRestorableDateTime (datetime) --

          LatestRestorableDateTime is 5 minutes from now and there is a +/- 1 minute fuzziness on the restore times.