【发布时间】:2021-07-19 17:23:03
【问题描述】:
有没有办法在 CloudFormation 模板中检查未定义的资源属性(由 Fn::GetAtt 返回)?
我想使用 Fn::GetAtt 将指定资源的属性包含在堆栈的输出中,前提是这些属性已定义。
例如,使用以下模板创建堆栈会给我一个错误:
“属性:找不到资源的 StreamArn:MyTestStack-DDBTable-1C0T2MJZA1J0I。用户请求回滚。”
因为该特定表的资源属性中不包含流规范。
当然,解决这个问题的简单方法就是从堆栈输出列表中删除 StreamArn。但是,我仍然想知道如何检查该属性是否是为指定资源定义的。
任何建议都将受到高度赞赏。
- 拍拍
{
"Resources":{
"DDBTable":{
"Type":"AWS::DynamoDB::Table",
"Properties":{
"AttributeDefinitions":[
{
"AttributeName":"ArtistId",
"AttributeType":"S"
},
{
"AttributeName":"Concert",
"AttributeType":"S"
},
{
"AttributeName":"TicketSales",
"AttributeType":"S"
}
],
"GlobalSecondaryIndexes":[
{
"IndexName":"GSI",
"KeySchema":[
{
"AttributeName":"TicketSales",
"KeyType":"HASH"
}
],
"Projection":{
"ProjectionType":"KEYS_ONLY"
},
"ProvisionedThroughput":{
"ReadCapacityUnits":5,
"WriteCapacityUnits":5
}
}
],
"KeySchema":[
{
"AttributeName":"ArtistId",
"KeyType":"HASH"
},
{
"AttributeName":"Concert",
"KeyType":"RANGE"
}
],
"ProvisionedThroughput":{
"ReadCapacityUnits":5,
"WriteCapacityUnits":5
}
}
}
},
"Outputs":{
"DDBTablePhysicalID":{
"Value":{
"Ref":"DDBTable"
}
},
"DDBTableArn":{
"Value":{
"Fn::GetAtt":[
"DDBTable",
"Arn"
]
}
},
"DDBTableStreamArn":{
"Value":{
"Fn::GetAtt":[
"DDBTable",
"StreamArn"
]
}
}
}
}
【问题讨论】:
标签: amazon-web-services amazon-cloudformation