import boto3 import config dynamodb = boto3.resource('dynamodb') table = dynamodb.create_table( TableName=config.TABLE_NAME, KeySchema=[ { 'AttributeName': 'first_id', 'KeyType': 'HASH' }, { 'AttributeName': 'second_id', 'KeyType': 'RANGE' }, ], AttributeDefinitions=[ { 'AttributeName': 'first_id', 'AttributeType': 'S' }, { 'AttributeName': 'second_id', 'AttributeType': 'S' }, ], GlobalSecondaryIndexes=[ { 'IndexName': 'second_id-first_id', 'KeySchema': [ { 'AttributeName': 'second_id', 'KeyType': 'HASH' }, { 'AttributeName': 'first_id', 'KeyType': 'RANGE' } ], 'Projection': { 'ProjectionType': 'ALL' }, 'ProvisionedThroughput': { 'ReadCapacityUnits': 7, 'WriteCapacityUnits': 7 } }, ], ProvisionedThroughput={ 'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5 } ) table.meta.client.get_waiter('table_exists').wait(TableName=config.TABLE_NAME) print('table created at: {}'.format(table.creation_date_time)) print(table.item_count)