gpt4 book ai didi

json - 亚马逊上嵌套堆栈中的参数

转载 作者:行者123 更新时间:2023-12-03 07:37:47 27 4
gpt4 key购买 nike

浏览了所有谷歌并没有找到答案......或者只是部分没有真正的例子。

这是我的堆栈:

{
"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

请帮忙提供完整的示例,以避免出现我在 Google 上发现的类似情况,其中答案是建议解决方案,但不清楚,以至于接下来的 20 个人不得不再次问同样的问题:在哪里以及什么?

非常感谢,我已经花了整个下午了......

迈克

最佳答案

您可能需要向嵌套模板添加参数部分,例如

{
"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"
}
}
}
}

关于json - 亚马逊上嵌套堆栈中的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38338549/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com