CloudFormation 坚持我的 DynamoDB 创建 JSON 无效..但我看不到如何 [英] CloudFormation insists my DynamoDB creation JSON is invalid .. but I can't see how

查看:28
本文介绍了CloudFormation 坚持我的 DynamoDB 创建 JSON 无效..但我看不到如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的对流层生成的 JSON(的 DynamoDB 部分):

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 在尝试启动 VPC 时给我这个错误:Property AttributeDefinitions 与表的 KeySchema 和二级索引不一致.

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.

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

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.

我用谷歌搜索了一下,只真正找到了一个提到这个错误的地方,它更多地与开发人员和 CF 之间的层有关,而不是 CF 本身.

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?

推荐答案

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

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"
            }
]

这篇关于CloudFormation 坚持我的 DynamoDB 创建 JSON 无效..但我看不到如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆