<?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 Suraj B on Medium]]></title>
        <description><![CDATA[Stories by Suraj B on Medium]]></description>
        <link>https://medium.com/@sriman.suraj1?source=rss-92840cdeb8e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ojhdHFkJ8TSHgZ2l5FETCg.jpeg</url>
            <title>Stories by Suraj B on Medium</title>
            <link>https://medium.com/@sriman.suraj1?source=rss-92840cdeb8e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 06:29:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sriman.suraj1/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[ Multi‑Agent AI with Gemini & MCP: Secure, Tenant‑Aware Intelligence for Real‑World Systems]]></title>
            <link>https://medium.com/@sriman.suraj1/multi-agent-ai-with-gemini-mcp-secure-tenant-aware-intelligence-for-real-world-systems-167f42f27cdc?source=rss-92840cdeb8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/167f42f27cdc</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[fastapi]]></category>
            <dc:creator><![CDATA[Suraj B]]></dc:creator>
            <pubDate>Thu, 02 Jul 2026 08:43:59 GMT</pubDate>
            <atom:updated>2026-07-02T08:53:26.545Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern enterprises don’t just need “an AI model” — they need <strong>multiple intelligent agents</strong> that can reason independently over <strong>isolated data domains</strong> while keeping tenants secure and workloads scalable.</p><p>This project demonstrates exactly that.</p><p>It is a <strong>production-ready Multi-Agent AI Architecture</strong> using Gemini, MCP, FastAPI, and PostgreSQL multi‑schema isolation — built for hospitals, banks, and SaaS platforms needing secure tenant‑aware intelligence.</p><p>👉 GitHub: <a href="https://github.com/suraj143/ai-multi-agent-fastapi-mcp-db">https://github.com/suraj143/ai-multi-agent-fastapi-mcp-db</a></p><h3>🔍 Why Multi‑Agent AI Matters</h3><p>Enterprises across <strong>healthcare, banking, and SaaS</strong> deal with <strong>strict data isolation</strong>, <strong>multiple tenants</strong>, and <strong>domain‑specific intelligence</strong>. A single LLM cannot safely or efficiently handle all domains.</p><p>Multi‑agent architecture solves this by enabling:</p><ul><li>Secure multi‑tenant isolation</li><li>Independent domain‑specific agents</li><li>LLM‑powered reasoning</li><li>Dynamic task routing</li><li>Scalable microservices deployment</li></ul><h3>🧠 Core Components: Gemini 1.5 Flash — The Reasoning Brain</h3><p>Gemini acts as the central intelligence layer:</p><ul><li>Detects intent</li><li>Selects the correct agent</li><li>Interprets agent responses</li><li>Synthesizes final insights</li></ul><h3>MCP Agents — Independent Domain Experts</h3><p>Each agent:</p><ul><li>Connects to its own PostgreSQL schema</li><li>Performs schema‑specific analysis</li><li>Maintains contextual memory</li><li>Operates independently</li></ul><h3>AI Orchestrator — The Router</h3><p>The orchestrator:</p><ul><li>Receives incoming requests</li><li>Uses Gemini to evaluate intent</li><li>Routes tasks to AgentA or AgentB</li><li>Aggregates and refines results</li></ul><h3>FastAPI Gateway — Unified Entry Point</h3><p>FastAPI provides:</p><ul><li>High‑performance REST API</li><li>Async request handling</li><li>Single endpoint for all clients</li></ul><h3>PostgreSQL Multi‑Schema Isolation</h3><p>One database, multiple schemas:</p><ul><li>schema1 → AgentA</li><li>schema2 → AgentB</li></ul><p>This ensures <strong>tenant separation</strong> without extra infrastructure cost.</p><h3>Dockerized Deployment</h3><p>All components run in containers:</p><pre>docker compose up --build</pre><h3>🏗 System Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6bW6NVih97OIbmH-4sB8Xw.png" /></figure><pre>FastAPI (Public API)<br>       │<br>       ▼<br>AI Orchestrator (Gemini Reasoning)<br>       │<br> ┌─────┴─────┐<br> ▼           ▼<br>AgentA     AgentB<br>(schema1)  (schema2)<br>       │<br>       ▼<br>PostgreSQL (Single DB, Multiple Schemas)</pre><h3>🌍 Real‑World Industry Examples</h3><h3>🏥 Healthcare (Hospitals)</h3><p><strong>Problem:</strong> Each hospital must keep patient data isolated.</p><p><strong>Solution:</strong></p><ul><li>Hospital A → schema1</li><li>Hospital B → schema2</li></ul><p>A doctor asks: <em>“Summarize 30‑day readmission risk for patient X.”</em></p><p>The orchestrator routes to the correct hospital agent, which:</p><ul><li>Fetches patient data</li><li>Analyzes risk using Gemini</li><li>Returns insights <strong>without exposing other hospitals’ data</strong></li></ul><p><strong>Outcome:</strong> HIPAA‑friendly, tenant‑aware AI analytics.</p><h3>🏦 Banking &amp; Finance</h3><p><strong>Problem:</strong> Retail and corporate banking must remain isolated.</p><p><strong>Solution:</strong></p><ul><li>Retail Banking → schema1</li><li>Corporate Banking → schema2</li></ul><p>A manager asks: <em>“Generate a risk and opportunity summary for client Y.”</em></p><p>The correct agent:</p><ul><li>Pulls transactions</li><li>Analyzes credit patterns</li><li>Generates risk scores using Gemini</li></ul><p><strong>Outcome:</strong> Regulatory‑safe financial intelligence.</p><h3>💻 IT &amp; SaaS Multi‑Tenant Platforms</h3><p><strong>Problem:</strong> Each customer requires isolated analytics.</p><p><strong>Solution:</strong></p><ul><li>Company A → schema1</li><li>Company B → schema2</li></ul><p>A product owner asks: <em>“Show usage anomalies and churn risk for this tenant.”</em></p><p>The agent:</p><ul><li>Reads logs</li><li>Detects anomalies</li><li>Generates churn insights</li></ul><p><strong>Outcome:</strong> Scalable multi‑tenant AI without cross‑customer leakage.</p><h3>🔄 Real‑Time Data Flow</h3><p>Code</p><pre>Client<br>  │<br>  ▼<br>POST /insights (FastAPI)<br>  │<br>  ▼<br>AI Orchestrator → Gemini Intent Analysis<br>  │<br>  ├──► AgentA (schema1)<br>  └──► AgentB (schema2)<br>        │<br>        ▼<br>Orchestrator → Gemini Final Reasoning<br>  │<br>  ▼<br>FastAPI → Client</pre><h3>📦 Explore the Project</h3><p>⭐ GitHub Repository: <a href="https://github.com/suraj143/ai-multi-agent-fastapi-mcp-db">https://github.com/suraj143/ai-multi-agent-fastapi-mcp-db</a></p><p>This architecture is ideal for <strong>enterprise AI platforms</strong>, <strong>intelligent assistants</strong>, and <strong>secure multi‑tenant applications</strong>.</p><p>#ArtificialIntelligence #AgenticAI #MultiAgentAI #GeminiAI #FastAPI #Python #MCP #SoftwareArchitecture #PostgreSQL #EnterpriseAI #Microservices #Docker #CloudNative #GenerativeAI #LLM</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=167f42f27cdc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ HTTP Status Codes — Quick Guide]]></title>
            <link>https://medium.com/@sriman.suraj1/http-status-codes-quick-guide-d551b514af0f?source=rss-92840cdeb8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d551b514af0f</guid>
            <dc:creator><![CDATA[Suraj B]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 06:28:30 GMT</pubDate>
            <atom:updated>2026-01-13T06:28:30.129Z</atom:updated>
            <content:encoded><![CDATA[<p>🌐 HTTP Status Codes — Quick Guide</p><p>APIs communicate through status codes. Knowing them helps you debug faster and build cleaner systems.</p><p>🔵 2xx — Success <br>Everything worked.</p><p>🟡 3xx — Redirect <br>Follow a new path.</p><p>🔴 4xx — Client Error <br>Fix your request.</p><p>🔥 5xx — Server Error <br>Server failed to process a valid request.</p><p>Simple rule: <br>4xx = Your mistake <br>5xx = Server’s mistake<br>🌐 HTTP Status Codes — Quick Guide</p><p>APIs communicate through status codes. Knowing them helps you debug faster and build cleaner systems.</p><p>🔵 2xx — Success <br>Everything worked.</p><p>🟡 3xx — Redirect <br>Follow a new path.</p><p>🔴 4xx — Client Error <br>Fix your request.</p><p>🔥 5xx — Server Error <br>Server failed to process a valid request.</p><p>Simple rule: <br>4xx = Your mistake <br>5xx = Server’s mistake</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d551b514af0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ How We Reduced AWS EKS Infrastructure Costs by 80% Without Sacrificing Reliability]]></title>
            <link>https://aws.plainenglish.io/how-we-reduced-aws-eks-infrastructure-costs-by-80-without-sacrificing-reliability-de160716c3f6?source=rss-92840cdeb8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/de160716c3f6</guid>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[karpenter]]></category>
            <category><![CDATA[cloud-cost-optimization]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws-eks]]></category>
            <dc:creator><![CDATA[Suraj B]]></dc:creator>
            <pubDate>Sun, 28 Dec 2025 16:32:19 GMT</pubDate>
            <atom:updated>2026-01-19T06:45:29.969Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_c0161syfvenbKpk.png" /></figure><p>Cloud costs have become one of the biggest pain points for engineering teams. As workloads scale, the default reaction is often to throw more compute at the problem. But more nodes, more clusters, and more autoscaling rarely translate to better efficiency — just higher bills.</p><p>In our case, we decided to challenge that mindset.</p><p>Instead of asking <em>“How do we provision more?”</em> we asked a different question: <strong>“When do we actually need resources?”</strong></p><p>This shift in thinking led us to redesign our Kubernetes infrastructure on AWS EKS — and the result was dramatic:</p><p>👉 <strong>80% reduction in monthly infrastructure costs</strong> 👉 <strong>Zero impact on SLAs or application reliability</strong></p><p>Here’s the technical breakdown of how we achieved it.</p><h3>🔍 Rethinking Kubernetes Scaling: Focus on When, Not How Much</h3><p>Traditional autoscaling strategies assume that workloads grow linearly and that provisioning more nodes is the safest path. But in reality, most workloads have predictable patterns, idle periods, and opportunities for smarter scheduling.</p><p>We performed a systematic analysis of:</p><ul><li>Workload behavior</li><li>Queue depth patterns</li><li>Node utilization</li><li>Interruption tolerance</li><li>Provisioning latency</li></ul><p>This allowed us to design a platform that scales <strong>intelligently</strong>, not aggressively.</p><h3>🧩 The Three Architectural Decisions That Changed Everything</h3><h3>1️⃣ Switching from Cluster Autoscaler to Karpenter</h3><p><strong>Provisioning time: 5+ minutes → under 45 seconds</strong></p><p>Cluster Autoscaler works, but it’s slow and tied to node groups. Karpenter, on the other hand, provisions nodes <em>just in time</em> based on actual pod requirements.</p><h3>Why Karpenter made the difference:</h3><ul><li>⚡ Ultra‑fast node provisioning</li><li>📦 Efficient bin‑packing for better resource utilization</li><li>🧹 No need for large pre‑provisioned node groups</li><li>🎯 Instance types selected dynamically based on workload needs</li></ul><p>This alone eliminated a huge amount of idle capacity.</p><h3>2️⃣ Event‑Driven Autoscaling with KEDA</h3><p><strong>40% reduction in compute waste</strong></p><p>Most teams use cron‑based scaling or CPU‑based HPA triggers. But these don’t reflect real workload demand.</p><p>We replaced them with <strong>KEDA</strong>, which scales based on <em>actual queue depth</em>.</p><h3>What changed:</h3><ul><li>🌙 <strong>Scale‑to‑zero</strong> during off‑peak hours</li><li>📉 Real‑time scaling based on message queues</li><li>🔄 No more arbitrary schedules</li><li>💡 Workloads scale only when work exists</li></ul><p>This was one of the biggest contributors to cost savings.</p><h3>3️⃣ Spot‑First Strategy with Intelligent Fallback</h3><p><strong>70% of workloads now run on Spot Instances</strong></p><p>Spot Instances are cheap — but risky. The key is knowing which workloads can tolerate interruptions.</p><h3>Our approach:</h3><ul><li>🧪 Classified workloads by interruption tolerance</li><li>🔄 Built automatic fallback to On‑Demand</li><li>🛡️ Ensured graceful shutdown + checkpointing</li><li>📊 Monitored Spot availability patterns</li></ul><p>The result: Massive savings with zero reliability trade‑offs.</p><h3>📊 The Outcome: Same SLAs, 80% Lower Cost</h3><p>After implementing these changes, we achieved:</p><ul><li>⚙️ <strong>No degradation in performance</strong></li><li>🛡️ <strong>No change in reliability SLAs</strong></li><li>💰 <strong>80% reduction in monthly AWS EKS spend</strong></li><li>📈 <strong>Higher cluster efficiency and faster scaling</strong></li></ul><p>This wasn’t about cutting corners — it was about engineering smarter.</p><h3>🛠️ Technical Implementation</h3><p>If you want to explore the full implementation, including:</p><ul><li>Karpenter provisioner configs</li><li>KEDA ScaledObjects</li><li>Spot instance strategies</li><li>Consolidation policies</li><li>Observability setup</li></ul><p>You can find the complete reference architecture here:</p><p>👉 <strong>GitHub Repository:</strong> <a href="https://github.com/suraj143/eks-autonomous-platform">https://github.com/suraj143/eks-autonomous-platform</a></p><p><a href="https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/examples/karpenter/README.md">https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/examples/karpenter/README.md</a></p><h3>🎯 Final Thoughts</h3><p>Cloud efficiency isn’t about spending less — it’s about spending <em>intelligently</em>. By focusing on <strong>timing</strong>, <strong>workload behavior</strong>, and <strong>automation</strong>, we built an EKS platform that is:</p><ul><li>Faster</li><li>Cheaper</li><li>More resilient</li><li>Easier to operate</li></ul><p>If you’re exploring Kubernetes cost optimization or designing autonomous cloud platforms, this approach can be a game‑changer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de160716c3f6" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/how-we-reduced-aws-eks-infrastructure-costs-by-80-without-sacrificing-reliability-de160716c3f6">🚀 How We Reduced AWS EKS Infrastructure Costs by 80% Without Sacrificing Reliability</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrate On-Prem Apps to AWS EC2 with Full VPC, RDS, and Route53 Setup]]></title>
            <link>https://medium.com/@sriman.suraj1/migrate-on-prem-apps-to-aws-ec2-with-full-vpc-rds-and-route53-setup-1812cbfbbc0d?source=rss-92840cdeb8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1812cbfbbc0d</guid>
            <category><![CDATA[aws-infrastructure]]></category>
            <category><![CDATA[ec2-and-rds-setup]]></category>
            <category><![CDATA[devops-automation]]></category>
            <category><![CDATA[aws-cli]]></category>
            <category><![CDATA[cloud-migration]]></category>
            <dc:creator><![CDATA[Suraj B]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 20:17:49 GMT</pubDate>
            <atom:updated>2025-07-07T20:24:58.683Z</atom:updated>
            <content:encoded><![CDATA[<h3>On-Prem to AWS Cloud Migration</h3><p>Infrastructure Setup Guide (AWS EC2 + VPC + RDS + Route53)</p><p>📘 <strong>Overview</strong><br>This guide walks through the DIY setup of cloud infrastructure for migrating an on-premises multi-tier application to AWS, focusing purely on provisioning resources and installing system dependencies like nginx, redis, rabbitmq, and PostgreSQL client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*J78O5Yf14IO4bzyZ.png" /></figure><p><strong>The migration will:</strong></p><ul><li>Provision secure AWS infrastructure using the <strong>AWS CLI</strong></li><li>EC2 instance(s) to replace on-prem app servers</li><li>Install necessary packages (Node.js, PM2, Redis, RabbitMQ)</li><li>Set up PostgreSQL using Amazon RDS</li><li>Configure Route53 DNS failover from an On-Prem primary server to AWS EC2 secondary</li></ul><p>✅ <strong>Prerequisites:</strong><br>Before executing the script:</p><ul><li>AWS CLI v2 installed and configured with a user that has permissions for:<br>EC2, IAM, VPC, RDS, Route53</li><li>An existing Route53 hosted zone (e.g., example1.org.com)</li><li>A registered SSH key pair in AWS EC2 (my-key-pair)</li><li>A valid Ubuntu AMI ID in the ap-southeast-1 region</li><li>Custom SSL Certificates (optional) already available in your EC2 config path (e.g., /etc/nginx/ssl/)</li><li>Replace all &lt;placeholders&gt; in the script path (e.g., /etc/nginx/ssl/)</li><li>Replace placeholders like &lt;vpc-id&gt;, &lt;zone-id&gt;, &lt;ami-id&gt; before running.</li><li>You may use this script to bootstrap staging or test environments too.</li></ul><h3>🔑 IAM Setup</h3><ol><li>Create IAM user for EC2 automation:</li></ol><pre>aws iam create-user --user-name MyAppEC2User<br>aws iam attach-user-policy --user-name MyAppEC2User --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess<br>aws iam create-access-key --user-name MyAppEC2User</pre><h3>🌐 VPC and Network Setup</h3><p>Creates a private VPC with:</p><ul><li><strong>1 Public Subnet</strong> (10.0.1.0/24)</li><li><strong>1 Private Subnet</strong> (10.0.2.0/24)</li><li>Internet Gateway</li><li>Public Route Table</li><li>Elastic IP (for NAT or public EC2)</li></ul><pre># VPC<br>aws ec2 create-vpc --cidr-block 10.0.0.0/16</pre><pre> Subnets<br>aws ec2 create-subnet --vpc-id &lt;vpc-id&gt; --cidr-block 10.0.1.0/24 --availability-zone ap-southeast-1a<br>aws ec2 create-subnet --vpc-id &lt;vpc-id&gt; --cidr-block 10.0.2.0/24 --availability-zone ap-southeast-1a</pre><pre># Internet Gateway + Route Table<br>aws ec2 create-internet-gateway<br>aws ec2 create-route-table --vpc-id &lt;vpc-id&gt;<br>aws ec2 create-route --route-table-id &lt;rtb-id&gt; --destination-cidr-block 0.0.0.0/0 --gateway-id &lt;igw-id&gt;</pre><h3>🔐 Security Group</h3><p>Allows basic access:</p><ul><li>SSH (22)</li><li>HTTP (80)</li><li>HTTPS (443)</li></ul><pre>aws ec2 create-security-group --group-name myapp-sg --description &quot;App SG&quot; --vpc-id &lt;vpc-id&gt;<br>aws ec2 authorize-security-group-ingress --group-id &lt;sg-id&gt; --protocol tcp --port 22 --cidr 0.0.0.0/0<br>aws ec2 authorize-security-group-ingress --group-id &lt;sg-id&gt; --protocol tcp --port 80 --cidr 0.0.0.0/0<br>aws ec2 authorize-security-group-ingress --group-id &lt;sg-id&gt; --protocol tcp --port 443 --cidr 0.0.0.0/0</pre><h3>💻 EC2 Launch with Preinstalled Packages</h3><p>Launches an EC2 instance and installs:</p><ul><li>Nginx</li><li>Node.js, npm</li><li>PM2</li><li>Redis</li><li>RabbitMQ</li><li>PostgreSQL Client</li></ul><pre>USER_DATA=$(cat &lt;&lt;&#39;EOF&#39;<br>#!/bin/bash<br>apt update -y<br>apt install -y nginx nodejs npm redis-server rabbitmq-server postgresql-client<br>npm install pm2 -g<br>EOF<br>)</pre><pre>aws ec2 run-instances \<br>  --image-id &lt;ubuntu-ami&gt; \<br>  --instance-type t3.medium \<br>  --key-name my-key-pair \<br>  --security-group-ids &lt;sg-id&gt; \<br>  --subnet-id &lt;subnet-id&gt; \<br>  --associate-public-ip-address \<br>  --user-data \&quot;$USER_DATA\&quot; \<br>  --tag-specifications &#39;ResourceType=instance,Tags=[{Key=Name,Value=MyAppEC2}]&#39;</pre><h3>🌍 Route53 Failover DNS Setup</h3><p>Configure failover from <strong>On-Prem</strong> to <strong>EC2</strong>:</p><pre># EC2 Secondary Record<br>aws route53 change-resource-record-sets --hosted-zone-id &lt;zone-id&gt; --change-batch &#39;{<br>  &quot;Changes&quot;: [{<br>    &quot;Action&quot;: &quot;UPSERT&quot;,<br>    &quot;ResourceRecordSet&quot;: {<br>      &quot;Name&quot;: &quot;app.example1.org.com&quot;,<br>      &quot;Type&quot;: &quot;A&quot;,<br>      &quot;SetIdentifier&quot;: &quot;Secondary&quot;,<br>      &quot;Failover&quot;: &quot;SECONDARY&quot;,<br>      &quot;TTL&quot;: 300,<br>      &quot;ResourceRecords&quot;: [{&quot;Value&quot;: &quot;&lt;ec2-public-ip&gt;&quot;}]<br>    }<br>  }]<br>}&#39;</pre><pre># On-Prem Primary Record<br>aws route53 change-resource-record-sets --hosted-zone-id &lt;zone-id&gt; --change-batch &#39;{<br>  &quot;Changes&quot;: [{<br>    &quot;Action&quot;: &quot;UPSERT&quot;,<br>    &quot;ResourceRecordSet&quot;: {<br>      &quot;Name&quot;: &quot;app.example1.org.com&quot;,<br>      &quot;Type&quot;: &quot;A&quot;,<br>      &quot;SetIdentifier&quot;: &quot;Primary&quot;,<br>      &quot;Failover&quot;: &quot;PRIMARY&quot;,<br>      &quot;TTL&quot;: 300,<br>      &quot;ResourceRecords&quot;: [{&quot;Value&quot;: &quot;&lt;onprem-ip&gt;&quot;}]<br>    }<br>  }]<br>}&#39;</pre><h3>🛢 PostgreSQL RDS Instance</h3><p>Create PostgreSQL with <strong>monthly backups (30 days)</strong>:</p><pre>aws rds create-db-subnet-group \<br>  --db-subnet-group-name myapp-db-subnet \<br>  --db-subnet-group-description &quot;DB subnet group&quot; \<br>  --subnet-ids &lt;private-subnet-id&gt;</pre><pre>aws rds create-db-instance \<br>  --db-instance-identifier myapp-db \<br>  --db-instance-class db.t3.medium \<br>  --engine postgres \<br>  --master-username admin \<br>  --master-user-password StrongPass123 \<br>  --allocated-storage 20 \<br>  --vpc-security-group-ids &lt;sg-id&gt; \<br>  --db-subnet-group-name myapp-db-subnet \<br>  --backup-retention-period 30 \<br>  --no-publicly-accessible</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1812cbfbbc0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS RDS PostgreSQL HA/DR Setup with Cross-Region Replication]]></title>
            <link>https://medium.com/@sriman.suraj1/aws-rds-postgresql-ha-dr-setup-with-cross-region-replication-f05f4f1cb168?source=rss-92840cdeb8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f05f4f1cb168</guid>
            <category><![CDATA[high-availability]]></category>
            <category><![CDATA[zero-downtime-failovers]]></category>
            <category><![CDATA[disaster-recovery]]></category>
            <category><![CDATA[aws-rds]]></category>
            <category><![CDATA[cross-region-replication]]></category>
            <dc:creator><![CDATA[Suraj B]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 19:14:57 GMT</pubDate>
            <atom:updated>2025-07-07T19:14:57.427Z</atom:updated>
            <content:encoded><![CDATA[<p>This document provides a detailed guide for designing and implementing a highly available and disaster recovery (HA/DR) setup for Amazon RDS PostgreSQL.</p><p><strong>Deploy a highly available PostgreSQL database with:</strong></p><ul><li>Primary Cluster: Multi-AZ (us-west-1) + Async Read Replica</li><li>Disaster Recovery: Cross-region async replica (ap-southeast-1)</li><li>Automated Failover: Route 53 DNS routing</li></ul><h3><strong>Architecture Overview:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RPzEUdIJPpFXVb1K" /></figure><h3>Task 1: Primary Cluster Deployment</h3><blockquote><em>🔐 </em><strong><em>Note:</em></strong><em> This setup is designed for a production database. Access is tightly restricted to your office public IP and VPC-based applications only.</em></blockquote><h4>1.1 Create VPC in us-west-1</h4><pre>aws ec2 create-vpc --cidr-block 10.0.0.0/16</pre><h4>1.2 Create Subnets (Multi-AZ + App Access)</h4><blockquote><em>📶 Include private subnets for EC2 applications and configure appropriate route tables/NAT as needed for access.</em></blockquote><pre>aws ec2 create-subnet --vpc-id &lt;vpc-id&gt; --cidr-block 10.0.1.0/24 --availability-zone us-west-1a<br>aws ec2 create-subnet --vpc-id &lt;vpc-id&gt; --cidr-block 10.0.2.0/24 --availability-zone us-west-1b</pre><h4>1.3 Launch RDS PostgreSQL with Multi-AZ (Production Setup — Restricted Access)</h4><blockquote><em>🛡️ </em><strong><em>Security Note:</em></strong><em> For production environments, the RDS instance must be locked down to allow connections only from trusted IPs (e.g., office network) and within the VPC for application access.</em></blockquote><pre>aws rds create-db-instance \<br>  --db-instance-identifier project-db-primary \<br>  --db-instance-class db.m5.large \<br>  --engine postgres \<br>  --allocated-storage 100 \<br>  --master-username admin \<br>  --master-user-password &lt;password&gt; \<br>  --multi-az \<br>  --availability-zone us-west-1a \<br>  --vpc-security-group-ids sg-office-access \<br>  --db-subnet-group-name &lt;subnet-group&gt;</pre><h4>1.4 Create Read Replica in us-west-1c</h4><pre>aws rds create-db-instance-read-replica \<br>  --db-instance-identifier project-db-replica-west \<br>  --source-db-instance-identifier project-db-primary \<br>  --availability-zone us-west-1c</pre><h3>Task 2: DR Setup &amp; Failover Configuration</h3><h4>2.1 VPC in ap-southeast-1 + Peering</h4><pre>aws ec2 create-vpc --cidr-block 10.1.0.0/16<br>aws ec2 create-subnet --vpc-id &lt;vpc-id&gt; --cidr-block 10.1.1.0/24 --availability-zone ap-southeast-1a<br>aws ec2 create-subnet --vpc-id &lt;vpc-id&gt; --cidr-block 10.1.2.0/24 --availability-zone ap-southeast-1b<br>aws ec2 create-vpc-peering-connection --vpc-id &lt;vpc-west&gt; --peer-vpc-id &lt;vpc-sg&gt; --peer-region ap-southeast-1</pre><h4>2.2 Create Cross-Region Replica</h4><pre>aws rds create-db-instance-read-replica \<br>  --db-instance-identifier project-db-dr-sg \<br>  --source-db-instance-identifier project-db-primary \<br>  --region ap-southeast-1</pre><h4>2.3 Route 53 DNS Failover</h4><ol><li><strong>Create Health Checks:</strong></li></ol><ul><li>Navigate to Route 53 &gt; Health Checks</li><li>Create a health check for the <strong>primary RDS endpoint</strong> using TCP on port 5432</li><li>Create a second health check for the <strong>DR replica endpoint</strong> (also TCP on 5432)</li></ul><p><strong>2. Create a Hosted Zone:</strong></p><ul><li>Go to Route 53 &gt; Hosted Zones &gt; Create Hosted Zone</li><li>Enter the domain name project_name.com</li></ul><p><strong>3. Create Primary DNS Record:</strong></p><ul><li>Record type: CNAME</li><li>Name: db.project_name.com</li><li>Value: RDS primary endpoint</li><li>Routing policy: <strong>Failover</strong></li><li>Failover type: <strong>Primary</strong></li><li>Associate with primary health check</li></ul><p><strong>4. Create Secondary DNS Record:</strong></p><ul><li>Record type: CNAME</li><li>Name: db.project_name.com</li><li>Value: RDS DR replica endpoint</li><li>Routing policy: <strong>Failover</strong></li><li>Failover type: <strong>Secondary</strong></li><li>Associate with DR health check</li></ul><p><strong>5. Test Failover:</strong></p><ul><li>Temporarily stop the primary DB instance (or its health check)</li><li>Confirm DNS fails over to the DR endpoint by resolving db.project_name.com</li></ul><h3>🔍 Validation Commands</h3><h3>Check Replication Status (Primary)</h3><pre>SELECT * FROM pg_stat_replication;</pre><h3>Check DR Lag (on DR replica)</h3><pre>SELECT now() - pg_last_xact_replay_timestamp() AS replication_lag;</pre><h3>Simulate Failover (Manual)</h3><pre>aws rds reboot-db-instance --db-instance-identifier project-db-primary --force-failover</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f05f4f1cb168" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Automated Terraform Deployment with Jenkins on AWS]]></title>
            <link>https://medium.com/@sriman.suraj1/automated-terraform-deployment-with-jenkins-on-aws-09fb84f0873b?source=rss-92840cdeb8e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/09fb84f0873b</guid>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Suraj B]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 09:28:40 GMT</pubDate>
            <atom:updated>2025-07-07T09:37:58.436Z</atom:updated>
            <content:encoded><![CDATA[<p>In this guide, we’ll walk through how to use <strong>Terraform</strong>, a powerful Infrastructure as Code (IaC) tool, to <strong>automate the deployment of Jenkins on AWS</strong>, enabling faster, scalable, and repeatable setups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mEGQv_rdJdS3eFxg.png" /></figure><h3>🔧 Architecture Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mOMQ6A6mYJDmwPunlkvENg.png" /></figure><h3>🛠️ Terraform Automation Steps</h3><p>Step1: main.tf</p><pre>resource &quot;aws_instance&quot; &quot;jenkins&quot; {<br>  ami                         = var.ami_id<br>  instance_type               = var.instance_type<br>  key_name                    = var.key_name<br>  associate_public_ip_address = true<br>  vpc_security_group_ids      = [aws_security_group.jenkins-sg.id]<br>  user_data                   = file(&quot;jenkins_script.sh&quot;)<br><br>  tags = {<br>    Name = &quot;Jenkins-Server3&quot;<br>  }<br><br>}<br><br><br>resource &quot;aws_security_group&quot; &quot;jenkins-sg&quot; {<br>  name        = var.security_group_name<br>  description = &quot;Allow Port 22 and 8080&quot;<br><br>  ingress {<br>    description = &quot;Allow SSH Traffic&quot;<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [var.my_ip]<br>  }<br><br>  ingress {<br>    description = &quot;Allow HTTPS Traffic&quot;<br>    from_port   = 443<br>    to_port     = 443<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  ingress {<br>    description = &quot;Allow 8080 Traffic&quot;<br>    from_port   = 8080<br>    to_port     = 8080<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br>}<br><br>resource &quot;aws_s3_bucket&quot; &quot;jenkins-artifact&quot; {<br>  bucket = var.bucket<br>  key    = &quot;jenkins/terraform.tfstate&quot;<br>  tags = {<br>    Name = &quot;Jenkins-artifact&quot;<br>  }<br>}<br><br>resource &quot;aws_s3_bucket_ownership_controls&quot; &quot;s3_bucket_acl_ownership&quot; {<br>  bucket = aws_s3_bucket.jenkins-artifact.id<br>  rule {<br>    object_ownership = &quot;ObjectWriter&quot;<br>  }<br>}</pre><p>provider.tf</p><pre>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 4.0&quot;<br>    }<br>  }<br>}<br><br># Configure the AWS Provider<br>provider &quot;aws&quot; {<br>  region = var.aws_region<br>}</pre><p>variables.tf</p><pre>variable &quot;aws_region&quot; {<br>  default = &quot;us-east-1&quot;<br>  type    = string<br>}<br><br>variable &quot;ami_id&quot; {<br>  default = &quot;ami-0df8c184d5f6ae949&quot;<br>  type    = string<br>}<br><br>variable &quot;security_group_name&quot; {<br>  description = &quot;The name of the security group.&quot;<br>  default     = &quot;jenkins-sg&quot;<br>  type        = string<br>}<br><br>variable &quot;my_ip&quot; {<br>  default   = &quot;xx.xxx.xx.xx/32&quot;<br>  type      = string<br>  sensitive = true<br>}<br><br>variable &quot;instance_type&quot; {<br>  default = &quot;t2.micro&quot;<br>  type    = string<br>}<br><br>variable &quot;key_name&quot; {<br>  default = &quot;AOkey&quot;<br>  type    = string<br>}<br><br>variable &quot;bucket&quot; {<br>  default = &quot;jenkins-artifact-444xyz&quot;<br>  type    = string<br>}</pre><h4>Jenkins Server Setup</h4><p>jenkins_script.sh</p><pre>#!/bin/bash<br>sudo yum update -y<br>sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo<br>sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key<br>sudo yum upgrade -y<br>sudo dnf install java-17-amazon-corretto -y<br>sudo yum install jenkins -y<br>sudo systemctl enable jenkins<br>sudo systemctl start jenkins<br>sudo systemctl status jenkins</pre><p>After deployment, visit http://&lt;EC2-PUBLIC-IP&gt;:8080 to access Jenkins. You can find the initial admin password at /var/lib/jenkins/secrets/initialAdminPassword</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ZQURgEqM8W6TTAVd1oiCg.png" /></figure><h4>2. Configure Jenkins for Terraform</h4><p>Install Plugins:</p><ul><li>Terraform Plugin: Manage Terraform versions.</li><li>AWS Credentials Plugin: Securely store AWS keys.</li></ul><h4>AWS IAM Permissions for Terraform:</h4><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;ec2:*&quot;,<br>        &quot;s3:*&quot;,<br>        &quot;iam:*&quot;,<br>        &quot;dynamodb:*&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;*&quot;<br>    }<br>  ]<br>}</pre><p><strong>Add AWS Credentials to Jenkins:</strong><br>. Navigate to Jenkins Dashboard &gt; Credentials &gt; System &gt; Global Credentials.<br>. Add AWS ACCESS_KEY_ID and SECRET_ACCESS_KEY as &quot;AWS_CREDS&quot;.</p><h4>3. Jenkins Pipeline for Terraform:</h4><p>Create Jenkinsfile:</p><pre>pipeline {<br>  agent any<br>  parameters {<br>    string(name: &#39;TF_WORKSPACE&#39;, defaultValue: &#39;dev&#39;, description: &#39;Terraform workspace&#39;)<br>    string(name: &#39;TF_STATE_BUCKET&#39;, defaultValue: &#39;jenkins-artifact-444xyz&#39;, description: &#39;S3 bucket for state&#39;)<br>  }<br>  environment {<br>    EMAIL_RECIPIENTS = &#39;team@example.com&#39;<br>    TERRAFORM_VERSION = &#39;1.5.7&#39;<br>    AWS_REGION = &#39;us-east-1&#39;<br>  }<br>  stages {<br>    stage(&#39;Checkout&#39;) {<br>      steps {<br>        git branch: &#39;main&#39;, url: &#39;https://github.com/your-repo/terraform-aws-demo.git&#39;<br>      }<br>    }<br>    <br>    stage(&#39;Setup Terraform&#39;) {<br>      steps {<br>        sh &#39;tfenv install ${TERRAFORM_VERSION} || true&#39;<br>      }<br>    }<br>    <br>    stage(&#39;Terraform Init&#39;) {<br>      steps {<br>        withCredentials([[<br>          $class: &#39;AmazonWebServicesCredentialsBinding&#39;,<br>          credentialsId: &#39;AWS_CREDS&#39;,<br>          accessKeyVariable: &#39;AWS_ACCESS_KEY_ID&#39;,<br>          secretKeyVariable: &#39;AWS_SECRET_ACCESS_KEY&#39;<br>        ]]) {<br>          sh &#39;&#39;&#39;<br>            terraform workspace select ${TF_WORKSPACE} || terraform workspace new ${TF_WORKSPACE}<br>            terraform init -backend-config=&quot;bucket=${TF_STATE_BUCKET}&quot; -reconfigure -input=false<br>          &#39;&#39;&#39;<br>        }<br>      }<br>    }<br>    <br>    stage(&#39;Terraform Plan&#39;) {<br>      steps {<br>        sh &#39;terraform plan -out=tfplan -var-file=${TF_WORKSPACE}.tfvars&#39;<br>        archiveArtifacts artifacts: &#39;tfplan&#39;, allowEmptyArchive: true<br>      }<br>    }<br>    <br>    stage(&#39;Manual Approval&#39;) {<br>      when {<br>        expression { params.TF_WORKSPACE == &#39;prod&#39; }<br>      }<br>      steps {<br>        timeout(time: 30, unit: &#39;MINUTES&#39;) {<br>          input(<br>            id: &#39;approve&#39;,<br>            message: &#39;Approve PRODUCTION deployment?&#39;,<br>            submitter: &#39;admin-team&#39;,<br>            parameters: [string(name: &#39;reason&#39;, description: &#39;Deployment reason&#39;)]<br>          )<br>        }<br>      }<br>    }<br>    <br>    stage(&#39;Terraform Apply&#39;) {<br>      steps {<br>        sh &#39;terraform apply -auto-approve tfplan&#39;<br>      }<br>    }<br>  }<br>  post {<br>    always {<br>      script {<br>        def buildStatus = currentBuild.currentResult<br>        emailext(<br>          subject: &quot;${buildStatus == &#39;SUCCESS&#39; ? &#39;✅&#39; : &#39;❌&#39;} Terraform ${buildStatus}: ${env.JOB_NAME}&quot;,<br>          body: &quot;&quot;&quot;<br>            &lt;p&gt;Workspace: ${params.TF_WORKSPACE}&lt;/p&gt;<br>            &lt;p&gt;Status: ${buildStatus}&lt;/p&gt;<br>            &lt;p&gt;&lt;a href=&quot;${env.BUILD_URL}&quot;&gt;Build Details&lt;/a&gt;&lt;/p&gt;<br>            ${buildStatus == &#39;FAILURE&#39; ? &#39;&lt;p&gt;Check console output for errors.&lt;/p&gt;&#39; : &#39;&#39;}<br>          &quot;&quot;&quot;,<br>          to: env.EMAIL_RECIPIENTS,<br>          mimeType: &#39;text/html&#39;<br>        )<br>        sh &#39;rm -rf tfplan terraform.tfstate* .terraform*&#39;<br>      }<br>    }<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=09fb84f0873b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>