Invalid KeySchema: The second KeySchemaElement is not a RANGE key type

amazon-dynamodb, aws-cloudformation

Solution

The answer is that only one of the keys can be a HASH key in the primary index. The second key must be of RANGE type, even if you never plan on comparing it with > or <. I'd love it if somebody could elaborate on why I can't have two HASH keys. Why doesn't Dynamo just concatenate the two keys internally and create one primary key?

Problem

In my Cloudformation script, I'm creating a Dynamo DB table (Datasets) with two keys - let's call them CatalogId and DatasetId. They are both URIs that are outside of my control, but suffice it to say that together they make a unique ID. I made both of them HASH keys in the primary KeySchema / index. When I did that, CF gave me the following error: ``` Invalid KeySchema: The second KeySchemaElement is not a RANGE key type ``` What am I doing wrong?

Original source