0

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

如果属性和键模式语法的数组很好,有人可以帮忙。我可以改变什么来纠正这个缩进问题。

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

> 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)
4

1 回答 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)
于 2019-02-25T15:15:05.613 回答