Amazon web services 调用CreateTable操作时出错(ValidationException):成员必须满足枚举值集:[B,N,S]

Amazon web services 调用CreateTable操作时出错(ValidationException):成员必须满足枚举值集:[B,N,S],amazon-web-services,amazon-dynamodb,boto3,Amazon Web Services,Amazon Dynamodb,Boto3,我正在尝试用以下代码创建一个表 table = dynamodb.create_table( TableName='log', AttributeDefinitions=[ { 'AttributeName': 'lastcall', 'AttributeType': 's' } ], KeySchema=[ { 'AttributeNa

我正在尝试用以下代码创建一个表

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


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

我得到了上面的错误,无法找出云的错误所在。

您的
属性类型必须是大写的S,就像这样
'AttributeType':'S'
这导致了你的错误

您还需要指定
BillingMode
,如果您不选择按需计费,则可能需要指定
ProvisionedThroughput

代码应该如下所示:

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
    },
)