How to deploy your node.js web application with AWS Beanstalk?

This post will show you how we can quickly create a node.js web aplication based on express framework and how to deploy that application on AWS using AWS BeanStalk service.

Now first you need to know what is AWS BeanStalk?

Some information about AWS BeanStalk:

  • AWS BeanStalk is the fastest and simplest way to deploy your application on AWS.
  • Under the covers, it is simply running your code on EC2 instances.
  • It automatically scales your application up and down.
  • Basically here you can select your EC2 instance type that is optimal for your application.
  • It can deploy apps built over popular frameworks like Java, node.js, PHP etc. and servers like Apache Tomcat, IIS, Passenger etc.

So let us get started!

Step 1: Creating an web application in node.js – express framework.

To create a express application skeleton we need to install express generator from npm:

m1

Check available option while creating an express app:

m2

After installing the express generator, we will create an express sample application:

m3

Now go to the application folder and install dependencies:

m4

On Mac OS or Linux, run the app with this command

m5

On Windows, use this command:

m6

The generated app has the following directory structure:

m7

Then load http://localhost:3000/ in your browser to access the app.

1

I added some text and picture and a button to make it like a web app.

2.PNG

OK, now our express app is created and running on localhost.

Let us go to our AWS Management Console and see how to deploy this app on AWS BeanStalk.

Step 1) Go Service and Click on AWS BeanStalk under Compute.

As shown below:

 

3
Click on AWS BeanStalk

Step 2) Now click on Get Started button, as shown below:

4

Step 3) Fill the details as shown below:

5 (2)

5 (1)

Click on upload button to upload you code in a zip file.

6.PNG

 

Click on upload.

Then click on Create Application button

7.PNG

This will upload your codebase in S3 bucket and deploy your application.

This takes around 5-10 mins.

8.PNG

Once your app is deployed you will see the dashboard showing Health, status, EC2 instance name, Machine name etc details.

9.PNG

Click on URL present on the dashboard and you can see your app running.

10.png

So that is end of this post..

Hope you all learned and enjoyed this one.

Post you queries in the comments section below.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s