gpt4 book ai didi

amazon-web-services - aws cloudformation嵌套堆栈导出/导入值

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

我正在创建一个云形成嵌套模板,用于自动化 AWS 基础设施。基本上我的父配置如下

"Resources": {
"VPCStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"Parameters": {
"ClassB": {

"Ref": "ClassB"

}
},
"TemplateURL": "https://s3.us-east-2.amazonaws.com/xxx/vpc.json",
"TimeoutInMinutes": "5"
}
},
"NatStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"Parameters": {
"ParentVPCStack": { "Ref": "AWS::StackName" },
"SubnetZone": {"Ref": "SubnetZone"}
},
"TemplateURL": "https://s3.us-east-2.amazonaws.com/xxx/nat-gateway.json",
"TimeoutInMinutes": "5"
},
"DependsOn": "VPCStack"
}
}

上面将触发嵌套 CF,我在 VPC 中导出输出,如下

"Outputs": {
"StackName": {
"Description": "Stack name.",
"Value": {
"Fn::Sub": "${AWS::StackName}"
}
},
"AZs": {
"Description": "AZs",
"Value": 2,
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-AZs"
}
}
},
"AZA": {
"Description": "AZ of A",
"Value": {
"Fn::Select": [
0,
{
"Fn::GetAZs": ""
}
]
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-AZA"
}
}
},
"AZB": {
"Description": "AZ of B",
"Value": {
"Fn::Select": [
1,
{
"Fn::GetAZs": ""
}
]
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-AZB"
}
}
},
"ClassB": {
"Description": "Class B.",
"Value": {
"Ref": "ClassB"
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-ClassB"
}
}
},
"VPC": {
"Description": "VPC.",
"Value": {
"Ref": "VPC"
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-VPC"
}
}
},
"SubnetsPublic": {
"Description": "Subnets public.",
"Value": {
"Fn::Join": [
",",
[
{
"Ref": "SubnetAPublic"
},
{
"Ref": "SubnetBPublic"
}
]
]
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-SubnetsPublic"
}
}
},
"SubnetsPrivate": {
"Description": "Subnets private.",
"Value": {
"Fn::Join": [
",",
[
{
"Ref": "SubnetAPrivate"
},
{
"Ref": "SubnetBPrivate"
}
]
]
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-SubnetsPrivate"
}
}
},
"RouteTablePrivate": {
"Description": "Route table private (deprecated in v4, will be removed in v5).",
"Value": {
"Ref": "RouteTablePrivate"
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-RouteTablePrivate"
}
}
}

然后我有 nat 网关,VPC 创建也没有问题,但是在创建 nat 网关时我收到此错误未找到名为 ${stack-name}-RouteTableAPrivate 的导出

我的主 CF 中有这些输出

"Outputs": {

"StackRef": {"Value": { "Ref" : "VPCStack"}},

"Output1FromNestedmyVPCStack" : {

"Value": { "Fn::GetAtt": [ "VPCStack", "Outputs.RouteTableAPrivate" ] }

}

}
}

如何解决这个问题

最佳答案

您导出的值在 RouteTable 和 Private 之间没有 A,而您的引用值则有 (RouteTableAPrivate)

关于amazon-web-services - aws cloudformation嵌套堆栈导出/导入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50291804/

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