我有一个cloudformation模板,用于创建Table以及EventSourceMapping for Stream。我在表创建中使用条件,但是它抱怨EventSourceMapping的依赖性,因为我的EventSourceMapping依赖于表创建。我想要一些有关如何管理依赖项的建议。这是我的示例代码:
参数: 表名: 说明:DynamoDb表的名称 类型:字符串
条件: TableCreationCondition:!等于[!Ref TableName,“”]
资源:
DynamoDBTable:
#Condition: TableCreationCondition
Type: "AWS::DynamoDB::Table"
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: !Ref HashKeyElementName
AttributeType: !Ref HashKeyElementType
KeySchema:
- AttributeName: !Ref HashKeyElementName
KeyType: HASH
TableName: !Ref TableName
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
ProvisionedThroughput:
ReadCapacityUnits: !Ref ReadCapacityUnits
WriteCapacityUnits: !Ref WriteCapacityUnits
SSESpecification:
SSEEnabled: true
DynamoDBTableStream:
Type: AWS::Lambda::EventSourceMapping
Properties:
BatchSize: 1 #trigger one lambda per document
Enabled: True
EventSourceArn:
Fn::GetAtt:
- DynamoDBTable
- StreamArn
FunctionName:
Fn::GetAtt:
- MyLambdaFunction
- Arn
StartingPosition: LATEST
答案 0 :(得分:0)
您可以在DynamoDB表上设置此属性:
DependsOn: !Ref DynamoDBTableStream