j'obtiens l'erreur suivante lorsque vous appelez mon adresse lambdaDynamoDB exception de validation lambda
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
Voici le code:
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
}
)
Selon mon tableau de bord de l'erreur est sur la ligne TableName='Values'
. Je suivais un tutoriel et seulement changé certaines choses, donc je ne vois pas pourquoi cela ne fonctionne pas. Je ne peux pas tester sur un environnement local car j'ai des problèmes de région/d'identification.
DynamoDB nécessite une clé de hachage et non plus d'une clé de plage dans la clé primaire, ne ce pas? –