<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[AWS RDS]]></title><description><![CDATA[AWS RDS]]></description><link>https://awsrds.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 09:45:58 GMT</lastBuildDate><atom:link href="https://awsrds.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Aws RDS with Docker and EC2]]></title><description><![CDATA[How I Hosted a Node.js Frontend and Backend with Docker on AWS EC2 and Connected it to AWS RDS
Introduction
I recently set up a project where I hosted a Node.js frontend and backend on an AWS EC2 instance using Docker. The backend connected to a MySQ...]]></description><link>https://awsrds.hashnode.dev/aws-rds-with-docker-and-ec2</link><guid isPermaLink="true">https://awsrds.hashnode.dev/aws-rds-with-docker-and-ec2</guid><category><![CDATA[AWS RDS]]></category><category><![CDATA[AWS]]></category><category><![CDATA[aws ec2]]></category><dc:creator><![CDATA[Kunal Kumar Singh]]></dc:creator><pubDate>Wed, 12 Mar 2025 08:03:27 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-how-i-hosted-a-nodejs-frontend-and-backend-with-docker-on-aws-ec2-and-connected-it-to-aws-rds">How I Hosted a Node.js Frontend and Backend with Docker on AWS EC2 and Connected it to AWS RDS</h1>
<h2 id="heading-introduction">Introduction</h2>
<p>I recently set up a project where I hosted a <strong>Node.js frontend and backend</strong> on an <strong>AWS EC2 instance</strong> using <strong>Docker</strong>. The backend connected to a <strong>MySQL database</strong> running on AWS RDS to store data. This setup made deployment smoother and scalable. In this blog, I’ll explain how I did it step by step.</p>
<h2 id="heading-what-i-used">What I Used</h2>
<ul>
<li><p><strong>Frontend &amp; Backend:</strong> Node.js with Express.js</p>
</li>
<li><p><strong>Database:</strong> AWS RDS (MySQL)</p>
</li>
<li><p><strong>Hosting:</strong> AWS EC2 with Docker</p>
</li>
<li><p><strong>Extras:</strong> Nginx for handling traffic, Docker Compose for managing containers, and GitHub Actions for CI/CD</p>
</li>
</ul>
<h2 id="heading-setting-up-aws-rds">Setting Up AWS RDS</h2>
<p>Before setting up the EC2 instance, I created a MySQL database using AWS RDS:</p>
<ol>
<li><p>Logged into <strong>AWS RDS</strong> and created a <strong>MySQL</strong> database.</p>
</li>
<li><p>Chose the <strong>Free Tier</strong> for cost savings.</p>
</li>
<li><p>Set the security group to allow connections from my EC2 instance.</p>
</li>
<li><p>Created a database and saved my credentials for later.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741766389766/9d568e54-77be-499d-8aa6-f2891341e657.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<h2 id="heading-deploying-the-backend-with-docker-on-aws-ec2">Deploying the Backend with Docker on AWS EC2</h2>
<p>I hosted the backend on an EC2 instance inside a <strong>Docker container</strong>.</p>
<ol>
<li><p><strong>Started an EC2 instance</strong> (Ubuntu or Amazon Linux)</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741766430231/aaff5ffa-99c4-4c30-bb1c-02e415f7a14b.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Installed <strong>Docker</strong> and <strong>Docker Compose</strong>:</p>
</li>
<li><p>Pulled the docker image from the Docker Hub.</p>
<pre><code class="lang-plaintext"> sudo yum install docker -y 
 sudo systemctl start docker
 sudo docker pull philippaul/node-mysql-app:02
</code></pre>
</li>
<li><p>Run the Image pulled from Docker Hub.</p>
<pre><code class="lang-plaintext"> docker run --rm -p 80:3000 -e DB_HOST="your_hostname" -e DB_User="admin" -e DB_password="password" -d philippaul/node-mysql-app:02
</code></pre>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741766337096/d25865f9-3d1c-482c-9452-2ca2a1dbaa7b.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>We will now check and add the data from MySql as well , we will run the below command.</p>
<pre><code class="lang-plaintext"> sudo docker run -it --rm mysql:8.0 mysql -h "your_host_name" -u admin -p
</code></pre>
</li>
<li><p>Now we can Run the basics Query of MySql to show the data available.</p>
<pre><code class="lang-plaintext"> select * from contacts;
</code></pre>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741766482051/6cb95ece-96bb-43c4-b01a-dd8cfc083feb.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-automating-deployment-with-github-actions">Automating Deployment with GitHub Actions</h2>
<p>To make deployments smoother, I used <strong>GitHub Actions</strong>:</p>
<ol>
<li><p>Created a workflow to build and push Docker images.</p>
</li>
<li><p>Configured the EC2 instance to pull updates and restart containers.</p>
</li>
<li><p>Automated deployments whenever I pushed changes to the repository.</p>
</li>
</ol>
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>Hosting a full-stack Node.js application with Docker on EC2 while using AWS RDS for the database made my deployment process efficient and scalable. If you’re working on a similar setup, I hope this guide helps!</p>
]]></content:encoded></item></channel></rss>