浏览所有谷歌并没有找到答案......或者只是部分没有真正的例子。
这是我的Stack:
{
"Resources": {
"NestedStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://xyz/json.template",
"Parameters" : {
"Sg1" : { "Ref": "Sg1"},
"Sg2" : { "Ref": "Sg2"}
},
"DependsOn": ["Sg1","Sg2"]
},
"Sg1": {
"Type": "AWS_EC2_SecurityGroup",
.....
},
"Sg2": {
"Type": "AWS_EC2_SecurityGroup",
.....
}
}
这是我的嵌套堆栈模板:
{
"Resources": {
"flow1": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"SourceSecurityGroupId": {"Ref": "Sg1"},
"FromPort": "161",
"ToPort": "161",
"GroupId": {"Ref": "Sg2"},
"IpProtocol": "tcp"
}
}
}
通过CloudFormation部署整个堆栈时,所有内容都已正确创建,直到嵌套堆栈为止,然后我只是收到此消息:
Template format error: Unresolved resource dependencies [Sg1,Sg2] in the Resources block of the template
请帮助,完整的例子,以避免我在谷歌上发现的类似案件,答案是建议解决方案,但不清楚,接下来的20人不得不再次问同样的问题:在哪里和什么?
非常感谢你,整个下午我已经花了这么多时间......
麦克
答案 0 :(得分:1)
您可能需要在嵌套模板中添加参数部分,例如
{
"Parameters" : {
"Sg1" : {
"Type" : "AWS::EC2::SecurityGroup",
"Description" : "cool beans"
},
"Sg2" : {
"Type" : "AWS::EC2::SecurityGroup",
"Description" : "whatever"
}
},
"Resources": {
"flow1": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"SourceSecurityGroupId": {"Ref": "Sg1"},
"FromPort": "161",
"ToPort": "161",
"GroupId": {"Ref": "Sg2"},
"IpProtocol": "tcp"
}
}
}
}