Search code examples
amazon-web-servicesaws-cloudformationamazon-vpc

CloudFormation Inside VPC?


I get that I can create resources using CloudFormation, and that I can also create a VPC using CloudFormation, along with the resources inside it.

Can I create a stack, using a CloudFormation template, inside a pre-existing VPC? For example, let's say that I have a VPC for my company, and there is a Services segment, some production segments (private and public), and maybe some Development segments.

I want to define each set of services - Services, production environment, Development environments - with its own CloudFormation template inside the VPC.

Can I do that?


Solution

  • Yes, you can. You can either pass the subnet id as a parameter and create resources inside those subnets or pass the vpc id as a parameter and create the subnets and resources inside it.

    For example, this template will create an RDS database inside an existing VPC: https://s3.amazonaws.com/cloudformation-templates-us-east-1/RDS_VPC.template