叫我拉姆达技能DynamoDB验证异常的拉姆达
ClientError: An error occurred (ValidationException)
when calling the CreateTable operation: 1 validation error detected:
Value '[[email protected],
[email protected],
[email protected]]' at
'keySchema' failed to satisfy constraint: Member must have length less than or equal to 2
当我在这里收到以下错误代码:
def write_values_to_db(ddid, token, intent):
pid = ...
dynamodb_client = boto3.client('dynamodb')
try:
response = dynamodb_client.create_table(
AttributeDefinitions=[
{
'AttributeName': 'pid',
'AttributeType': 'S',
},
{
'AttributeName': 'ddid',
'AttributeType': 'S',
},
{
'AttributeName': 'token',
'AttributeType': 'S',
},
],
KeySchema=[
{
'AttributeName': 'pid',
'KeyType': 'HASH',
},
{
'AttributeName': 'ddid',
'KeyType': 'RANGE',
},
{
'AttributeName': 'token',
'KeyType': 'RANGE',
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 5,
'WriteCapacityUnits': 5,
},
TableName='Values',
)
except dynamodb_client.exceptions.ResourceInUseException:
dynamodb_client.put_item(
TableName='Values',
Item={
'pid': pid,
'ddid': ddid,
'token': token
}
)
根据我的仪表盘上的错误是在TableName='Values'
线。我正在跟着一个教程,只改变了某些东西,所以我不明白为什么这不起作用。我无法在本地环境中测试,因为我有区域/凭证问题。
DynamoDB需要一个散列密钥,并在主键不超过一个范围键,不是吗? –