joseph goksu
A Quick Guide to Deploying a NestJS App to AWS ECS Using Pulumi
Published on

A Quick Guide to Deploying a NestJS App to AWS ECS Using Pulumi

Find the finest methods for deploying NestJS applications to AWS ECS using Pulumi.
Authors

Overview

Introduction

One of my favourite tools is Pulumi. It is an excellent solution for developing and deploying apps to cloud platforms like AWS, Azure, and Google Cloud.

I have been using it for a while now, and I am quite pleased with the results. It is extremely simple to use and very powerful.

In this article, I'll show you how to deploy a NestJS app to AWS ECS using Pulumi.

Prerequisites

Step by Step Guide

  1. Create a new Pulumi project

    
    $ pulumi new my-project
    
    $ cd my-project
    
    
  2. Install the Pulumi NPM dependencies and import them into the relevant js/ts file.

Pulumi NPM dependencies and import to the related js/ts file
  1. Define Container's credentials.
Define the credientials for Container
  1. Create a VPC, Gateway and Route Table
Create a VPC, Gateway and Route Table

I'd want to show you an AWS Architecture diagram at that point.

AWS Architecture diagram

You can find best practises for constructing a VPC, Subnets, and so on, but we don't need to do that for this experiment.

  1. Create an S3 bucket to hold the static files (I assume we also have frontend app)
Create a S3 Bucket for storing the static files
  1. We're almost finished. To reach the server app, we must first establish an Elastic Load Balancer. Following that, we will define an AWS ECS fargate task.

A ECS cluster will be created using the task definition. It will also generate our Docker image and upload it to the ECR.

We almost done. We need to create an Elastic Load Balancer to reach the server app. After that we will create a AWS ECS fargate task definition. The task definition will be used to create a ECS cluster. It will also build our docker image and push it to the ECR.
  1. To run the IaC, use the following commands.
    $ pulumi up
  1. Check the output on the pulumi dashboard. That's it. :)

See you in the next hands-on lab. Thanks for reading! Reach out to me on Twitter if you have any questions or comments.