叫我拉姆達技能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需要一個散列密鑰,並在主鍵不超過一個範圍鍵,不是嗎? –