This repo contains an examples of both a Cloudformation template and a Terraform configuration to build a VPC with 2x Public Subnets & 2x Private Subnets
An Internet Gateway is launched and is attached to the VPC so that outbound & inbound internet traffic permits
Resources launched inside the private Subnets (e.g. EC2 instances) would not be able to talk to the internet by default but can do so by way of contacting a NAT Gateway which is resided in the corresponding Public Subnet.
via the AWS CLI:
aws cloudformation create-stack --stack-name [your-stack-name] --template-body public-private-vpc.yml
where [your-stack-name]
is your chosen name for your Cloudformation stack
terraform init
terraform plan
terraform apply