Steve
Steve

Reputation: 195

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.

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.

Does anyone know how to do this without having to pass it as a parameter?

Upvotes: 0

Views: 386

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270039

There is no native capability for CloudFormation templates to "get" values of existing infrastructure that it didn't create itself.

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. 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. It takes a bit of work to get your first Custom Resource going because the 'call-back' process is a little complicated.

Upvotes: 0

Related Questions