gpt4 book ai didi

amazon-web-services - 从另一个模板导入 VPCGatewayAttachment

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

我有一个包含 InternetGateway 的网络堆栈,它通过 VPCGatewayAttachment 元素连接到 VPC。

我有一个应用程序堆栈,其中有一个 EIP,它应该取决于 VPCGatewayAttachment,当前如下所示:

"MyEIP": {
"Type": "AWS::EC2::EIP",
"DependsOn": [
{ "Fn::ImportValue" : {"Fn::Sub": "${NetworkStackName}-GatewayAttachment" } }
],
}

但是我收到一个模板错误,指出每个 DependsOn 值都必须是字符串。那么如何导入这个值呢?

最佳答案

您不需要使用DependsOn AWS::EC2::EIP 上的属性应用程序堆栈中的资源,因为 AWS::EC2::VPCGatewayAttachment正在单独的网络堆栈中创建资源。 EIP 资源的 Domain 中对此进行了说明。属性:

Note

If you define an Elastic IP address and associate it with a VPC that is defined in the same template, you must declare a dependency on the VPC-gateway attachment by using the DependsOn attribute on this resource.

当 VPC 在单独的模板中定义时,您无需显式声明任何依赖项。只要应用程序堆栈在网络堆栈之前被删除,EIP 就会在 VPC 网关附加之前被删除。

更一般地说,在堆栈之间声明 DependsOn 是没有必要的。由于如果另一个堆栈引用其输出之一,则无法删除该堆栈,因此使用 Fn::ImportValue 创建跨堆栈引用会创建一个依赖项,即必须先删除包含该引用的堆栈,然后再执行该操作。正在引用堆栈。

关于amazon-web-services - 从另一个模板导入 VPCGatewayAttachment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40985206/

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