1

I'm setting up my first VPC with AWS VPC wizard and i'm having some troubles understand what type of instances should I put in a public subnet, and what type of instances in a private subnet.

It does make sense to me to put all the RDS instances in private, but assuming I have an EC2 instance (holding WordPress site for example), should I put it in a private subnet? or maybe it should be private, have a load balancer in front of it in the public subnet, and incase it needs S3 content he should call the NAT?

What's the best practices, or decisions making pros and cons for deciding this ?

Asaf Nevo
  • 175
  • 1
  • 10
  • http://serverfault.com/questions/658291/vpc-public-subnet-internet-access-with-elb-hooked-up/658362#658362 addresses this, as does the ever-popular [Why do we need private subnet in VPC?](http://stackoverflow.com/a/22212017/1695906) (which, arguably, should have been asked here, rather than SO). – Michael - sqlbot Jun 03 '15 at 22:39

1 Answers1

3

From the Amazon VPC documentation:

The instances in the public subnet can receive inbound traffic directly from the Internet, whereas the instances in the private subnet can't. The instances in the public subnet can send outbound traffic directly to the Internet, whereas the instances in the private subnet can't. Instead, the instances in the private subnet can access the Internet by using a network address translation (NAT) instance that you launch into the public subnet.

Based on the above, you will need to create both private and public subnets - I would typically create one private and one public per Availability Zone.

You'll also need to create and configure a NAT instance and assign this as an internet gateway for your VPC.

Your ELB instances will need to be connected to your public subnets, and should be able to balance connections to instances in private subnets.

Your EC2 instances (in your example, WordPress) will be launched in one of your private subnets. Note that should should ideally have more than one instance in each AZ that your ELBs are configured for.

If you only plan to have one server on the ELB, or launch all of your EC2 instances within the same AZ, you will only need to configure your ELB for the public subnet within that AZ.

Craig Watson
  • 9,370
  • 3
  • 30
  • 46