Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: Add a public internet gateway to 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 VPC’s public subnet Internet Gateway.

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: Setup your VPC

If you’ve already added your internet gateway then go to the next article— Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: Add a NAT gateway for your private subnet

Expose your public subnet using an Internet Gateway

In order for your “public” subnet to be public, you’ll need to create an Internet Gateway. Click on the left hand menu for “Internet Gateways”. Then click “Create Internet Gateway”. I named mine ebnodeigw.

Under Internet Gateways, Click Create Internet Gateway and name it ebnodeigw

Once the Internet Gateway is created, we’ll need to attach it to our VPC in order to enable communication. Check your new internet gateway and click “Attach to VPC”

Select your VPC, identiable by the CIDR block you assigned. Click Yes Attach

Now we need to create a new route that will tell our public subnet to send all external traffic through the Internet Gateway. Click on the “Routes” menu on the left and then click “Create Route Table”. I called my route table ebnodeinternet. This is so I know that this is the route table that gives internet access, for security best practices, I’m going to leave my default route table alone. I don’t want my default route assignment to give internet access.

Under Routes, Click Create Route Table. Name it ebnodeinternet

Select the new route table you’ve created and then on the bottom panel select the “Routes” tab.

Click “Add another route”. The destination will be 0.0.0.0/0. For the target you’ll select your new Internet Gateway from the autocomplete dropdown that appears. (Most likely starts with “igw”). Then click Save.

Create a default route, 0.0.0.0/0 and assign the target to your internet gateway

Now click on the “Subnet Associations” tab.

Edit the subnet it is associated with

Click Edit and then select the subnet we created for the public subnet earlier. For me this was 10.0.5.0/24. After you’ve selected that subnet, click Save.

attach the public subnet to the internet gateway connected route table you created

Your public subnet is now “public”. When ElasticBeanstalk creates machines on this subnet, you will be able to access them from the internet.

Go to parent articleBuild a robust MEAN website in under an hour for less than $1/day

Go to previous articleSetting up your MEAN (Node.js) website in AWS ElasticBeanstalk: Setup your VPC

Go to next article — Setting up your MEAN (Node.js) website in AWS ElasticBeanstalk: Add a NAT gateway for your private subnet

--

--

Joseph Nielsen

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