【发布时间】:2015-01-03 01:33:28
【问题描述】:
我正在构建一个 Cloud Formation JSON 来定义 EC2 实例和安全组。
我需要创建一个安全组,允许属于其中的每个实例在彼此之间共享任何数据。
我的 JSON 是这样的:
"InternalSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"VpcId" : {"Ref" : "myVPC"},
"GroupDescription" : "Allow the machines in this group to share all kinds of traffic between each other",
"SecurityGroupIngress" : [
{
"IpProtocol" : "-1",
"FromPort": "-1",
"ToPort": "-1",
"SourceSecurityGroupId" : { "Ref" : "InternalSecurityGroup" }
}
],
"SecurityGroupEgress" : [
{
"IpProtocol" : "-1",
"FromPort": "-1",
"ToPort": "-1",
"DestinationSecurityGroupId" : { "Ref" : "InternalSecurityGroup" }
}
]
}
},
但这显示了以下错误:
调用 CreateStack 时发生客户端错误(ValidationError) 操作:资源之间的循环依赖
为了解决这个问题,我将代码更改为 CidrIp 而不是 SourceSecurityGroupId,定义了实例所在的子网。
是否可以引用同一个安全组?实现我想要的最好(或正确)方法是什么?
【问题讨论】:
标签: json amazon-web-services amazon-ec2 amazon-cloudformation