CloudFormation坚持认为我的DynamoDB创建JSON无效..但我看不出如何

时间:2016-07-01 10:17:23

标签: amazon-dynamodb amazon-cloudformation

这是我的Troposphere生成的JSON中的(DynamoDB部分):

"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在尝试启动VPC时给出了这个错误:Property AttributeDefinitions is inconsistent with the KeySchema of the table and the secondary indexes

但是......是吗?我将audit_id指定为单独的键,它肯定存在于AttributeDefinitions列表中。我对CF(和Dynamo,对于那个问题)很新,所以我很可能会遗漏一些非常明显的东西,但目前对我来说并不明显。

我已经四处搜索,只是真的发现了一个这个错误的提及,而更多的是与开发人员和CF之间的层,而不是CF本身。

有人可以指出我的模板有什么问题吗?

1 个答案:

答案 0 :(得分:161)

这归结于我对DynamoDB的误解。此处应定义的属性是将用作键的属性。因此,将AttributeDefinitions数组更改为以下解决了问题:

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