Deploying your existing Node.js App to AWS Elastic Beanstalk

Before we get started, it is important to note that deploying your application to Elastic Beanstalk requires that you have an AWS account and have the AWS Elastic Beanstalk Command Line Interface (CLI) installed on your system.

Introduction to AWS account

Before we get started, it is important to note that deploying your application to Elastic Beanstalk requires that you have an AWS account and have the AWS Elastic Beanstalk Command Line Interface (CLI) installed on your system.

To create an account for the AWS free tier, follow these steps:

  1. Go to the AWS website and click on the "Create an AWS Account" button.
  2. Follow the on-screen instructions to create your account. You will need to provide your email address, choose a password, and enter your payment information.
  3. After your account is created, go to the AWS Management Console and sign in with your new account.
  4. Once you are signed in, you can explore the various AWS services and choose the ones you want to use. Some services, such as Amazon EC2 and Amazon S3, are eligible for the free tier, which means you can use them for free within certain usage limits.
  5. To see which services are eligible for the free tier and what the usage limits are, go to the AWS Free Tier page. From here, you can view the available services and their usage limits, as well as any additional requirements or restrictions that apply.
  6. To start using a free tier service, simply select it from the AWS Management Console and follow the on-screen instructions to set it up.

After you setup your account, you will be able to use any of resources of AWS.

Installing AWS EB CLI

Once you have setup the AWS account, the next step is to install AWS EB CLI. I did this on my Mac, but you can install on Linux or Windows.

To install the EB CLI on a Mac, you need to have pip installed. pip is a package manager for Python that makes it easy to install and manage Python packages.

To install pip, open a terminal window and run the following command:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Once pipis installed, you can use it to install the EB CLI by running the following command:

pip install awsebcli

This will install the EB CLI and all of its dependencies. You can verify that the installation was successful by running the eb --version command, which should print the version number of the EB CLI.

Setup your IAM user

Now to start configuring your Node.js App, first you need to create an IAM user to give access for Elastic Beanstalk

To create an IAM user for Elastic Beanstalk, you need to perform the following steps:

  • Sign in to the AWS Management Console and open the IAM console.

  • In the navigation pane, choose Users, and then choose Add user.

  • Enter a user name for the IAM user.

    • Add user

  • Choose Attach existing policies directly.
  • Set permission

  • Choose Next: Review, and then choose Create user.

After completing these steps, the IAM user will be created and will have full access to Elastic Beanstalk. You can use the user's credentials to sign in to the AWS Management Console and access Elastic Beanstalk.

Configure your AWS credentials

Before we initialize with Elastic Beanstalk let’s configure AWS Credentials in our project by typing “aws configure”.

Initialize your Elastic Beanstalk environment

Once you have done with this, you will need to run the eb init command to initialize your Elastic Beanstalk environment. This command will ask you to select a few options, such as the region where you want to deploy your application and the version of Node.js you are using.

Follow these steps to configure your application to Elastic Beanstalk: First let’s start with “eb init” and then it will ask you to choose your region. Mine is eu-central-1, so I will choose 5.

Untitled

Next, you will need to choose the application you want to use or if you want to create one. I will create a new application, choose 3 and type your application name. Then it will ask you for your Node App version. Mine is Node.js 14 and I will choose 2.

Untitled

In the end, it will ask you if you want to use CodeCommit. I will choose “n” because I’m using Github.

Untitled

Next, you will need to create an Elastic Beanstalk environment to deploy your application to. This can be done using the eb create command. This command will ask you to provide a name for your environment and a few other options.

Screen Shot 2023-01-18 at 1.29.04 PM.png

After your environment has been created, it will deploy your application to Elastic Beanstalk

Once your application has been deployed, you can access it by going to the URL provided by Elastic Beanstalk. You can also manage and monitor your application using the Elastic Beanstalk management console.

In conclusion, deploying your existing Node.js application to Elastic Beanstalk is a simple process that can be accomplished using the AWS Elastic Beanstalk CLI. By following the steps outlined in this blog, you can quickly and easily deploy your application to the cloud and take advantage of the benefits offered by Elastic Beanstalk.


Euron Behrami

Head of Operations

Eager to learn new technologies everyday...


facebook icontwitter iconlinkedinwhatsapp iconmail icon