CloudFormation insists my DynamoDB creation JSON is invalid .. but I can't see how

Amazon DynamodbAmazon Cloudformation

Amazon Dynamodb Problem Overview


Here's (the DynamoDB part of) my Troposphere-generated JSON:

"sandbox": {
        "Properties": {
            "AttributeDefinitions": [
                {
                    "AttributeName": "audit_id",
                    "AttributeType": "S"
                },
                {
                    "AttributeName": "status",
                    "AttributeType": "S"
                },
                {
                    "AttributeName": "filename",
                    "AttributeType": "S"
                },
                {
                    "AttributeName": "file_detected_dt",
                    "AttributeType": "S"
                },
                {
                    "AttributeName": "time_taken",
                    "AttributeType": "N"
                },
                {
                    "AttributeName": "number_rows_processed_file",
                    "AttributeType": "N"
                },
                {
                    "AttributeName": "number_rows_created_db",
                    "AttributeType": "N"
                },
                {
                    "AttributeName": "info_messages",
                    "AttributeType": "S"
                }
            ],
            "KeySchema": [
                {
                    "AttributeName": "audit_id",
                    "KeyType": "HASH"
                }
            ],
            "ProvisionedThroughput": {
                "ReadCapacityUnits": {
                    "Ref": "ReadCapacityUnits"
                },
                "WriteCapacityUnits": {
                    "Ref": "WriteCapacityUnits"
                }
            }
        },
        "Type": "AWS::DynamoDB::Table"
    }

CloudFormation gives me this error on trying to spin up the VPC: Property AttributeDefinitions is inconsistent with the KeySchema of the table and the secondary indexes.

But ... is it? I'm specifying audit_id as a lone key, and it definitely exists within the AttributeDefinitions list. I'm very new to CF (and Dynamo, for that matter) so I may well be missing something extremely obvious, but it's not apparent to me at the moment.

I've googled around and only really found one mention of this error, and it was more to do with a layer between developer and CF, rather than CF itself.

Can anyone point out what's wrong with my template?

Amazon Dynamodb Solutions


Solution 1 - Amazon Dynamodb

This was down to a misunderstanding on my part regarding DynamoDB. The only attributes that should be defined here are those that will be used as keys. Thus, changing the AttributeDefinitions array to the following solved the problem:

"AttributeDefinitions": [
            {
                "AttributeName": "audit_id",
                "AttributeType": "S"
            }
]

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1381745View Question on Stackoverflow
Solution 1 - Amazon Dynamodbuser1381745View Answer on Stackoverflow