这是我的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本身。
有人可以指出我的模板有什么问题吗?
答案 0 :(得分:161)
这归结于我对DynamoDB的误解。此处应定义的仅属性是将用作键的属性。因此,将AttributeDefinitions数组更改为以下解决了问题:
"AttributeDefinitions": [
{
"AttributeName": "audit_id",
"AttributeType": "S"
}
]