Node with TypeScript: How to configure automatic deploy on AWS with Elastic Beanstalk

Matheus Ícaro
5 min readJan 3, 2021

--

[ Deploy, Node, TypeScript, Elastic Beanstalk, AWS ]

For this article, I want to demonstrate how to set up automatic deploys of a Node.js application with TypeScript on the AWS Cloud, using Elastic Beanstalk. In this way, this article will be like a tutorial, a little more direct, like a sequence of steps.

To start, you will need to have an AWS account, it is a project working correctly. I will use this repository as an example.

On the AWS console, look for Elastic Beanstalk, and create your application as shown in the image below:

step 1

After creating the application, create a new environment in the sequence of images below:

step 2
step 3

Add a domain and check its availability in the region where you are working

step 4
step 5

Now, wait for the EC2 instance creation process to finish.

step 6

Once completed, you will see in the environment settings of your application that it was successful, and something is already running.

step 7

Now, let’s set up a pipeline to get our project repository. We will use the CodePipeline that you can access on the console, as shown below:

step 8
step 9
step 10

In the image below, connect to your Github repository:

step 11

Now choose which branch will receive Github events that will be sent to the pipeline. Be careful when choosing.

In this case, I will use the “master” branch, and any commit made on the master, the pipeline will be executed.

step 12

At this point, let’s skip the build configuration.

step 13
step 14
step 15

Now let’s wait for the pipeline to run for the first time.

step 16

After finishing, just click on the Elastic Beanstalk link to return the environment settings of our application.

step 17

We can see that our application did fail to upload the code directly from the master branch repository.

step 18

In this repository, we have a health route to get the status of the application, and it really isn’t working.

step 19

We were able to analyze the application logs as shown in the image below:

step 20
step 21

We were able to identify that we did not compile TypeScript. So, let’s edit our application’s package.json to execute the build in the “start” script.

step 22

After committing our change to the “dev” branch, and making a merge request to the “master” branch, we can see that the pipeline received an update event, and is automatically running a new deploy.

step 23
step 24

Let’s access the host of our application again:

step 25
step 26

We realized that our application is working now. Let’s configure the health route to monitor the health of our application.

Let’s access the settings as shown below:

step 27
step 28

Add a new process to detect the health route in HTTP / 80 and HTTPS / 443.

step 29
step 30

Now we can confirm that the status of our application is all ok and everything is still working.

step 31

--

--

Matheus Ícaro
Matheus Ícaro

Written by Matheus Ícaro

I am a software developer with extensive experience in building scalable web applications to serve thousands of users and huge requests

Responses (1)