{"id":10024,"date":"2020-10-02T07:57:43","date_gmt":"2020-10-02T02:27:43","guid":{"rendered":"https:\/\/www.arkasoftwares.com\/blog\/?p=10024"},"modified":"2023-01-03T06:14:01","modified_gmt":"2023-01-03T06:14:01","slug":"how-to-deploying-node-js-applications-to-aws-elastic-beanstalk","status":"publish","type":"post","link":"https:\/\/www.arkasoftwares.com\/blog\/how-to-deploying-node-js-applications-to-aws-elastic-beanstalk\/","title":{"rendered":"How To Deploying Node.js Applications to AWS Elastic Beanstalk?"},"content":{"rendered":"<p><span style=\"color: #000000;\">Cloud computing has revolutionized the IT World. It is an innovative platform and It has established itself as the backbone of the technology for the future. It allows organizations to implement and launch applications in such a way, which is next to impossible with that traditional infrastructure.<\/span><\/p>\n<p><span style=\"color: #000000;\">Cloud Computing has reshaped the entire Application development process. With the emergence of several cloud service providers like Microsoft Azure, Google Cloud, or <span style=\"color: #0874b9;\"><a href=\"https:\/\/www.arkasoftwares.com\/blog\/which-cloud-platform-is-best-aws-azure-or-google-cloud\/\" target=\"_blank\" rel=\"noopener\"><strong style=\"font-weight: 600;\">Amazon Web Services<\/strong><\/a>,<\/span> which offer a variety of development tools and services, which make the application development process more robust and secure.<\/span><\/p>\n<p><span style=\"color: #000000;\"> But choosing Which one is better AWS or Azure or Google cloud? is the real question! AWS Elastic Beanstalk is a development tool launched by Amazon, and it has been implemented based on the PaaS model.<\/span><\/p>\n<p><span style=\"color: #000000;\"><a href=\"https:\/\/www.arkasoftwares.com\/cloud-computing\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #0874b9;\"><strong style=\"font-weight: 600;\">Cloud Computing<\/strong><\/span><\/a> has been able to deliver such a success an exceptional success with its PaaS service. Amazon has its PaaS service, which is famously known as AWS Elastic Beanstalk. <\/span><\/p>\n<p><span style=\"color: #000000;\">AWS Elastic Beanstalk is a service that helps us in the deployment and scaling of web applications and services developed\u00a0with .NET, Java, Node.js, PHP, Go, <a href=\"https:\/\/www.arkasoftwares.com\/services\/web-development\/python\" target=\"_blank\" rel=\"noopener\">Python development<\/a>, Docker, and Ruby on renowned servers like IIS, Nginx, Apache, and Passenger.<\/span><\/p>\n\n<div class=\"custom_vedio\"><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/SrwxAScdyT0\" width=\"100%\" height=\"500\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n\n<p><span style=\"color: #000000;\">AWS Elastic Beanstalk facilitates rapid deployment and management of applications in the AWS cloud without worrying about the underlying infrastructure which supports those applications and their related services. <\/span><\/p>\n<p><span style=\"color: #000000;\">Elastic Beanstalk takes care of all the details of the Application\u2019s versions, load balancing, application scaling, capacity provisioning, and its health monitoring. It offers flexibility to the developer to deploy an application without provisioning the infrastructure while maintaining the high availability of application services.<\/span><\/p>\n\n<h2><span class=\"ez-toc-section\" id=\"Benefits_of_AWS_Elastic_Beanstalk\"><\/span><span style=\"color: #000000;\">Benefits of AWS Elastic Beanstalk<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"color: #000000;\">Here are some important benefits that AWS Elastic Beanstalk offers over other PaaS services in the market.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Multi-Tenant Architecture: <\/span><\/h3>\n<p><span style=\"color: #000000;\">It allows users to share their applications across different sets of Devices and Architecture with high security and scalability. It also offers a thorough report of User profiles and application usage. <\/span><\/p>\n<h3><span style=\"color: #000000;\">Rapid Deployment:<\/span><\/h3>\n<p><span style=\"color: #000000;\">It offers an ability to the developers to deploy their applications in the most rapid and rapid way possible. It is possible for developers to deploy and launch their applications within a few minutes straight. This gives them a big upper hand as they do not have to worry about the resource configuration and underlying infrastructure.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Provides absolute Resource Control : <\/span><\/h3>\n<p><span style=\"color: #000000;\">Beanstalk provides developers the freedom to choose the AWS resources, that are optimal for their application. It gives developers an absolute control over all the AWS resources and access them whenever it is required.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Transparent and Simplified Operations: <\/span><\/h3>\n<p><span style=\"color: #000000;\">It operates and provisions the computing infrastructure and at the same time, it manages the application stack. It makes the process too transparent and simplified, those application developers have to just focus on writing the code for their application, and they don\u2019t have to spend time configuring and managing the servers, networks, databases, and firewalls.<\/span><\/p>\n<p><span style=\"color: #000000;\">In this article, we would be explaining the process of setting up continuous deployment for a <a href=\"https:\/\/www.arkasoftwares.com\/services\/web-development\/nodejs\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #0874b9;\"><strong style=\"font-weight: 600;\"> Node.js application<\/strong><\/span><\/a> on Elastic Beanstalk. We will be initializing an environment on the Elastic Beanstalk console and make some configuration changes on our Node.js application. We will cover the deployment process as well.<\/span><\/p>\n\n<h4><span style=\"color: #000000;\"><img data-dominant-color=\"eae7e6\" data-has-transparency=\"false\" style=\"--dominant-color: #eae7e6;\" decoding=\"async\" loading=\"lazy\" class=\"not-transparent size-full wp-image-10047 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/arch-diagram_nodejs-app-new.jpg\" alt=\"Deploying Node.js Applications to AWS Elastic Beanstalk\" width=\"1220\" height=\"788\" \/><\/span><\/h4>\n<h4><\/h4>\n<h2><span class=\"ez-toc-section\" id=\"What_is_Nodejs\"><\/span><span style=\"color: #000000;\">What is Node.js?<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"color: #000000;\">Node.js- It is getting more popularity in recent times due to the availability of a huge number of plugins it supports and its unbelievably better spin-up times than Java or C#. Which makes it the best bet for developing client-facing applications. <\/span><\/p>\n<p><span style=\"color: #000000;\">It enjoys enormous support from its dedicated community of developers and contributors, which makes it easy to discuss the problems and finding their solutions.<\/span><\/p>\n<h3><span style=\"color: #000000;\">What is Elastic Beanstalk CLI<\/span><\/h3>\n<p><span style=\"color: #000000;\">It is a command-line tool, which helps us managing AWS Elastic Beanstalk environments. We can also use <strong style=\"font-weight: 600;\">EB CLI<\/strong> to monitor our environment\u2019s status and health parameters in real-time. <\/span><\/p>\n<p><span style=\"color: #000000;\">Once we install and configure the EB CLI, we can launch a new environment and proceed with the deployment of our code via the EB create command. If we already created an environment in place in EB console, then we can attach the EB CLI to it, by running eb init in a project folder.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Deploying Node.js Applications to Elastic Beanstalk<\/span><\/h3>\n<p><span style=\"color: #000000;\">It is extremely easy to deploy, manage and scale a Node.js application on AWS Elastic Beanstalk using the Amazon web services. Elastic Beanstalk for Node.js is used for hosting or <span style=\"color: #0874b9;\"><a style=\"color: #0874b9;\" href=\"https:\/\/www.arkasoftwares.com\/services\/web-development\/nodejs\" target=\"_blank\" rel=\"noopener\"><strong>developing a web application using Node.js<\/strong><\/a><\/span>. <\/span><\/p>\n<p><span style=\"color: #000000;\">Past deployment of our EB app, we can use EB Command Line Interface to manage our app and environment, or you can use the Elastic Beanstalk console, APIs, or AWS Command-line interfaces.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Roadmap of our Deployment<\/span><\/h3>\n<p><span style=\"color: #000000;\">Our deployment roadmap will have the following basic steps.<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">We will be creating an IAM user to handle deployments.<\/span><\/li>\n<li><span style=\"color: #000000;\">We will create an EB app and set up an environment.<\/span><\/li>\n<li><span style=\"color: #000000;\">We will deploy our Node.js app to the EB application using a command-line interface.<\/span><\/li>\n<\/ul>\n<h3><span style=\"color: #000000;\">Pre-requisites for a successful deployment<\/span><\/h3>\n<ul>\n<li><span style=\"color: #000000;\">Basic knowledge of command-line interface.<\/span><\/li>\n<li><span style=\"color: #000000;\">An active AWS account<\/span><\/li>\n<li><span style=\"color: #000000;\">The Elastic Beanstalk Command Line Interface (EB CLI)<\/span><\/li>\n<li><span style=\"color: #000000;\">Basic knowledge of Git<\/span><\/li>\n<\/ul>\n\n<h4 style=\"text-align: center;\">Read: <a href=\"https:\/\/www.arkasoftwares.com\/blog\/dotnet-vs-java-best-for-software-development\/\" target=\"_blank\" rel=\"noopener\">.Net vs Java &#8211; Best Technology for Software Development?<\/a><\/h4>\n\n<div class=\"row clearfix content-line\"><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Step_by_the_Step_Deployment_Process\"><\/span><span style=\"color: #000000;\">Step by the Step Deployment Process<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span style=\"color: #000000;\">Step -1 &#8211; Setting up an AWS Account<\/span><\/h3>\n<p><span style=\"color: #000000;\">The first and foremost thing is to set up an AWS account. If you do not have one, then please register yourself at the AWS portal. If you already have an AWS account, then please make sure you have an IAM user that has API keys and an adequate level of access.<\/span><br \/>\n<span style=\"color: #000000;\">It is a pretty straightforward process to create an account. The AWS account signup process should walk you through everything smoothly. When you first set up an AWS account, you will get root access. <\/span><span style=\"color: #000000;\">However, it is considered as a security best practice to create a different user that you will use to login on regular basis.<\/span><\/p>\n<p><span style=\"color: #000000;\">It is always a good practice to have control over the roles and responsibilities within the AWS account. Whenever you start a new project, please create a new IAM user with specific permissions, which is aligned to the specific project needs.<\/span><\/p>\n\n<p><img data-dominant-color=\"e4e4e6\" data-has-transparency=\"false\" style=\"--dominant-color: #e4e4e6;\" decoding=\"async\" loading=\"lazy\" class=\"not-transparent size-full wp-image-10032 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/new-image.png\" alt=\"AWS setting\" width=\"595\" height=\"443\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125552\/new-image.png 595w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125552\/new-image-300x223.png 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/p>\n\n<p><span style=\"color: #000000;\">Let us get this started. Please head over to your AWS console and open the IAM console. Select the Users option on the left side menu.\u00a0<\/span><span style=\"color: #000000;\">Here, hit that blue \u201cAdd user\u201d button to create a new user account. We should create a new eb-deploy-user user, that will be having programmatic access through the Command-line interface (CLI). So please tick that checkbox.<\/span><\/p>\n\n<h5><span style=\"color: #000000;\"><img data-dominant-color=\"ebeced\" data-has-transparency=\"false\" style=\"--dominant-color: #ebeced;\" decoding=\"async\" loading=\"lazy\" class=\"not-transparent size-full wp-image-10031 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/AWS-services.png\" alt=\"\" width=\"1183\" height=\"572\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125551\/AWS-services.png 1183w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125551\/AWS-services-300x145.png 300w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125551\/AWS-services-1024x495.png 1024w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125551\/AWS-services-768x371.png 768w\" sizes=\"(max-width: 1183px) 100vw, 1183px\" \/><\/span><\/h5>\n<h5><\/h5>\n<h3><span style=\"color: #000000;\">Step -2 Creation of Group <\/span><\/h3>\n<p><span style=\"color: #000000;\">The next step about defining the permissions for the newly added User. Here the thumb rule is, you should always follow a restrictive approach while delegating the permissions. <\/span><\/p>\n<p><span style=\"color: #000000;\">In this case we are supposed to use only Elastic Bean deployment capabilities, hence we will just assign the Elastic Beanstalk Full Access permission to the new User. We will be creating a new Group called eb-full-access and assign that group to our new user.<\/span><\/p>\n\n<p><span style=\"color: #000000;\"><img data-dominant-color=\"eceeef\" data-has-transparency=\"false\" style=\"--dominant-color: #eceeef;\" decoding=\"async\" loading=\"lazy\" class=\"not-transparent size-full wp-image-10034 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/AWS-create-group.png\" alt=\"AWS create group\" width=\"648\" height=\"701\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125552\/AWS-create-group.png 648w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125552\/AWS-create-group-277x300.png 277w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><\/span><\/p>\n\n<p><span style=\"color: #000000;\">Continue hitting next, you should get the review screen that looks like this.<\/span><\/p>\n\n<p><span style=\"color: #000000;\"><img data-dominant-color=\"f3f6f3\" data-has-transparency=\"false\" style=\"--dominant-color: #f3f6f3;\" decoding=\"async\" loading=\"lazy\" class=\"not-transparent size-full wp-image-10035 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/AWS-user.png\" alt=\"AWS user\" width=\"1684\" height=\"386\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125554\/AWS-user.png 1684w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125554\/AWS-user-300x69.png 300w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125554\/AWS-user-1024x235.png 1024w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125554\/AWS-user-768x176.png 768w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125554\/AWS-user-1536x352.png 1536w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125554\/AWS-user-1568x359.png 1568w\" sizes=\"(max-width: 1684px) 100vw, 1684px\" \/><\/span><\/p>\n\n<p><span style=\"color: #000000;\">Here it is important to note that, we will have to use these access keys and secrets soon. You can either leave this window open or just download the CSV file using the \u201cDownload .csv\u201d button.<\/span><\/p>\n<p><span style=\"color: #000000;\">Now we must open the console on our system and have to configure a new profile for the AWS cli. We can call this new profile eb-deploy-user. We will use the AWS to configure the tool to fulfill this function.<\/span><\/p>\n\n<p><span style=\"color: #000000;\"><img data-dominant-color=\"474543\" data-has-transparency=\"false\" style=\"--dominant-color: #474543;\" decoding=\"async\" loading=\"lazy\" class=\"not-transparent size-full wp-image-10036 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/AWS-configure-tool.png\" alt=\"AWS configure tool\" width=\"642\" height=\"108\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125554\/AWS-configure-tool.png 642w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125554\/AWS-configure-tool-300x50.png 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><\/span><\/p>\n\n<p><span style=\"color: #000000;\">Once the new profile is created, we can confirm it by opening the ~\/.aws\/credentials file and see that if the new profile is available there. Till now we have set up the Authentication and now let us move ahead and create our first EB application.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Step -3 &#8211; Creating the Elastic Beanstalk App<\/span><\/h3>\n<p><span style=\"color: #000000;\">We will be using the EB CLI tool to perform all the further actions. To get started, we will have to initialize our Node.js project as an Elastic Beanstalk project. To proceed further, we can use the eb init command, it will help us passing an argument for a new user profile, which we have already created using the &#8211;profile option.<\/span><\/p>\n\n<p><span style=\"color: #000000;\"><img data-dominant-color=\"44413f\" data-has-transparency=\"false\" style=\"--dominant-color: #44413f;\" decoding=\"async\" loading=\"lazy\" class=\"not-transparent size-full wp-image-10037 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/Creating-the-Elastic-Beanstalk-App.png\" alt=\"Creating the Elastic Beanstal\" width=\"590\" height=\"617\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125555\/Creating-the-Elastic-Beanstalk-App.png 590w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125555\/Creating-the-Elastic-Beanstalk-App-287x300.png 287w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/><\/span><\/p>\n\n<p><span style=\"color: #000000;\">For the sake of demonstration, we have chosen all the default options here. However, you are free to make the required configurations based on your project and regional requirements. <\/span><\/p>\n<p><span style=\"color: #000000;\">Now, If you check the Elastic Beanstalk console in your browser, you will find the new application names elastic beanstalk-HelloWorld listed there. Here it is important to note, that you must choose the correct Zone and Region to get the appropriate level of services.<\/span><\/p>\n<p><span style=\"color: #000000;\">Now we will proceed further with the creation of our first Elastic Beanstalk environment. In EB, the top-level entity it an Application, then within the application we can have several environments, like staging, development, or production environment. Here, we will be creating a single environment to show how this entire process functions.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Step -4 &#8211; Creating the EB Environment<\/span><\/h3>\n<p><span style=\"color: #000000;\">We will proceed with the creation of our first environment, by using the eb create command, that is offered by the EB Command Line Interface. Here, we are again using all the default options for now to avoid any complexities.<\/span><\/p>\n\n<p><span style=\"color: #000000;\"><img data-dominant-color=\"464341\" data-has-transparency=\"false\" style=\"--dominant-color: #464341;\" decoding=\"async\" loading=\"lazy\" class=\"not-transparent size-full wp-image-10038 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/EB-Environment.png\" alt=\"EB Environment\" width=\"953\" height=\"769\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125556\/EB-Environment.png 953w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125556\/EB-Environment-300x242.png 300w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125556\/EB-Environment-768x620.png 768w\" sizes=\"(max-width: 953px) 100vw, 953px\" \/><\/span><\/p>\n\n<p><span style=\"color: #000000;\">Now, as our EB application has been created and Environment has been set up and in place, we will notice a new directory in the root of our Node.js project, the directory called .elasticbeanstalk. You will also find a YML file in this directory, along with the deployment configuration.<\/span><\/p>\n\n<div class=\"bg-gray-code\" style=\"background: #d0d0d0; padding: 10px;\"><span style=\"color: #000000;\">branch-defaults:<\/span><br \/>\n<span style=\"color: #000000;\">master:<\/span><br \/>\n<span style=\"color: #000000;\">environment: elasticbeanstalk-helloworld-dev<\/span><br \/>\n<span style=\"color: #000000;\">group_suffix: null<\/span><br \/>\n<span style=\"color: #000000;\">global:<\/span><br \/>\n<span style=\"color: #000000;\">application_name: elasticbeanstalk-helloworld<\/span><br \/>\n<span style=\"color: #000000;\">branch: null<\/span><br \/>\n<span style=\"color: #000000;\">default_ec2_keyname: null<\/span><br \/>\n<span style=\"color: #000000;\">default_platform: Node.js<\/span><br \/>\n<span style=\"color: #000000;\">default_region: us-west-2<\/span><br \/>\n<span style=\"color: #000000;\">include_git_submodules: true<\/span><br \/>\n<span style=\"color: #000000;\">instance_profile: null<\/span><br \/>\n<span style=\"color: #000000;\">platform_name: null<\/span><br \/>\n<span style=\"color: #000000;\">platform_version: null<\/span><br \/>\n<span style=\"color: #000000;\">profile: eb-deploy-user<\/span><br \/>\n<span style=\"color: #000000;\">repository: null<\/span><br \/>\n<span style=\"color: #000000;\">sc: git<\/span><br \/>\n<span style=\"color: #000000;\">workspace_type: Application<\/span><\/div>\n\n<p><span style=\"color: #000000;\">This file contains all the necessary information, used by the EB Command Line interface to deploy our application. It contains a branch-defaults property, which helps EB to decide to which environment it should start the deployment, depending on the local GIT branch we are standing at.<\/span><\/p>\n<p><span style=\"color: #000000;\">In the current scenario, we are standing at the master branch, hence it will start <a href=\"https:\/\/www.arkasoftwares.com\/blog\/how-to-create-an-app\/\"><strong>application deployment<\/strong> <\/a> to the elastic beanstalk-HelloWorld-dev environment we have just created. <\/span><\/p>\n<p><span style=\"color: #000000;\">If required, we can anytime create separate environments and assign specific GIT branches to them and deployment could be performed there as well.<\/span><\/p>\n<p><span style=\"color: #000000;\">Here, we have to be a little bit patient as the Environment creation may take a few minutes as Elastic Beanstalk will create the EC2 instance and make the necessary configuration changes. <\/span><\/p>\n<p><span style=\"color: #000000;\">As a default option, it will also attempt to proceed with the deployment of our application, but this deployment may fail, we need to make further configuration changes to ensure this works fine.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Step -5 &#8211; Configuring the Node Command<\/span><\/h3>\n<p><span style=\"color: #000000;\">In the previous step, we did talk about the failure of initial deployment, the reason behind that failure is because Elastic Beanstalk looks at the application code and it found an app.js file in the directory. <\/span><span style=\"color: #000000;\">By default, when EB sees an app.js file, it considers it as an entry file and attempts to run node app.js.<\/span><\/p>\n<p><span style=\"color: #000000;\">In our case, we will be running the application using the npm start command. In a way or another, we will tell EB to use that command, instead of trying to run our app.js file on its own.<\/span><\/p>\n<p><span style=\"color: #000000;\">Now, access the left side menu and select the configuration option, within your application in the EB console and click the \u201cModify\u201d button within the <strong>\u201cSoftware\u201d <\/strong>box:<\/span><\/p>\n\n<p><span style=\"color: #000000;\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp- style= aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/Configuring-the-Node-Command.png\" alt=\"Configuring the Node Com\" width=\"1432\" height=\"542\" \/><\/span><\/p>\n\n<p><span style=\"color: #000000;\">Here we will see an empty field called \u201cNode command\u201d. We need to enter \u201cnpm start\u201d as the start command and click the <strong style=\"font-weight: 600;\">\u201cApply configuration\u201d<\/strong> button on the top right corner to proceed further.<\/span><\/p>\n<p><span style=\"color: #000000;\">We can also change the Node version in our instance, and we can make other configuration changes as well. We would recommend you go over all the configuration settings, as it will help you to understand the EB platform in a better way.<\/span><\/p>\n<p><span style=\"color: #000000;\">Once we are finished with all the configuration changes, the EB will once again try to run the application automatically using the new node command. Once it runs all the initialization steps, you will get a green status in your dashboard, which means the deployment has been successful.<\/span><\/p>\n<p><span style=\"color: #000000;\">Now you can click the environment URL and you will see the<strong style=\"font-weight: 600;\"> \u2018Express hello world\u2019<\/strong> page in your browser.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Step -6 &#8211; Deploying your app from the console<\/span><\/h3>\n<p><span style=\"color: #000000;\">Now, as we are done with all the configuration steps, it is time to deploy the application directly from our console, without accessing the AWS console in the browser. All we need to do is to run the eb deploy command and that is where we will get the successful application deployment.<\/span><\/p>\n<p><span style=\"color: #000000;\">Here, we want to share a quick tip for you, please make sure that you always commit the changes you want to deploy to the branch configured our config.yml file. <\/span><\/p>\n<p><span style=\"color: #000000;\">Once we hit the deploy command, it always searches for our local branch and initiates a build using that. God forbids, if you have uncommitted changes, then those will not be available in the deployed application.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Step -7\u00a0 Get a custom domain name<\/span><\/h3>\n<p><span style=\"color: #000000;\">As we are done with the Application deployment and it can be seen in the browser as well. But if you run eb open command, we will observe that application URL is very long. If required, then we can make the necessary changes using Route 53.<\/span><\/p>\n<h3><span style=\"color: #000000;\">Step -8 Get an SSL Certification<\/span><\/h3>\n<p><span style=\"color: #000000;\">An SSL certification is a de facto requirement for <span style=\"color: #0874b9;\"><a style=\"color: #0874b9;\" href=\"https:\/\/www.arkasoftwares.com\/blog\/security-measures-to-be-taken-while-developing-a-mobile-application\/\" target=\"_blank\" rel=\"noopener\"><strong>ensuring security for our web application<\/strong><\/a><\/span>. It is very easy to get an SSL certificate for our application instance. We can visit the certificate manager and start the process of creating a new certificate for our domain, it is quite an easy and effective process.<\/span><\/p>\n<p><span style=\"color: #000000;\">We can sign for an SSL cert for CloudFront, all we need is to start the process from the target zone and Region. We can always make the changes in our Zone at this screen.<\/span><\/p>\n\n<p><span style=\"color: #000000;\"><img data-dominant-color=\"e6e7e7\" data-has-transparency=\"true\" style=\"--dominant-color: #e6e7e7;\" decoding=\"async\" loading=\"lazy\" class=\"has-transparency size-full wp-image-10044 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/Get-an-SSL-Cert.png\" alt=\"Get an SSL Cert\" width=\"361\" height=\"519\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125559\/Get-an-SSL-Cert.png 361w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125559\/Get-an-SSL-Cert-209x300.png 209w\" sizes=\"(max-width: 361px) 100vw, 361px\" \/><\/span><\/p>\n\n<p><span style=\"color: #000000;\">Once we verify it and it is ready to use, we can add this to our EB configuration, we can use the following steps to add the SSL certification in the configuration.<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">Go to your EB dashboard<\/span><\/li>\n<li><span style=\"color: #000000;\">Choose your application<\/span><\/li>\n<li><span style=\"color: #000000;\">Choose your environment<\/span><\/li>\n<li><span style=\"color: #000000;\">Click on \u201cconfiguration\u201d and choose the SSL certificate.<\/span><\/li>\n<\/ul>\n<h5><span style=\"color: #000000;\"><img data-dominant-color=\"f6f6f6\" data-has-transparency=\"true\" style=\"--dominant-color: #f6f6f6;\" decoding=\"async\" loading=\"lazy\" class=\"has-transparency size-full wp-image-10043 aligncenter\" src=\"https:\/\/live-arkasoftwares.s3.us-east-1.amazonaws.com\/uploads\/2020\/10\/Load-Balancer.png\" alt=\"Load Balancer\" width=\"704\" height=\"443\" srcset=\"https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125559\/Load-Balancer.png 704w, https:\/\/live-arkasoftwares.s3.amazonaws.com\/uploads\/2020\/10\/17125559\/Load-Balancer-300x189.png 300w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/span><\/h5>\n<h5><\/h5>\n<h3><span style=\"color: #000000;\">Step \u2013 9 &#8211; ssh into the EC2 instance<\/span><\/h3>\n<p><span style=\"color: #000000;\">Here we have few commands to do the ssh into the EC2 instance.<\/span><br \/>\n<span style=\"color: #000000;\">To ssh into the EB EC2 instance, we can run the following command<\/span><\/p>\n<p><strong style=\"font-weight: 600;\"><span style=\"color: #000000;\">$ eb ssh &lt;environment_name&gt;<\/span><\/strong><\/p>\n<p><span style=\"color: #000000;\">To navigate to the location of the application files, we can run the following command<\/span><\/p>\n<p><strong style=\"font-weight: 600;\"><span style=\"color: #000000;\">$ cd \/var\/app\/current<\/span><\/strong><\/p>\n<h3><span style=\"color: #000000;\">Step -10 &#8211; Debugging<\/span><\/h3>\n<p><span style=\"color: #000000;\">Debugging is an important aspect of <a href=\"https:\/\/www.arkasoftwares.com\/services\/mobile-app-development-company\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #0874b9;\"> <strong>mobile application development<\/strong>.<\/span><\/a> Sometimes, the application status may not be \u2018green\u2019, it may be degraded, that means there might be some problem, which should be assessed and fixed. We can run the following command to view the logs and take the appropriate action. <\/span><br \/>\n<strong><span style=\"color: #000000;\">$ eb logs<\/span><\/strong><\/p>\n<h5><span style=\"color: #000000;\">Step \u2013 11 &#8211; Deploying an update<\/span><\/h5>\n<p><span style=\"color: #000000;\">If we want to deploy an update to the application, we can run the following command<\/span><br \/>\n<span style=\"color: #000000;\">$ eb deploy<\/span><\/p>\n<h5><span style=\"color: #000000;\">Step \u2013 12 &#8211; Setting environment variables<\/span><\/h5>\n<p><span style=\"color: #000000;\">If you want to set an environment variable using the CLI, run the following command<\/span><br \/>\n<span style=\"color: #000000;\">$ eb setenv [VAR_NAME=VALUE]<\/span><br \/>\n<span style=\"color: #000000;\">Step \u2013 13 &#8211; For more commands, run<\/span><br \/>\n<span style=\"color: #000000;\">$ eb &#8211;help<\/span><\/p>\n\n<h4><span style=\"color: #000000;\">Conclusion<\/span><\/h4>\n<p><span style=\"color: #000000;\">We hope these steps will help you with the <span style=\"color: #0874b9;\"><a style=\"color: #0874b9;\" href=\"https:\/\/www.arkasoftwares.com\/services\/web-development\/nodejs\" target=\"_blank\" rel=\"noopener\"><strong>deployment of Node.js application to AWS Elastic Beanstalk<\/strong><\/a><\/span>. Now we can go ahead and deploy to multiple environments in EB directly from your local console using a single command. We can deploy any valid <a href=\"https:\/\/www.arkasoftwares.com\/hire-nodejs-developer\"><strong>Node.js application<\/strong><\/a> in this way, including much more complex and practical applications.<\/span><\/p>\n<p><span style=\"color: #000000;\">The biggest advantage is that AWS Elastic Beanstalk is itself free. All we need to pay is for the underlying resources which we are using, like EC2 instances. It also offers 12 months of free 750 hours of EC2 per month under the free tier payment model.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cloud computing has revolutionized the IT World. It is an innovative platform and It has established itself as the backbone of the technology for the future. It allows organizations to&nbsp;[\u2026]<\/p>\n","protected":false},"author":1,"featured_media":10049,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1460,168],"tags":[1223,184],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/posts\/10024"}],"collection":[{"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/comments?post=10024"}],"version-history":[{"count":2,"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/posts\/10024\/revisions"}],"predecessor-version":[{"id":31770,"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/posts\/10024\/revisions\/31770"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/media\/10049"}],"wp:attachment":[{"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/media?parent=10024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/categories?post=10024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.arkasoftwares.com\/blog\/wp-json\/wp\/v2\/tags?post=10024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}