Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: Setup your VPC
--
I walk through step by step how to get a Node.JS MEAN.JS that uses Grunt and Bower working on Amazon Web Services ElasticBeanstalk. In this section we’ll configure our AWS credentials and ElasticBeanstalk service role.
Go to parent article — Build a robust MEAN website in under an hour for less than $1/day
Go to previous article — Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: IAM Configuration
If you’ve already setup your basic VPC with two subnets then go to the next article — Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: Add a public internet gateway
Setup a VPC with two subnets
Before we can use ElasticBeanstalk to deploy our application, we need to setup a Virtual Private Cloud (VPC) on AWS.
Why a VPC? This does two things.
- It insures that your web server and your database server are in the same availability zone for reduced latency.
- It allows you to remove your database servers from direct internet access.
This is how we set up our VPC.
Go to the AWS console (my region is us-east-1 https://console.aws.amazon.com/console/home?region=us-east-1)
Click “Create VPC”. For mine I’ve entered “ebnodetest” for the name and my CIDR block (pronounced like cider) is 10.0.0.0/16.
This means that any subnets I create for my VPC have to start with “10.0.” Each number is equal to 8 bits.
Now on the left menu, click “Subnets”.
We want to create two subnets, one public and one private. We’ll later configure ElasticBeanstalk to put our web servers on the public subnet, while we’ll launch our database server instance on the private subnet in order to protect it from the internet. This also allows us to easily keep the database and web servers in the same availability zone for lower latency.
Click “Create Subnet”. For the (10.0.0.5/24)
This is where we’ll deploy ElasticBeanstalk web servers.
Now click “Create Subnet” again and create a subnet for your private subnet. (10.0.0.6/24)
This is where we’ll deploy the MongoDB server so that it cannot be accessed from the internet.
Now let’s connect the public subnet to the internet.
Go to parent article — Build a robust MEAN website in under an hour for less than $1/day
Go to previous article — Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: IAM Configuration
Go to the next article — Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: Add a public internet gateway