DEV Community

Cover image for Deploying Node.js Application with AWS Elastic Beanstalk: A Beginner's Guide
Reyes, Kier Christian F.
Reyes, Kier Christian F.

Posted on

Deploying Node.js Application with AWS Elastic Beanstalk: A Beginner's Guide

Why Elastic Beanstalk?

We recently spent our semester learning Node.js frameworks, and I'm curious about deploying and managing applications in the cloud. Surprisingly, recently, I got into an AWS mentorship program, and we got this activity to create technical documentation while exploring AWS service. It's overwhelming for me since there are many configuration options to consider, like monitoring, load balancers, the EC2 instances and more, and by that, I'm finding a service that can handle the infrastructure complexity for me, and that's the thing I find out on AWS Elastic Beanstalk.


What We'll Build

In this, I'll show you how to deploy a simple Node.js Todo list application using AWS Elastic Beanstalk. I'll focus on the basics to get you started.


Prerequisites

Make sure you have first:

  • An AWS account
  • Git installed to clone the sample repository

Getting Started:

You can clone my sample Node.js Todo list application from here:

git clone https://github.com/KierFR-clean/todo_nodeapp.git
Enter fullscreen mode Exit fullscreen mode

1.Create the EB Environment.

Screenshot of AWS Elastic Beanstalk console showing deployment configuration

  • Login to your AWS Console and find and select AWS Elastic Beanstalk.

  • Navigate for Elastic Beanstalk in the services search bar, and click Create Application.

2.Configure your Application.

Screenshot of AWS Elastic Beanstalk console showing deployment configuration

  • Put the desired name for the application; choose this from the platform options.

Screenshot of AWS Elastic Beanstalk console showing deployment configuration

3.Upload Application.

  • You can choose between a sample application(default) or importing a custom application.

Screenshot of AWS Elastic Beanstalk console showing deployment configuration

If importing, create a zip folder of all files from the project and exclude node_modules and others.

Screenshot of AWS Elastic Beanstalk console showing deployment configuration

On configuration presets, select Single Instance, then click Next.

4.Configure service access

  • Next, service access rights in the existing service roles will be configured. Select Use existing roles; also, don't forget to choose an EC2 instance profile. You can create and do it in the IAM console if there's none.

After that, you can Skip to Review since we can modify these settings later through the Elastic Beanstalk console.

5.Review Settings

Screenshot of AWS Elastic Beanstalk console showing deployment configuration

  • Review all the settings, click submit, and wait for the environment creation.

  • After creation, you can access the environment using the domain link.

If you encounter 404 errors, follow these steps to fix them.

  • Check the application logs.

  • Check also the static file paths.

  • Ensure all needed files is included in the zip file.

Screenshot of application

Here is the application's look: It's a simple ToDo list app using in-memory storage only, and I plan to add a proper database while I explore more with AWS Elastic Beanstalk.


Conclusion

AWS Elastic Beanstalk makes Node.js application deployment much simpler. Although I've only covered the basics, I hope this beginner's perspective helps you start your deployments. In future posts, I will improve this application with a proper database and explore more advanced production features.

This post is part of my learning journey with AWS. If you found it helpful, consider following me on my cloud development journey!🚀

Top comments (1)

Collapse
 
ehtesham_ali_abc367f36a5b profile image
Ehtesham Ali

Thanks for sharing. Its quite simple yet effective.