amazon-web-services - 在 AWS cloudformation 模板中使用条件时如何管理资源依赖关系?
问题描述
我有一个 cloudformation 模板,它为 Stream 创建表以及 EventSourceMapping。我在表创建中使用条件,但它抱怨 EventSourceMapping 的依赖关系,因为我的 EventSourceMapping 依赖于表创建。我想要一些关于如何管理依赖的建议。这是我的示例代码:
参数:TableName: 描述:DynamoDb 表的名称类型:String
条件:TableCreationCondition: !Equals [ !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
解决方案
您可以在 DynamoDB 表上设置此属性:
DependsOn: !Ref DynamoDBTableStream
推荐阅读
- wordpress - wp.data.select('core').getPostType('post-type') 在 Gutenberg 中返回 undefined
- c# - 如何创建转换器以便 JsonConvert.DeserializeObject 将转换 List
属性只是字符串属性 - string - 如何在 Go 中的多行字符串中添加反引号?
- artifactory - 当 jfrog-cli 在下载时跳过已经存在的文件或工件时,如何以编程方式知道?
- python - 如何从 Excel 工作表中删除无效字符?
- laravel - 如何在我的项目上设置惯性,当我尝试加载登录页面时出现错误
- c# - 我无法从 NHibernate 的列表中删除项目
- html - 无法在 div 中设置图像
- asp.net-core - ASP.NET Core 中的静态文件在本地工作,但一次不会发布到 Azure
- c# - 基元、泛型和重载——接口方法返回类型是否可以定义为一组结构和基元?