简体   繁体   English

AWS-在现有VPC中创建公共子网

[英]AWS - Create public subnet in existing VPC

I have a VPC with a internet gateway already attached and I'm trying to create a cloudformation that adds new public and private subnets to the VPC. 我有一个已经连接了Internet网关的VPC,我正在尝试创建一个cloudformation,将新的公共和私有子网添加到VPC。

The problem I'm having is that I don't know how to get the gateway id of the IG to update the route table of the public subnet. 我遇到的问题是,我不知道如何获取IG的网关ID以更新公共子网的路由表。

Does anyone know how to do this without having to pass it as a parameter? 有谁知道如何做到这一点而不必将其作为参数传递?

There is no native capability for CloudFormation templates to "get" values of existing infrastructure that it didn't create itself. CloudFormation模板没有本机功能来“获取”它自己没有创建的现有基础架构的值。

If the VPC was create by a CloudFormation stack and the stack has the VPC in its Exports, then another template can use the Exports as input parameters . 如果VPC是由CloudFormation堆栈创建的,并且该堆栈在其Exports中具有VPC,则另一个模板可以将Exports用作输入参数 However, this doesn't sound appropriate for your use-case. 但是,这听起来不适合您的用例。

The only other option is to write a Custom Resource using Lambda that queries the API and returns the value to the stack. 唯一的其他选择是使用Lambda编写自定义资源 ,该资源查询API并将值返回到堆栈。 It takes a bit of work to get your first Custom Resource going because the 'call-back' process is a little complicated. 要开始使用您的第一个自定义资源,需要花费一些工作,因为“回叫”过程有点复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM