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

use*_*745 80 aws-cloudformation amazon-dynamodb

这是我的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"
    }
Run Code Online (Sandbox Code Playgroud)

CloudFormation在尝试启动VPC时给出了这个错误: Property AttributeDefinitions is inconsistent with the KeySchema of the table and the secondary indexes.

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

我已经google了一下,只是真的发现了一个这个错误,这更多的是与开发人员和CF之间的层,而不是CF本身.

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

use*_*745 176

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

"AttributeDefinitions": [
            {
                "AttributeName": "audit_id",
                "AttributeType": "S"
            }
]
Run Code Online (Sandbox Code Playgroud)

  • 这里的错误是试图定义表的模式(即关系数据库中表的'列').在DynamoDb中,您只定义用于检索表中项的值的键,而不是项本​​身的模式.DynamoDb是无模式的,并且在添加项目时定义针对每个键存储的值.没有要定义的数据形状. (9认同)
  • 这也被捕获[这里](http://stackoverflow.com/a/30924384/1111215) (3认同)
  • 噢,我多年来一直坚持这个完全相同的问题.谢谢. (3认同)
  • 并非每个英雄都披着斗篷...感谢大家的光临! (3认同)