【发布时间】:2021-07-03 08:36:48
【问题描述】:
cloudformation中的字符串、列表和字符串列表有什么区别?
当我使用 if 条件在 dynamodb 中提供 NonKeyAttributes 时。 当我尝试使用 if 条件提供新条件 z 时,我得到属性 NonKeyAttributes 的值必须是字符串列表类型。 还有没有更好的方法来做到这一点,而不是太多的 if 条件
条件: x: ! 或 [ !Equals [ !Ref env, "prod" ], !Equals [ !Ref env, "acpt" ] ] y: ! 或 [ !Equals [ !Ref env, "infrastructure" ], !Equals [ !Ref env, "cont" ] ] z: ! 或 [ !Equals [ !Ref env, "dev" ], !Equals [ !Ref env, "test" ], [ !Ref env, "prod" ], !Equals [ !Ref env, "cont" ] ]
Type: "AWS::DynamoDB::Table"
Properties:
TableName: Employer
AttributeDefinitions:
- AttributeName: "empID"
AttributeType: "S"
- AttributeName: "TeamID"
AttributeType: "S"
- AttributeName: "Date"
AttributeType: "N"
KeySchema:
- AttributeName: "empID"
KeyType: "HASH"
ProvisionedThroughput:
ReadCapacityUnits: 20
WriteCapacityUnits: 20
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
GlobalSecondaryIndexes:
- IndexName: "ByTeamID"
KeySchema:
- AttributeName: "TeamID"
KeyType: "HASH"
- AttributeName: "Date"
KeyType: "RANGE"
Projection:
NonKeyAttributes:
- "A"
- "B"
- "C"
- "D"
- !If [x, "x1", !Ref "AWS::NoValue"]
- !If [y, "y1", !Ref "AWS::NoValue" ]
- !If
- z
- - "z1"
- - "z2"
- - "z3"
- - "z4"
- !Ref AWS::NoValue
【问题讨论】:
-
您是在尝试仅在某些情况下投影属性,还是仅在某些情况下才存在属性?换句话说,您是说仅在某些条件为真时才项目 X,还是仅在某些条件为真时才存在 X,因此您不想包含它?
-
如果 x 条件为真,那么它将提供 x1 值。当条件满足时,如果它具有单一值,我就可以做到。但是对于 z 条件,我的值不止 z1, z2, z3
标签: amazon-dynamodb amazon-cloudformation