From Local to Cloud: Deploying a Django Employment Management App with AWS RDS

·

6 min read

Cover Image for From Local to Cloud: Deploying a Django Employment Management App with AWS RDS

💡 Introduction

Welcome to the world of DevOps and Cloud Computing! Today, we’re diving into an exciting hands-on project where we’ll build an Employee Management Application using Django and migrate its database to AWS RDS (Relational Database Service).

Here’s what we’ll cover step by step:
✅ Build the Django application.
Test it locally to ensure everything works.
Migrate the database from a local setup to AWS RDS.
Containerize the application using Docker for better scalability.
Verify the database to check if our data is stored correctly in the cloud.

By the end of this guide, you’ll have a solid understanding of how to integrate Django with AWS RDS, making your applications cloud-ready! Let’s get started. 🚀


💡 Pre-requisites

Before we dive into the project, let's make sure we have everything set up. Here’s what you’ll need:

🔹 An AWS Account – Since we’ll be creating a database on AWS RDS, an AWS account is a must. If you don’t have one, you can sign up at aws.amazon.com.

🔹 Python Installed – Django is a Python framework, so having Python installed on your system is essential. You can check if Python is installed by running:

python --version
// or
python3 --version

If it's not installed, download it from python.org.

🔹 Docker Installed – We’ll be containerizing our Django app using Docker to make it more portable. If you don’t have Docker installed, you can get it from docker.com.


💡 Getting Started with the Project

Now that we have our prerequisites sorted, let’s jump into building the Employee Management Application! To make things easier, I’ve already hosted the code on GitHub.

Step 1: Clone the Project

First, open your terminal and clone the GitHub repository:

git clone https://github.com/Pravesh-Sudha/employee_management.git

Now, navigate to the project directory:

cd employee_management

Inside this folder, you’ll find:

  • Dockerfile – To containerize our Django app.

  • manage.py – The core script to manage our Django project.

  • db.sqlite3 – A local SQLite database file.

Step 2: Customize the Application (Optional, but Fun!)

To make this project feel more personal, let’s add a small customization. Open this file:

employees/templates/employees/employee_list.html

Find this line:

<div class="navbar">Pravesh Sudha's Employee Management Table</div>

Change "Pravesh Sudha" to your own name, so it feels like your own project.

Step 3: Build the Docker Image

Now, let’s containerize our application. Run the following command from the project’s root directory:

docker build -t employee-management:v1 .

This will create a Docker image named employee-management:v1.

Step 4: Run the Application in a Container

Now, start the container using:

docker run -d -p 8000:8000 employee-management:v1

Your application is now running! 🎉

Step 5: Access the Application

Open your browser and go to:

http://localhost:8000

Ps: I manually added some entries in the above screenshot.

You should see the Employee Management Table! 🎊 Try adding and deleting employees to test how it works.

Now that our Django app is up and running locally, let’s move on to migrating the database to AWS RDS. 🚀


💡 Migrating the Database to AWS RDS

Now that our Employee Management Application is up and running locally, let’s take things to the next level by migrating our database to AWS RDS (Relational Database Service).

Step 1: Create a MySQL Database in AWS RDS

1️⃣ Log in to AWS Console → Navigate to RDS → Click Create Database
2️⃣ Select Standard Create
3️⃣ Choose MySQL as the engine
4️⃣ Use Free Tier as the template
5️⃣ Under Credentials Settings, select Self-managed and set:

  • Username: admin

  • Password: admin1234
    6️⃣ Enable Public Access (so we can connect externally)
    7️⃣ Click Create Database

Once the database is fully set up, copy the endpoint (we’ll need this soon).

Step 2: Update Django’s Database Configuration

Open the settings.py file inside the employee_management directory and update the DATABASES block:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'employee_db',  
        'USER': 'admin',
        'PASSWORD': 'admin1234',
        'HOST': 'Your-Endpoint-Here',
        'PORT': '3306',
    }
}

🔹 Replace "Your-Endpoint-Here" with the RDS endpoint you copied earlier.
🔹 Since MySQL runs on port 3306, make sure your security group allows inbound connections on port 3306.

Step 3: Create the employee_db Database in MySQL Workbench

We need to create a database on our RDS instance before Django can migrate tables.

1️⃣ Open MySQL Workbench
2️⃣ Click the + icon to add a new connection
3️⃣ Provide these details:

  • Connection Name: my-database

  • Username: admin

  • Password: admin1234

  • Host: Paste your RDS endpoint
    4️⃣ Click OK to connect

Now, in the Query section, run:

CREATE DATABASE employee_db;
EXIT;

This will create the database and exit the session.

Step 4: Run Django Migrations

Now, let’s migrate our database to AWS RDS. Open your terminal and run:

python3 manage.py makemigrations
python3 manage.py migrate

This will create all necessary tables in AWS RDS instead of using SQLite.

Step 5: Build and Run the New Docker Image

Now that our database is in RDS, we need to rebuild our Docker image:

docker build -t employee-management:v2 .

Run the new container:

docker run -d -p 8000:8000 employee-management:v2

Step 6: Test Your Application & Verify the Database

Now, open your browser and go to:

http://localhost:8000

Try adding and deleting employees as before.

To check if the data is stored in AWS RDS, go back to MySQL Workbench and run these queries:

USE employee_db;
SELECT * FROM employees_employee;

If everything worked, you’ll see the Django tables inside the MySQL database on AWS! 🎉


💡 Conclusion

In this blog, we explored how to build a Django-based Employee Management Application and take it a step further by migrating its database to AWS RDS. Along the way, we:

Developed a Django application and tested it locally
Containerized the application using Docker
Set up a MySQL database in AWS RDS
Configured Django to connect with RDS and migrated the database
Verified data persistence using MySQL Workbench

This project provided hands-on experience with cloud databases, Docker, and Django, giving us insights into deploying real-world applications on scalable cloud infrastructure.

The best part? We now have a solid foundation for further enhancements! You could explore CI/CD pipelines for automated deployments, AWS Lambda for serverless functions, or Kubernetes for container orchestration. The possibilities are endless! 🚀

If you enjoyed this guide, feel free to share your thoughts, ask questions, or experiment with new features. Happy coding! 😊

✨ For more informative blog, Follow me on Hashnode, X(Twitter) and LinkedIn.