I'm trying to create the table shown at the bottom in DynamoDB but I get this error. I understand that you can't define more than one PK but is that also the case for GSI-PKs? How can I fix the errors?
2 validation errors detected: Value '[KeySchemaElement(attributeName=VenueID, keyType=HASH), KeySchemaElement(attributeName=VenueName, keyType=Range), KeySchemaElement(attributeName=CheckInID, keyType=HASH)]' at 'globalSecondaryIndexes.1.member.keySchema' failed to satisfy constraint: Member must have length less than or equal to 2;
Value 'Range' at 'globalSecondaryIndexes.1.member.keySchema.2.member.keyType' failed to satisfy constraint: Member must satisfy enum value set: [HASH, RANGE]
Serverless.yml
resources:
Resources:
BeaconTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.beaconsTable}
AttributeDefinitions:
- AttributeName: BeaconAddr
AttributeType: S
- AttributeName: VenueID
AttributeType: S
- AttributeName: VenueName
AttributeType: S
- AttributeName: CheckInID
AttributeType: S
KeySchema:
- AttributeName: BeaconAddr
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: BeaconAddr-index
KeySchema:
- AttributeName: VenueID
KeyType: HASH
- AttributeName: VenueName
KeyType: Range
- AttributeName: CheckInID
KeyType: HASH
Projection:
ProjectionType: "ALL"
BillingMode: PAY_PER_REQUEST
If you need indices on two attributes, create two indices. You cannot have one BeaconAddr-index
index with two hash attributes.
Also, I wonder if you've misunderstood something because naming your index BeaconAddr-index
when it's NOT indexed on BeaconAddr
seems odd? What did you intend to do?