I am trying to create dynamo db table with python. Below is the script i have. I am trying to create one partition key and sort key and bunch of columns.
What I tried:
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.create_table(
TableName='g_view_data',
KeySchema=[
{
'AttributeName': 'customer_id',
'KeyType': 'HASH' #Partition key
},
{
'AttributeName': 'key_id',
'KeyType': 'RANGE' #Sort key
}
],
AttributeDefinitions=[
{
'AttributeName': 'cusotmer_id',
'AttributeType': 'N'
},
{
'AttributeName': 'key_id',
'AttributeType': 'N'
},
{
'AttributeName': 'dashboard_name',
'AttributeType': 'S'
},
{
'AttributeName': 'tsm',
'AttributeType': 'S'
},
{
'AttributeName': 'security_block',
'AttributeType': 'S'
},
{
'AttributeName': 'core_block',
'AttributeType': 'S'
},
{
'AttributeName': 'type',
'AttributeType': 'S'
},
{
'AttributeName': 'subscription',
'AttributeType': 'S'
},
{
'AttributeName': 'account_id',
'AttributeType': 'S'
},
{
'AttributeName': 'region',
'AttributeType': 'S'
},
{
'AttributeName': 'NAT',
'AttributeType': 'S'
},
{
'AttributeName': 'jb',
'AttributeType': 'S'
},
{
'AttributeName': 'dc',
'AttributeType': 'S'
},
{
'AttributeName': 'av',
'AttributeType': 'S'
},
{
'AttributeName': 'gl',
'AttributeType': 'S'
},
{
'AttributeName': 'backup',
'AttributeType': 'S'
},
{
'AttributeName': 'cpm',
'AttributeType': 'S'
},
{
'AttributeName': 'zb',
'AttributeType': 'S'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 10,
'WriteCapacityUnits': 10
}
)
print("Table status:", table.table_status)
Output i am getting:
invalid One or more parameter values were invalid: Some index key attributes are not defined in AttributeDefinitions.
can some one suggest what wrong with my code..just trying to create a simple table. why it complains parameters are missing. not sure..can some one suggest pls
Edit1: after adding customer_id,key_id in attributes i am getting different error
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the CreateTable operation: One or more parameter values were invalid: Number of attributes in KeySchema does not exactly match number of attributes defined in AttributeDefinitions