How To Deploy Your Node.js Application On AWS Using GitHub.
Tags: aws, node, github, devops
Published: 2021-03-06 15:58:13

Good Day friends, nice having you here.

If you have been trying to figure out how to deploy your NodeJS application on Aws using GitHub, reading through this note would be a work-through for you.

So let's get started.

Prerequisites:
Make sure you have a GitHub account and a Git installed on your machine.
Make sure you have an AWS account setup.

Getting started

Firstly let's get started by pushing or app to Github
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dsjtw2h8moibpj2l0cby.PNG)
yea I have my repo created and the code has been pushed.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4coe5qrwhctvt7ed8jir.PNG) 
so finally you have your app push to GitHub now, Awesome we are moving gradually.

Let's proceed to our Aws account to set up the needed services need to have our app up and running.

My dashboard view below
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73cilthrt1gn4cmopgkf.PNG)

so let's dive into the services to set up a basic Nodejs app up and running.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvbf5nbr3tg84b4g45rc.PNG)

After taking a look at the different services available let's dive straight to the one we needed.

First Service (CodePipeline), What is a code pipeline?

 AWS CodePipeline is a fully managed continuous delivery service that helps you automate your release pipelines for fast and reliable application and infrastructure updates. ... You can easily integrate AWS CodePipeline with third-party services such as GitHub, which is what we would be using GitHub.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wy65e9cqbzk5kq2pgckq.PNG)

So we need to go further by creating a pipeline that handles getting updates from our repo push to Github.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sgdsrb3sn16wgnud70kc.PNG)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5datmkaj1uieaidibs7h.PNG)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oamq4rm6phbul618tgau.PNG)

The image above clicks on connect to Github button which automatically pops up a modal for you to authorize the accessing of your repo and when this is done successfully you should have the outcome below.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqps52fnh4f65rm33ng5.PNG)

From here search for the repo you want to deploy and add it up alongside the branch.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/76yjcw8stvp2qwdbmzk4.PNG)

You can decide to choose the build stage if you want to spice up your pipeline with some more configuration which won't be included in this note now, just click on the skip build stage button.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ywmgp1xof54bh2r6z8c.PNG)

So the next is for us to choose the provider we would be using to host our app,  there are a variety of provider listed but we would be using Elastic Beanstalk
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1cdo2tit006a2n3hkert.PNG)
After selecting Elastic Beanstalk you would be asked to put in the application name which in your case as a first timer in deploying to AWS you would have no application name suggested for you.

So click on the services dropdown to get to see the list of services, go on by opening Elastic BeanStalk in a new tab.

So to create a new application navigate to applications on the sidebar, so you can go further by clicking on create new application button.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36ow60m7pxykju0j2ubb.PNG)
 After you have your app created you would be redirected to create an environment.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqiy1g5hskmj0wkzq5eu.PNG)
Go further to create an environment and select web server as the option.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mxlk3glx0dyw0tcjasq.PNG)

So now that you have your Application created and environment name generated go back to your abandoned tab to put in the info that is required of you is "application and the environment name"
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lmevnecooapuxigxkz6x.PNG)
So you can create your pipeline now, by just clicking create a pipeline.

--- Then we can go back to complete our Environment setup on the other tab.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7amvrlp8ysv26170j2nf.PNG)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qjghvdvbz7ybrb0aoli.PNG)
So you need to select a platform which is Nodejs, after you have done that you can click on create environment button.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xu5tohctdm9sfgk5o72.PNG)
The image above would take some time to finally create the environment.
Finally, you have your environment created below image-
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tcsa4t6wdafepkawhelh.PNG)
The image below shows a successful pipeline created
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdwsj9najvf3gbbr7f5c.PNG)

Hope this helps. Please share your valuable feedback.

That's it!!! I hope you had fun reading and learning from the not to continue the conversation you can follow me on Twitter: https://twitter.com/femithz

Gracias!!!