Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: Setup your VPC

Joseph Nielsen
3 min readSep 26, 2016

--

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.

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.

  1. It insures that your web server and your database server are in the same availability zone for reduced latency.
  2. 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)

Go to the VPC (Virtual Private Cloud) services dashboard

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.

create a new VPC, I used a CIDR block of 10.0.0.0/16

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 the public subnet we’ll use for your Node web servers

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 the private subnet where we’ll put our database server

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.

--

--

Joseph Nielsen

I lead the software engineering and DevOps practice for Slalom, New Jersey. I enjoy building things, endurance running and all things DeepRacer.