I am trying to build a DynamoDB table using boto,which will save the various aspects of an IAM policy in the table. I have defined the attributes for keyschema, I do not understand the error.I am very new to DYanmoDB and AWS. This is my code:
table =dynamodb.create_table(
TableName='GoodTable',
KeySchema=[
{
'AttributeName': 'Name',
'KeyType': 'HASH'
},
{
'AttributeName': 'Instance Type',
'KeyType': 'RANGE'
},
{
'AttributeName': 'Region',
'KeyType': 'RANGE'
},
{
'AttributeName': 'Volume Size',
'KeyType': 'RANGE'
},
],
AttributeDefinitions=[
{
"AttributeName": "Name",
"AttributeType": "S"
},
{
"AttributeName": "Instance Type",
"AttributeType": "S"
},
{
"AttributeName": "Region",
"AttributeType": "S"
},
{
"AttributeName": "Volume Size",
"AttributeType": "N"
}
],
ProvisionedThroughput={
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
}
)
time.sleep(20)
table = dynamodb.Table('GoodTable')
response = table.put_item(
Item= {
'Name': 'GoodName',
}
)
response = table.put_item(
Item= {
'Instance Type': 't2.micro',
}
)
response = table.put_item(
Item= {
'Region': 'us-east-1',
}
)
response = table.put_item(
Item= {
'Volume Size': '20',
}
)
This is the error I am getting:
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the CreateTable operation: 1 validation error detected: Value '[com.amazonaws.dynamodb.v20120810.KeySchemaElement@ad4dcbcd, com.amazonaws.dynamodb.v20120810.KeySchemaElement@126b7ad8, com.amazonaws.dynamodb.v20120810.KeySchemaElement@ca666a07, com.amazonaws.dynamodb.v20120810.KeySchemaElement@6478bc3a]' at 'keySchema' failed to satisfy constraint: Member must have length less than or equal to 2