如何避免 cloudformation 模板之间的循环引用?
例如我的 Web 服务器有一个模板,数据库实例有另一个模板。模板数据库将类似于:
"Database": {
"Type":"AWS::RDS::DBInstance",
"Properties": {
// lots of other props
"VPCSecurityGroups": [ {"Ref":"DBSecurityGroup"} ]
}
},
"DBSecurityGroup" : {
"Type":"AWS::RDS::DBSecurityGroup",
"Properties": {
// lots of other props
"SecurityGroupIngress": [{... "SourceSecurityGroupId":{"Ref":"WebSecurityGroup"}}]
}
}
但是在我的 Web 服务器模板中,我需要引用 DBSecurityGroup:
"WebServer": {
"Type":"AWS::EC2::Instance",
"Properties": {
// lots of other props
"SecurityGroups": [ {"Ref":"DBSecurityGroup"} ]
}
},
"WebSecurityGroup" : {
"Type":"AWS::EC2::SecurityGroup",
"Properties": {
// lots of other props
"SecurityGroupEgress": [{... "SourceSecurityGroupId":{"Ref":"DBSecurityGroup"}}]
}
}
如何避免模板之间的这些循环引用?
最佳答案
使用单独的 AWS::EC2::SecurityGroupEgress
资源,而不是 SecurityGroupEgress 属性。
关于amazon-web-services - 如何避免cloudformation与安全组的循环引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24853034/