代码的对流层dynamodb语法

问题描述 投票:0回答:1

我有以下代码我正在尝试创建一个dynamodb表我已经为变量分配了资源代码。我无法在我的文件中缩进变量部分。

如果属性和keyschema语法的数组很好,可以帮助一些人。我可以改变什么来纠正这个缩进问题。

================

> dynamodb_table=Table(
>               "DYNAMODB_JWT_IAM",
>                       AttributeDefinitions = [AttributeDefinition([
>                               {
>                                 AttributeName="deviceId",
>                               AttributeType="HASH"
>                                      },
>                                  {
>                                                       AttributeName="solutionId",
>                                                       AttributeType="S"
>                                               }
>                                            )]],
>                       KeySchema = [KeySchema(
>               {
>                       AttributeName="solutionId",
>                                   KeyType="RANGE",
>                               },
>               {
>                                   AttributeName="deviceId",
>                               KeyType="HASH",
>                           }
>                           )],
>       ProvisionedThroughput = ProvisionedThroughput(
>               ReadCapacityUnits = 5L,
>                           WriteCapacityUnits = 6L,
>                           ),
>       TableName = DYNAMODB_JWT_IAM,
>                   Tags=dynamodb.Tags(dynamodb_tags)
>                   )   self.template.add_resource(dynamodb_table)
amazon-web-services amazon-dynamodb troposphere
1个回答
0
投票

您能否更具体地说明为什么不能以编程方式更正缩进?

我手动整理了你的缩进,发现AttributeDefinition的右括号序列不正确。请参阅下面的评论:

dynamodb_table=Table(
    "DYNAMODB_JWT_IAM",
    AttributeDefinitions=[
        AttributeDefinition([
            {
                AttributeName="deviceId",
                AttributeType="HASH"
            },
            {
                AttributeName="solutionId",
                AttributeType="S"
            }
        )] # your closing bracket sequence is incorrect; switch the order of your closing parenthesis and square bracket
        ],
        KeySchema=[
            KeySchema(
                {
                    AttributeName="solutionId",
                    KeyType="RANGE",
                },
                {
                    AttributeName="deviceId",
                    KeyType="HASH",
                }
            )
        ],
        ProvisionedThroughput=ProvisionedThroughput(
            ReadCapacityUnits = 5L,
            WriteCapacityUnits = 6L,
        ),
        TableName=DYNAMODB_JWT_IAM,
        Tags=dynamodb.Tags(dynamodb_tags)
)
self.template.add_resource(dynamodb_table)
© www.soinside.com 2019 - 2024. All rights reserved.