Mastering DevOps: Deploy 3-Tier Project on AWS EC2 (Day 2)

Mastering DevOps: Deploy 3-Tier Project on AWS EC2 (Day 2)

Introduction

Embark on a comprehensive journey into mastering DevOps with a focus on virtualization, exploring the deployment of a 3-tier project on AWS EC2.

Getting Started with GitHub

Before we get to work on the project, we need to understand how to move around on GitHub's website. This is important because we will find the project's code there, which we will later put on AWS EC2.

Clone the git repo using the command "git clone" and take the entire code on your local system

Project Structure and Technologies

Here, we learn about the different parts of the project - the frontend (what the user sees), backend (how the site works), and the database (where information is stored). Understanding how these parts work together is crucial in making the project function smoothly.

Understanding the 3-Tier Application

1. Frontend:

The frontend is the part of the project that the user interacts with directly. It includes elements like the user interface, the design, and how information is presented to the user. In this project, technologies like React JS are likely used for frontend development. React JS is a popular library for building user interfaces in JavaScript. It helps in creating dynamic, responsive, and user-friendly interfaces that users can interact with seamlessly.

2. Backend:

The backend is like the engine of the project. It handles the logic, processes data, and communicates with the frontend and database. Common technologies for backend development in this project may include Node JS and Express JS. Node JS allows developers to run JavaScript on the server-side, enabling the backend to handle user requests, process data, and generate dynamic content. Express is a popular framework for Node JS that simplifies routing, middleware, and building APIs, making backend development more efficient.

3. Database:

The database is where all the project's data is stored. In this project, MongoDB is mentioned as a likely choice for database management. MongoDB is a NoSQL database program, which means it stores data in a flexible, JSON-like format. It's often used in modern web applications for its scalability, flexibility, and ease of use. The backend communicates with the database to store and retrieve data, ensuring that the application functions correctly and efficiently.

Each of these components (frontend, backend, and database) works together harmoniously to create a functioning web application. The frontend provides the user interface, the backend processes requests and data, and the database stores and retrieves information, resulting in a cohesive and interactive user experience. Understanding how these parts interact is essential for developing and deploying a successful project.

Time for some hands on:-

Using the free-tier ec2 instance with Ubuntu image to launch the instance.

Setting Up the Frontend:

  1. Navigate to the frontend code directory within the cloned repository.

  2. Install the necessary dependencies using package managers like Npm and Node JS

    Setting Up the backend:

    1. Move to the backend code directory within the cloned repository.

    2. Install dependencies required for the backend code through package managers.

      Setting Up the Database:

      1. Install mongodb fron the site and start the server.

      2. Check if mongoDB is correctly installed by "mongosh"

Establishing Connection between Frontend, Backend, and Database:

  1. To establish connection between frontend, backend and database need to follow few things.

  2. Make sure to copy the env variables in the ".env file"

  3. Also need to open the specific ports in the security group of ec2 instance to access from the internet.

  4. Use the "nohup" command to keep the frontend working while backend and database are already working

Conclusion

Mastering the deployment of a 3-tier project on AWS EC2 opens the doors to a world of possibilities in the realm of DevOps, setting the stage for leveraging cloud infrastructure efficiently and effectively.