The code that you can use to create a tabke in Dynamo DB is as follows:-
import boto3
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
table = dynamodb.create_table(
TableName='PhoneBook',
KeySchema=[
{
'AttributeName': 'ID',
'KeyType': 'HASH' #Partition key
},
{
'AttributeName': 'Name',
'KeyType': 'RANGE' #Sort key
}
],
AttributeDefinitions=[
{
'AttributeName': 'ID',
'AttributeType': 'N'
},
{
'AttributeName': 'Name',
'AttributeType': 'S'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 10,
'WriteCapacityUnits': 10
}
)
print("Table status:", table.table_status)
OUTPUT:
Table status: CREATING