[英]parameters in nested stacks on amazon
browsed all google through and did not find an answer... Or just partial with no real example. 浏览了所有的google并没有找到答案...或者只是部分而没有真实的例子。
Here is my 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",
.....
}
}
Here is my nested stack template: 这是我的嵌套堆栈模板:
{
"Resources": {
"flow1": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"SourceSecurityGroupId": {"Ref": "Sg1"},
"FromPort": "161",
"ToPort": "161",
"GroupId": {"Ref": "Sg2"},
"IpProtocol": "tcp"
}
}
}
When deploying the whole stack via CloudFormation, everything is properly created until it comes to the nested stack and then I simply get this message: 通过CloudFormation部署整个堆栈时,所有内容都会正确创建,直到涉及嵌套堆栈为止,然后我简单地得到以下消息:
Template format error: Unresolved resource dependencies [Sg1,Sg2] in the Resources block of the template
Please help, with the full example to avoid the similar cases I found on google where the answer was suggesting a solution but so unclear that next 20 people had to ask the same again: where and what? 请提供完整的示例,以帮助避免我在google上发现的类似情况,答案在此提出了解决方案,但不清楚,接下来的20个人不得不再次问相同的问题:在哪里和什么?
Thank you soo much, I spent on this the whole afternoon already... 非常感谢您,我已经整个下午都在这里度过了...
Mike 麦克风
You might need to add a parameters section to the nested template, eg 您可能需要在嵌套模板中添加一个参数部分,例如
{
"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"
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.