[英]Lookup IGW after specifying VPC parameter in CloudFormation template
在下面的代码片段中,我可以根据 VpcId 参数使用 function(或其他东西)而不需要它作为参数来查找 IGW 吗?
Parameters:
VpcId:
Type: AWS::EC2::VPC::Id
Description: Enter the Existing Landing Zone VPC ID.
InternetGateway:
Type: String
Description: Enter the Existing Landing Zone IGW.
Resources:
DefaultRoute:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
RouteTableId: !Ref RouteTable
谢谢。
我没有尝试任何东西,因为我找不到任何让我认为这可行的东西,只是不确定我是否遗漏了什么。
不,这在 CloudFormation 中是不可能的。
以这种方式动态查找资源的唯一方法是,如果您利用 CloudFormation 宏来调用执行自定义代码的 lambda function。 例如,在 Python 中,您可以使用 boto3 describe_inte.net_gateways API 返回一个 inte.net 网关列表(您可以对 VPC ID 使用过滤器)。
有关 CloudFormation 宏的更多信息: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-macros.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.