我有以下代码我正在尝试创建一个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)
您能否更具体地说明为什么不能以编程方式更正缩进?
我手动整理了你的缩进,发现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)