I am trying, and failing, to delete a record with a condition. I keep getting this error: The provided key element does not match the schema
.
This is my definition in the yml:
resources:
Resources:
vuelosTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
-
AttributeName: vuelta
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
-
AttributeName: vuelta
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.DYNAMODB_TABLE}
These are the params when trying to delete:
params = {
RequestItems: {
[process.env.DYNAMODB_TABLE]: [{
DeleteRequest: {
Key: {
"vuelta": "2017-09-09"
}
}
}]
}
};
I know it's something I am not getting, but I don't know what. Any ideas?
Your table key is both
id
andvuelta
but you're only providingvuelta
in the delete request. Modify the key in your delete request so it contains both theid
andvuelta
.Also, depending on your client library may need to specify