<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nidhish on Medium]]></title>
        <description><![CDATA[Stories by Nidhish on Medium]]></description>
        <link>https://medium.com/@nidhishprofessional?source=rss-aaf931e99f2a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hZLJClIAGL_gAEWSj1woqg.jpeg</url>
            <title>Stories by Nidhish on Medium</title>
            <link>https://medium.com/@nidhishprofessional?source=rss-aaf931e99f2a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:12:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nidhishprofessional/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Production-Style CI/CD Pipeline Using Jenkins and Docker on AWS EC2]]></title>
            <link>https://medium.com/@nidhishprofessional/building-a-production-style-ci-cd-pipeline-using-jenkins-and-docker-on-aws-ec2-8594eae6e695?source=rss-aaf931e99f2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8594eae6e695</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Nidhish]]></dc:creator>
            <pubDate>Sat, 24 Jan 2026 12:32:22 GMT</pubDate>
            <atom:updated>2026-01-24T12:32:22.095Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern applications demand fast, reliable, and repeatable deployments. In this blog, I’ll walk through how I built a <strong>real CI/CD pipeline using Jenkins and Docker</strong>, deployed across <strong>two AWS EC2 instances</strong>, closely mirroring how startups and small teams actually work in production.</p><h3>Architecture Overview</h3><p>We use <strong>two EC2 instances</strong> inside the same VPC:</p><h3>1. Jenkins EC2 (CI Server)</h3><ul><li>Runs Jenkins inside Docker</li><li>Listens on port 8080</li><li>Responsible for:</li><li>Pulling code from GitHub</li><li>Building Docker images</li><li>Deploying the app to App EC2 via SSH</li></ul><h3>2. App EC2 (Production Server)</h3><ul><li>Runs a Python FastAPI app using Docker</li><li>Exposes the app on port 8000</li><li>Receives deployments from Jenkins</li></ul><h3>Flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vo-sh9nLBa6n-CGmOZtuSg.png" /></figure><h3>Tech Stack Used</h3><ul><li>AWS EC2 (Ubuntu)</li><li>Jenkins (Dockerized)</li><li>Docker</li><li>GitHub</li><li>Python (FastAPI)</li><li>SSH key-based authentication</li></ul><h3>Step 1: App Dockerfile (Production-Ready)</h3><pre># ---------- Build stage ----------<br>FROM python:3.11-slim AS builder</pre><pre>WORKDIR /app<br>COPY app/requirements.txt .<br>RUN pip install --no-cache-dir --upgrade pip \<br>    &amp;&amp; pip install --no-cache-dir -r requirements.txt</pre><pre># ---------- Runtime stage ----------<br>FROM python:3.11-slim</pre><pre>WORKDIR /app<br>RUN useradd -m appuser</pre><pre>COPY --from=builder /usr/local /usr/local<br>COPY app /app</pre><pre>USER appuser<br>EXPOSE 8000</pre><pre>CMD [&quot;uvicorn&quot;, &quot;main:app&quot;, &quot;--host&quot;, &quot;0.0.0.0&quot;, &quot;--port&quot;, &quot;8000&quot;]</pre><h3>Step 2: Jenkins Setup Using Docker</h3><pre>docker volume create jenkins_home</pre><pre>docker run -d \<br>  --name jenkins \<br>  -p 8080:8080 \<br>  -p 50000:50000 \<br>  -v jenkins_home:/var/jenkins_home \<br>  -v /var/run/docker.sock:/var/run/docker.sock \<br>  --restart unless-stopped \<br>  jenkins/jenkins:lts</pre><h3>Step 3: Secure Jenkins → App EC2 Access (SSH)</h3><p>To allow Jenkins to deploy to the App EC2:</p><h3>Generate SSH key on Jenkins EC2</h3><pre>ssh-keygen -t ed25519 -f ~/.ssh/jenkins-app</pre><h3>Copy public key to App EC2</h3><pre>ssh-copy-id -i ~/.ssh/jenkins-app.pub ubuntu@&lt;APP_PRIVATE_IP&gt;</pre><p>Now Jenkins can SSH into App EC2 <strong>without passwords</strong>, which is critical for automation.</p><h3>Step 4: Jenkins Pipeline (Declarative)</h3><p>This pipeline:</p><ul><li>Pulls code from GitHub</li><li>Builds Docker image</li><li>SSHs into App EC2</li><li>Replaces the running container with the new version</li></ul><pre><br>   pipeline {<br>    agent any<br><br>    stages {<br>        stage(&#39;Checkout&#39;) {<br>            steps {<br>                git branch: &#39;main&#39;, url: &#39;https://github.com/your-repo.git&#39;<br>            }<br>        }<br><br>        stage(&#39;Build Docker Image&#39;) {<br>            steps {<br>                sh &#39;docker build -t myapp:latest .&#39;<br>            }<br>        }<br><br>        stage(&#39;Deploy to App EC2&#39;) {<br>            steps {<br>                sh &#39;&#39;&#39;<br>                ssh -i ~/.ssh/jenkins-app ubuntu@10.0.1.157 &lt;&lt; EOF<br>                  docker stop myapp || true<br>                  docker rm myapp || true<br>                  docker run -d --name myapp -p 8000:8000 myapp:latest<br>                EOF<br>                &#39;&#39;&#39;<br>            }<br>        }<br>    }<br>}</pre><h3>Step 5: Security Groups Configuration</h3><h3>Jenkins EC2</h3><ul><li>22 (SSH): Your IP</li><li>8080 (Jenkins UI): Your IP</li></ul><h3>App EC2</h3><ul><li>22 (SSH): Jenkins EC2 private IP</li><li>8000 (App): Load balancer or trusted IP</li></ul><p>No public SSH exposure between servers.</p><h3>Step 6: What Happens on Every Git Push</h3><ol><li>Developer pushes code to GitHub</li><li>Jenkins pipeline triggers</li><li>Docker image is rebuilt</li><li>Jenkins SSHs into App EC2</li><li>Old container stops</li><li>New container starts</li><li>App updates instantly with zero manual steps</li></ol><p>This is <strong>true CI/CD</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8594eae6e695" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Secure 3-Tier Architecture on AWS with ALB, Private EC2, NAT Gateway, and RDS]]></title>
            <link>https://medium.com/@nidhishprofessional/building-a-secure-3-tier-architecture-on-aws-with-alb-private-ec2-nat-gateway-and-rds-98a2f26d5d14?source=rss-aaf931e99f2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/98a2f26d5d14</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[nat-gateway]]></category>
            <category><![CDATA[aws-rds]]></category>
            <category><![CDATA[aws-alb]]></category>
            <dc:creator><![CDATA[Nidhish]]></dc:creator>
            <pubDate>Wed, 14 Jan 2026 12:30:49 GMT</pubDate>
            <atom:updated>2026-01-14T12:47:45.281Z</atom:updated>
            <content:encoded><![CDATA[<p>Most production systems are not deployed on a single server. Instead, they follow a multi-tier architecture where the web layer, application layer, and database layer are isolated for security and scalability.</p><p>In this project, I built a complete <strong>3-tier architecture on AWS</strong> using:</p><ul><li>VPC with public and private subnets</li><li>Application Load Balancer (ALB)</li><li>Frontend EC2 in public/private tier</li><li>Backend EC2 in private subnet</li><li>NAT Gateway for outbound internet access</li><li>PostgreSQL RDS in private database subnet</li></ul><p>The goal was to follow <strong>real-world cloud security practices</strong>, not just get the app running.</p><h3>Architecture Overview</h3><h4>High-Level Components</h4><ul><li><strong>VPC</strong>: Isolated network for all resources</li><li><strong>Public Subnets</strong>: Contain ALB and NAT Gateway</li><li><strong>Private App Subnet</strong>: Backend EC2 instance</li><li><strong>Database Subnet</strong>: RDS PostgreSQL instance</li><li><strong>Security Groups</strong>: Enforce tier-to-tier communication rules</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kP2IC9Q8T0kcXHj_v-uShg.png" /></figure><h3>Request Flow (End-to-End)</h3><p>Here is how a user request travels through the system:</p><ol><li>User sends HTTP request from browser</li></ol><p>2. Request hits <strong>Application Load Balancer (public subnet)</strong></p><p>3. ALB forwards traffic to <strong>Frontend EC2 target group</strong></p><p>4. Frontend makes API calls to <strong>Backend EC2 (private subnet)</strong></p><p>5. Backend queries <strong>PostgreSQL RDS (private database subnet)</strong></p><p>6. Response flows back through backend → frontend → ALB → user</p><p>No direct access to backend or database from the internet.</p><h4>Outbound Internet Flow for Private Instances</h4><p>Private instances still need internet access for:</p><p>OS updates</p><p>Docker image pulls</p><p>Package installs</p><p>Flow:</p><p>Backend EC2 → Route Table → NAT Gateway (public subnet) → Internet Gateway → Internet</p><p>Inbound traffic is blocked, but outbound traffic is allowed.</p><h3>Step-by-Step Build Process</h3><h4>Step 1: VPC and Subnet Design</h4><p>Created a custom VPC with CIDR block:</p><ul><li>Example: 10.0.0.0/16</li></ul><p>Subnets:</p><ul><li>Public Subnet A (ALB + NAT)</li><li>Public Subnet B (ALB high availability)</li><li>Private App Subnet (Backend EC2)</li><li>Private DB Subnet (RDS)</li></ul><p>Each subnet placed in different Availability Zones for fault tolerance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNCxhEt0bfCuMK6M9E6FEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7meWKzHjrfJowa4FvJO5hw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Al7wmuCS8f-HAe9XPmEiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jnJjuH6tXb9PQ_wvzGzKZg.png" /></figure><h4><strong>Step 2: Internet Gateway, NAT Gateway, Route Tables, and ALB</strong></h4><p>Subnets alone don’t determine traffic flow — route tables define where network traffic can go. In this project, I created separate route tables for public and private subnets to strictly control inbound and outbound connectivity.</p><ul><li><strong>Internet Gateway:</strong> Attached to the VPC to provide public internet access for resources in public subnets.</li><li><strong>NAT Gateway:</strong> Deployed in a public subnet to allow private instances to initiate outbound traffic (for OS updates, package installs, Docker image pulls) while blocking inbound traffic.</li><li><strong>Route Tables:</strong></li><li>Public subnets: Route 0.0.0.0/0 → Internet Gateway</li><li>Private subnets: Route 0.0.0.0/0 → NAT Gateway</li><li><strong>Application Load Balancer (ALB):</strong></li><li>Deployed in public subnets</li><li>Receives incoming HTTP/HTTPS requests from users</li><li>Forwards traffic to frontend EC2 instances in private subnets</li><li>Ensures the backend and database remain inaccessible directly from the internet</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ARJ0JAltc86ckRFNhqW4FQ.png" /><figcaption>Internet Gateway</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*99t0sypRFW80Ro82WxFgIg.png" /><figcaption>NAT Gateway</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTrxgY_tqVD8Ozqui8o2Gg.png" /><figcaption>Public Route Table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nxnxuUcN_8KMY0IRjo97zw.png" /><figcaption>Internet Gateway in public route table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JaeemmKAmV3dxfB9DfCg4w.png" /><figcaption>Subnet assoiciations in Public route table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*95b-zugzBedl6FfLfp4AXA.png" /><figcaption>NAT Gateway in private route table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rnnVFVwEQ5_4vfKBF6F0AQ.png" /><figcaption>Application Load Balancer</figcaption></figure><h4>Step 3: Security Group Design (Tier-Based Access)</h4><p>Instead of opening ports using IP ranges, I used <strong>security group referencing</strong>, which is more secure.</p><h4>ALB Security Group</h4><p>Inbound:</p><ul><li>HTTP/HTTPS from 0.0.0.0/0</li></ul><p>Outbound:</p><ul><li>To Frontend EC2 SG</li></ul><h4>Frontend EC2 Security Group</h4><p>Inbound:</p><ul><li>HTTP from ALB SG</li></ul><p>Outbound:</p><ul><li>To Backend EC2 SG</li></ul><h4>Backend EC2 Security Group</h4><p>Inbound:</p><ul><li>API port (example 5000) from Frontend EC2 SG</li></ul><p>Outbound:</p><ul><li>All traffic (for NAT + DB)</li></ul><h4>RDS Security Group</h4><p>Inbound:</p><ul><li>PostgreSQL (5432) from Backend EC2 SG</li></ul><p>Outbound:</p><ul><li>Default</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7H3gQ_t9uh3acyf4bCyLxg.png" /></figure><p>This ensures <strong>only backend can talk to database</strong>.</p><h4>Step 4: Deploy Frontend and Backend with Docker</h4><p>Both EC2 instances run Docker containers.</p><h4>Frontend</h4><ul><li>Nginx container serving React build</li><li>Exposed via ALB target group</li></ul><h4>Backend</h4><ul><li>Node.js API container</li><li>Exposes API port internally</li><li>Uses environment variables for DB config</li></ul><p>Docker allows consistent runtime across environments.</p><h4>Step 5: RDS in Private Subnet</h4><p>PostgreSQL RDS with:</p><ul><li>Public access: No</li><li>Subnet group: private</li><li>Security group: DB SG</li></ul><p>No public endpoint exposure.</p><p>I hope this breakdown helps you navigate the complexities of VPC networking and security group chaining. Cloud security can be tricky, but getting your hands dirty with private subnets and load balancers is the best way to learn.</p><p><strong>Let’s connect!</strong> Did you run into any issues with your NAT Gateway or RDS connectivity? Let me know in the comments, or reach out on<a href="https://www.linkedin.com/feed/"> linkedin</a>/<a href="https://x.com/nidhish30_10">x</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98a2f26d5d14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS CloudWatch Monitoring for EC2]]></title>
            <link>https://medium.com/@nidhishprofessional/aws-cloudwatch-monitoring-for-ec2-5b9908074853?source=rss-aaf931e99f2a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b9908074853</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloudwatch-agent]]></category>
            <category><![CDATA[aws-cloudwatch]]></category>
            <dc:creator><![CDATA[Nidhish]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 19:45:43 GMT</pubDate>
            <atom:updated>2025-11-24T19:45:43.811Z</atom:updated>
            <content:encoded><![CDATA[<p>Struggling to monitor <strong>custom</strong> EC2 metrics like disk usage, memory, swap and free memory because they’re not included in the default metrics? Stop wrestling with ad-hoc scripts and fragile IAM users.</p><p><strong>Solution:</strong> install the Amazon CloudWatch Agent on the instance. Give the agent an <strong>IAM role</strong> (not an IAM user) with the managed CloudWatch permissions, install the agent, and start shipping custom metrics. From there you can build dashboards and alarms.</p><p>Here is the step by step guide —</p><ol><li>Select the instance you want to attach cloudwatch agent and click on modify IAM role</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tE0y0GuOQ4011HS0wzpkZw.png" /></figure><p>Click on Create new IAM role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sVcJaUCBO_LJd6rQWMX2Mg.png" /></figure><p>2. Search “EC2CloudWatchAgentRole” and check the box of the result and click on Create Role button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X_jSrgXRRWwXM6l6Wn7sBw.png" /></figure><p>3. Choose Select trusted entity as AWS Service and Use case as EC2 then click on next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEtMNmuk3QZT7_JSKwGeMw.png" /></figure><p>Keep everything as it is in Add permissions page and click on next.In Step 3,name your role and give a description and just click on Create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9rdRFnO7ZWmN_NGlo6wmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WhspVg2wiLIprSrEsqfIRA.png" /></figure><p>4. Now IAM role for the cloudwatch agent is created so you can attach it to ec2 instance on that page where we clicked on Select IAM role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4BenSyPDDFR-vW_QEIHeNA.png" /></figure><p>Now let me share you the list of commands required for setting up the Amazon Cloudwatch agent inside the instance.</p><h3>Complete CloudWatch Agent Commands for Linux (Amazon Linux, Ubuntu, Debian, RHEL, CentOS)</h3><h4>1. Install CloudWatch Agent</h4><p>Amazon Linux 2 / Amazon Linux 1 / RHEL / CentOS</p><pre>sudo yum install -y amazon-cloudwatch-agent</pre><p>Ubuntu / Debian</p><pre>sudo apt-get update<br>sudo apt-get install -y amazon-cloudwatch-agent</pre><h4>2. Install collectd (Optional — For Additional Metrics)</h4><p>Amazon Linux 2 / RHEL / CentOS</p><pre>sudo yum install -y collectd</pre><p>Ubuntu / Debian</p><pre>sudo apt-get install -y collectd</pre><h4>3. Run CloudWatch Agent Configuration Wizard</h4><pre>sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard</pre><p>This generates a config file, usually located at:</p><pre>/opt/aws/amazon-cloudwatch-agent/bin/config.json</pre><h4>4. Start CloudWatch Agent With Local Config</h4><pre>sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \<br>  -a fetch-config \<br>  -m ec2 \<br>  -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json \<br>  -s</pre><h4>5. Manage the CloudWatch Agent (systemd)</h4><p>Start:</p><pre>sudo systemctl start amazon-cloudwatch-agent</pre><p>Restart:</p><pre>sudo systemctl restart amazon-cloudwatch-agent</pre><p>Stop:</p><pre>sudo systemctl stop amazon-cloudwatch-agent</pre><p>Enable on boot:</p><pre>sudo systemctl enable amazon-cloudwatch-agent</pre><p>Disable:</p><pre>sudo systemctl disable amazon-cloudwatch-agent</pre><h4>6. Check Agent Status</h4><pre>sudo systemctl status amazon-cloudwatch-agent</pre><h4>7. Validate Your Config File</h4><pre>sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \<br>  -a validate-config \<br>  -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json</pre><h4>8. View CloudWatch Agent Logs</h4><pre>sudo tail -f /opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log</pre><h4>9. Uninstall CloudWatch Agent</h4><p>Amazon Linux / RHEL / CentOS</p><pre>sudo yum remove amazon-cloudwatch-agent -y</pre><p>Ubuntu / Debian</p><pre>sudo apt-get remove amazon-cloudwatch-agent -y</pre><p>Your will status of cloudwatch agent as this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*41g0Z2tHui7qLHoF1spRvw.png" /></figure><p>Now when you create dashboard and select metric CWAgent will pop up</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sQMt2zVw7LcrZBw3PF_T4A.png" /></figure><p>Now you can create Alarms of the metrics you want. Create sns topic where email will be sent when alarm is triggered or trigger a lambda action or do some action on the ec2 instance itself like turning it off</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qoyxRqP0jZGq5sSfuD7ZAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pF4Gmbvk_pQ-UOH-8ySdEQ.png" /></figure><p>You will get alarm like -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ymf4viGMvqOREw-BrCqyPA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b9908074853" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>