An error occurred (ValidationException) when calling the CreateTable operation: Member must satisfy enum value set: [B, N, S]

Viewed 2008

I am trying to create a table with the following code

table = dynamodb.create_table(
    TableName='log',
    AttributeDefinitions=[
        {
            'AttributeName': 'lastcall',
            'AttributeType': 's'
        }


    ],
    KeySchema=[
         {
             'AttributeName': 'lastcall', #partition key 
             'KeyType': 'HASH'
         }
    ]
)

I am getting the above error not able to figure out what cloud be wrong.

1 Answers

Your AttributeType must be a capital S like so 'AttributeType': 'S' This is causing your error.

You also need to specify BillingMode and probably ProvisionedThroughput if you don't go for on-demand.

The code should look something like this:

table = dynamodb.create_table(
    TableName='log',
    AttributeDefinitions=[
    {
        'AttributeName': 'lastcall',
        'AttributeType': 'S'
    }

    ],
    KeySchema=[
    {
        'AttributeName': 'lastcall', #partition key 
        'KeyType': 'HASH'
    }
    ],
    BillingMode='PROVISIONED',
    ProvisionedThroughput={
        'ReadCapacityUnits': 5,
        'WriteCapacityUnits': 5
    },
)
Related