<?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 Ashaye Adetomiwa on Medium]]></title>
        <description><![CDATA[Stories by Ashaye Adetomiwa on Medium]]></description>
        <link>https://medium.com/@ashayeadetomiwa77?source=rss-54ac092415f5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-EtQqyueOjw4hfHANzl_HQ.jpeg</url>
            <title>Stories by Ashaye Adetomiwa on Medium</title>
            <link>https://medium.com/@ashayeadetomiwa77?source=rss-54ac092415f5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:38:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashayeadetomiwa77/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[Kubernetes Health Probes: Stop Assuming Your Pods Are Fine]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/kubernetes-health-probes-stop-assuming-your-pods-are-fine-f2e16bd3a5f0?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2e16bd3a5f0</guid>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[k8s-security]]></category>
            <category><![CDATA[livenessprobe]]></category>
            <category><![CDATA[readinessprobe]]></category>
            <category><![CDATA[k8s-health-probes]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 02:15:40 GMT</pubDate>
            <atom:updated>2026-04-27T02:15:40.891Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Your pod is running. Your deployment succeeded. Everything looks green. And yet — your users are getting errors.</em></blockquote><blockquote><em>Welcome to the most common false sense of security in Kubernetes.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ooXAcahLQOBYj0uC9Iom4A.png" /></figure><p>If you’ve been working with K8s for any amount of time, you’ve probably seen it: a pod in Running state that isn&#39;t actually serving traffic correctly. Or a container that&#39;s silently wedged — accepting connections but not doing anything useful with them. Or a rolling update that pushed a broken version because nobody told Kubernetes to check first.</p><p>Health probes fix all of this. And yet, they’re one of the most misconfigured — or outright skipped — features in the ecosystem.</p><p>This post is actually a deep dive into <strong>Readiness</strong> and <strong>Liveness</strong> probes: what they actually do, how they differ, how to configure them correctly, and what happens when you get them wrong.</p><blockquote>Spoiler: I broke both of them on purpose in the lab so you can learn from the wreckage.</blockquote><h3>The Problem With “Running”</h3><p>In Kubernetes, Running means the container process has started. That&#39;s it. It says nothing about whether your app has finished initialising, whether it can actually serve requests, or whether it&#39;s stuck in some half-alive state consuming resources and returning 500s.</p><p>This is the gap health probes are designed to close. They give Kubernetes a way to ask your application directly: <em>“Are you ready? Are you still alive?”</em> — and act on the answer.</p><p>There are two probes that matter here:</p><ul><li><strong>Readiness Probe</strong> — controls whether a pod receives traffic</li><li><strong>Liveness Probe</strong> — controls whether a pod gets restarted</li></ul><p>They sound similar. They are not the same. Confusing them is where most misconfiguration begins.</p><h3>Readiness Probe: “Don’t Send Me Traffic Yet”</h3><h3>What it does</h3><p>A readiness probe tells Kubernetes when a pod is actually ready to serve requests. Until the probe passes, the pod is excluded from the Service’s endpoints — meaning no traffic reaches it, even if it’s in Running state.</p><p>This matters most in two scenarios:</p><ol><li><strong>Slow-starting apps</strong> — your app takes 20 seconds to load config, connect to a database, warm up a cache. Without a readiness probe, traffic hits it at the third second.</li><li><strong>Rolling updates</strong> — Kubernetes won’t move to the next pod in a rolling update until the new pod’s readiness probe passes. This is your safety net.</li></ol><h3>Configuration Example</h3><pre>readinessProbe:<br>  httpGet:<br>    path: /<br>    port: 80<br>  initialDelaySeconds: 10<br>  periodSeconds: 10<br>  timeoutSeconds: 1<br>  failureThreshold: 3<br>  successThreshold: 1</pre><p>Let’s break down each field:</p><p>initialDelaySeconds How long to wait before the first check. Give your app time to boot.</p><p>periodSeconds How often to check after that.</p><p>timeoutSeconds How long to wait for a response before counting it as a failure.</p><p>failureThreshold How many consecutive failures before marking the pod as not ready?</p><p>successThreshold How many consecutive successes before marking the pod as ready again?</p><h3>What failure looks like</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrNoJqROPMsyAmDiCNFhCA.png" /><figcaption>Readiness probe failure simulation</figcaption></figure><p>Here’s what happens when you deliberately point the probe at a path that doesn’t exist:</p><pre>readinessProbe:<br>  httpGet:<br>    path: /does-not-exist<br>    port: 80</pre><p>Apply it, describe the pod, and you’ll see:</p><pre>Conditions:<br>  Type              Status<br>  Ready             False</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxeNuKuy3vDT_UI4lR6B5w.png" /><figcaption>Readiness probe failed</figcaption></figure><pre>Events:<br>  Warning  Unhealthy  Readiness probe failed: HTTP probe failed with statuscode: 404</pre><p>The pod stays Running. But its READY column reads 0/1. It&#39;s been quietly removed from the service endpoints. No traffic reaches it. No user-facing error — just silent exclusion.</p><p>This is readiness working exactly as designed. Now imagine that without the probe: that broken pod would be happily receiving traffic and returning 404s to your users while Kubernetes thinks everything is fine.</p><h3>The rolling update gate</h3><p>This is the part that makes readiness genuinely powerful in production. During a rolling update, Kubernetes will not terminate the old pod until the new pod’s readiness probe passes. If the new version is broken — if the probe never passes — the rollout stalls. Old pods keep serving. Nothing gets worse.</p><p>That’s not a bug. That’s the safety mechanism. Your readiness probe is the bouncer at the door of your deployment pipeline.</p><h3>Liveness Probe: “I Need You to Restart That Container”</h3><h3>What it does</h3><p>A liveness probe answers a different question: is this container still functioning correctly, or has it gotten into a state it can’t recover from on its own?</p><p>Some failures don’t crash a process. A deadlock keeps the process running but renders it useless. A memory leak might not cause an OOM kill immediately but makes the app progressively slower and less responsive. A stuck thread pool, a broken internal queue — these are all scenarios where Running lies to you.</p><p>Liveness probes detect these stuck states and restart the container automatically, without human intervention.</p><h3>Configuration</h3><pre>livenessProbe:<br>  httpGet:<br>    path: /<br>    port: 80<br>  initialDelaySeconds: 10<br>  periodSeconds: 10<br>  timeoutSeconds: 1<br>  failureThreshold: 3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jspqwSZ734zDeHMT-h_6Qg.png" /><figcaption>A deployed liveness probe</figcaption></figure><p>The structure mirrors the readiness probe. The difference is entirely in what Kubernetes <em>does</em> when the probe fails:</p><ul><li><strong>Readiness failure</strong> → remove from endpoints, stop sending traffic</li><li><strong>Liveness failure</strong> → restart the container</li></ul><h3>What failure looks like</h3><p>Point the liveness probe at an invalid path:</p><pre>livenessProbe:<br>  httpGet:<br>    path: /does-not-exist<br>    port: 80</pre><p>Describe the pod shortly after and you’ll see restarts climbing:</p><pre>Containers:<br>  nginx:<br>    State: Running<br>    Ready: True<br>    Restart Count: 3</pre><pre>Events:<br>  Warning  Unhealthy  Liveness probe failed: HTTP probe failed with statuscode: 404<br>  Normal   Killing    Container nginx failed liveness probe, will be restarted</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OV64tnuIx760ldTeTxJmXA.png" /><figcaption>Restarts climb and in in a CrashLoopBackOff</figcaption></figure><p>Keep watching, and it escalates:</p><pre>State: Waiting<br>  Reason: CrashLoopBackOff</pre><p>CrashLoopBackOff is Kubernetes backing off exponentially between restart attempts. It&#39;s not giving up — it&#39;s being responsible about not hammering a container that keeps failing. It will keep trying. But each attempt costs more time.</p><p>Fix the probe path, reapply, and the container recovers. Restart count resets. Traffic resumes. Clean.</p><h3>The Configuration Mistakes That Will Quietly Ruin Your Day</h3><h3>1. initialDelaySeconds set too low</h3><p>This is the most common mistake, and it’s brutal because it’s non-obvious.</p><p>Your app takes 15 seconds to start. You set initialDelaySeconds: 5. Kubernetes starts checking at second 5, gets no response, counts it as a failure, checks again, fails again — and by the time your app is ready, it&#39;s already hit failureThreshold and either excluded the pod from traffic (readiness) or restarted it (liveness).</p><p>You’re killing healthy pods. Set initialDelaySeconds to comfortably exceed your worst-case startup time. Add a buffer. Then add a bit more.</p><h3>2. Using liveness where you need readiness</h3><p>If your app is temporarily overwhelmed — high load, slow database query, transient spike — it might respond slowly to probes. A liveness failure here triggers a restart. Which adds more load. Which causes more liveness failures. Which triggers more restarts.</p><p>You’ve just written a restart loop into your production system.</p><p>Use readiness to handle temporary unavailability. Use liveness only for genuinely unrecoverable states. They are not interchangeable.</p><h3>3. No probe at all</h3><p>The default behaviour — no probe — is that Kubernetes considers your pod ready the moment the container starts and alive forever unless the process crashes. In a stateless toy app, maybe that’s fine.</p><p>In anything running real traffic, it’s a ticking clock.</p><h3>4. Probing the wrong endpoint</h3><p>Your /healthz endpoint might always return 200 even when your app is broken — if someone wrote it that way. Make sure your health endpoint actually checks what matters: database connectivity, downstream dependencies, internal state. A probe is only as good as what it&#39;s probing.</p><h3>Readiness vs Liveness: The One-Line Summary</h3><p><strong>The question asked</strong>:</p><ul><li>Readiness: Ready for traffic?</li><li>Liveness: Still functioning</li></ul><p><strong>On failure:</strong></p><ul><li>Readiness: Remove from endpoints</li><li>Liveness: Container restarted</li></ul><p><strong>Use case:</strong></p><ul><li>Readiness: Slow start, rolling updates</li><li>Liveness: Deadlocks, stuck states</li></ul><p><strong>Risk if misconfigured:</strong></p><ul><li>Readiness: Users hit unready pods</li><li>Liveness: Restart loops under load</li></ul><h3>A Note on successThreshold for Liveness</h3><p>One subtle configuration point worth calling out: successThreshold for liveness probes <strong>must always be 1</strong>. Kubernetes enforces this. It makes sense — once a container proves it&#39;s alive again after a restart, you don&#39;t need three consecutive confirmations before trusting it. One is enough.</p><p>For readiness, successThreshold can be higher if you want to be more conservative about when a pod re-enters the endpoint pool. Useful for apps that tend to flap.</p><h3>The Bottom Line</h3><p>Health probes aren’t optional. They’re the mechanism by which Kubernetes actually knows the difference between a pod that’s running and a pod that’s working.</p><p>Readiness ensures your users never hit a pod that isn’t ready. Liveness ensures a stuck container doesn’t sit quietly degrading your service while the process stays alive.</p><p>Configure initialDelaySeconds generously. Be deliberate about which probe type you&#39;re using and why. Make your health endpoints meaningful. And break them in a lab before they break in production.</p><p>Your cluster is always telling you something. Probes are how you make sure it’s telling you the truth.</p><p>I hope you found this useful!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2e16bd3a5f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Chaos to Container: Everything That Broke When I Dockerized EpicBook (And How I Fixed It)]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/from-chaos-to-container-everything-that-broke-when-i-dockerized-epicbook-and-how-i-fixed-it-fe040b264dda?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe040b264dda</guid>
            <category><![CDATA[cloud-engineering]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 10:53:20 GMT</pubDate>
            <atom:updated>2026-04-24T10:53:20.240Z</atom:updated>
            <content:encoded><![CDATA[<p>Let me set the scene.</p><p>You have a Node.js app, a MySQL database, and Nginx standing at the door like a security guard. You run docker compose up, lean back, and— <em>ERROR.</em> Then another error. Then a different one that makes no sense.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YnZNj0mr5wlkcEWlkE7Ehg.png" /></figure><p>That was my week migrating <strong>EpicBook</strong> — a Node.js + MySQL app — into a fully containerized, cloud-ready stack on AWS. This post is the honest account of every landmine I stepped on and how I defused each one. If you’re containerizing a legacy app for the first time, consider this your field guide.</p><h4>The Plan: A Three-Tier Architecture</h4><p>Before we get to the explosions, here’s what I was building — a classic three-container stack using <strong>Docker Compose</strong>:</p><ul><li><strong>Backend</strong> — The Node.js application</li><li><strong>Database</strong> — MySQL 8.0</li><li><strong>Reverse Proxy</strong> — Nginx to route traffic to the backend</li></ul><p>Simple on paper. An adventure in practice.</p><h4>Bug #1: The Missing Module</h4><p>The first crash was loud and clear:</p><pre>Error: Cannot find module &#39;cors&#39;</pre><p>The cors package was used in the code but never listed in package.json. On your local machine, you might have installed it manually and forgotten about it. Docker doesn&#39;t care about your local environment — it only reads package.json.</p><p><strong>The fix:</strong> Add cors (or any missing dependency) to package.json, then rebuild the image with --build to force Docker to reinstall everything fresh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*SsK_gZGQiAK8fsBWmY_sog.png" /><figcaption>Add cors to your package.json</figcaption></figure><blockquote><strong><em>Lesson:</em></strong><em> Docker is not your laptop. If it’s not in </em><em>package.json, it doesn&#39;t exist inside the container.</em></blockquote><h4>Bug #2: The Hyphen That Cost Me Sometime</h4><p>While trying to bring up the stack, I hit the following:</p><pre>KeyError: &#39;ContainerConfig&#39;</pre><p>After some digging: I was using docker-compose (the old Python-based V1 tool) instead of docker compose (the modern Go-based V2 plugin). That one hyphen was the difference.</p><p>On modern Ubuntu systems, the package is often named docker-compose-v2. So you need to run:</p><pre>sudo apt-get update<br>sudo apt-get install docker-compose-v2</pre><p>Once installed, check if it works by typing the following:</p><pre>docker compose version</pre><p>The hyphenated docker-compose is deprecated and, as you saw, can&#39;t handle modern image configs. Switching to the space version (docker compose) fixes that KeyError: &#39;ContainerConfig&#39; permanently.</p><blockquote><strong><em>Analogy:</em></strong><em> It’s like trying to play a modern Blu-ray on a 1990s DVD player. Same logo, completely different machine.</em></blockquote><p><strong>The fix:</strong> Switch to docker compose (no hyphen). V2 is faster, more stable, and actively maintained. V1 is essentially retired.</p><h4>Bug #3: The Name Tag Incident (Environment Variables)</h4><p>Picture this: you’re at a party. Your name tag says <strong>“Dave,”</strong> but everyone is calling you <strong>“David.”</strong> You’re not going to answer.</p><p>My .env file had a variable called DB_PASSWORD, but docker-compose.yml was looking for DB_PASS. The result? The app was trying to log into MySQL with a blank password — and getting rightfully rejected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sU8dTZYzbe57lnfp0WUNyA.png" /><figcaption>The password error message</figcaption></figure><p><strong>The fix:</strong> Treat your environment variables like a contract. If .env says DB_PASSWORD, every file in the stack — docker-compose.yml, your app config, all of it — must call it DB_PASSWORD. One mismatch, and the whole chain breaks silently.</p><h4>Bug #4: Don’t Try to Create the King (The MySQL Root Rule)</h4><p>This one is a MySQL quirk that bites almost everyone once.</p><p>If you put MYSQL_USER=root in your Docker config, the container crashes. Why? Because MySQL&#39;s Docker image already creates a root user automatically. Trying to create it again is a conflict the container handles by... dying.</p><blockquote><em>MySQL’s attitude: </em>“Bro, I AM root. I was born root. Don’t try to make ‘root’ happen.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*_u8EVZ07s1-nP_eJweYO3g.png" /><figcaption>Never define MYSQL_USER=root</figcaption></figure><p><strong>The fix:</strong> Never define MYSQL_USER=root. Only set MYSQL_ROOT_PASSWORD. MySQL handles the rest. If you need an app-specific user, give it a different name entirely.</p><h4>Bug #5: Sequelize’s “Dialect” Drama</h4><p>Next came this cryptic error:</p><pre>Dialect needs to be explicitly supplied</pre><p>Two separate things were happening here.</p><p>First, the legacy app was looking for a JAWSDB_URL environment variable (a Heroku-specific thing). We weren&#39;t on Heroku, so the variable didn&#39;t exist, and Sequelize had no idea what database engine to use.</p><p>Second — and this one is sneaky — Sequelize is extremely particular about the order of its constructor arguments. We had:</p><pre>new Sequelize(user, password, database)</pre><p>But Sequelize expects:</p><pre>new Sequelize(database, user, password)</pre><p>Because the arguments were swapped, Sequelize was trying to connect to a database named after our <em>password</em>. The database was not amused.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qN_ZV_heAWuAfLkdnIp9qg.png" /><figcaption>Sequelize in the right order</figcaption></figure><p><strong>The fix:</strong> Refactor models/index.js to explicitly pass the dialect (mysql) and use the correct argument order. Don&#39;t rely on legacy environment variable names — adapt the code to your environment, not the other way around.</p><h4>Bug #6: The Teenager Problem (Race Conditions)</h4><p>Database containers are like teenagers: they take a while to get ready.</p><p>Our Node.js app was starting in under a second and immediately screaming <em>“WHERE IS THE DATABASE?!”</em> Meanwhile, MySQL was still initializing its schema — still putting on its shoes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*Rg5EN9-vITqgRWVZBS5Diw.png" /><figcaption>Use the restart:always</figcaption></figure><p><strong>The fix:</strong> Add restart: always to the backend service in your docker-compose.yml. This tells Docker: if the app crashes because the database isn&#39;t ready yet, just restart it. You can also add a short sleep command as a startup delay.</p><blockquote><em>It’s the digital equivalent of telling the app: </em>“Go back to bed for 15 seconds. The database is still in the shower.”</blockquote><h4>Bug #7: Nginx Looking in Its Own Pockets</h4><p>The final boss: a <strong>502 Bad Gateway</strong> and a completely unstyled page.</p><p>Nginx was configured to serve static assets (CSS, images) directly. The problem? Those files lived inside the <strong>backend container</strong>, not the Nginx container. Nginx was checking its own pockets for keys that were in someone else’s coat.</p><p><strong>The fix:</strong> Remove the static assets block from Nginx entirely. Tell Nginx to do one job: proxy every request to the backend. The backend already knows where the CSS lives.</p><p>nginx</p><pre>location / {<br>    proxy_pass http://backend:8080;<br>}</pre><p>Simple. Clean. No more 502.</p><h4>Security Sidebar: Keep Secrets Out of GitHub</h4><p>One of the earlier crashes involved an Access Denied error from MySQL. The root cause? The app was reading the <em>label</em> DB_PASSWORD as the actual password value, rather than resolving it to the real secret.</p><p>The right pattern:</p><ul><li>Your config.json uses generic variable names (labels)</li><li>The real values live in a .env file on your server</li><li>.env is in .gitignore — it never touches GitHub</li></ul><p>Your code bridge the two. Your repository stays clean. Your credentials stay private. This isn’t optional — it’s the baseline.</p><h4>The Moment It All Worked</h4><p>After fixing the variable names, correcting the Sequelize argument order, giving MySQL time to breathe, and simplifying Nginx, the logs finally looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cqJX93CUeVXgjMZI-f7ojA.png" /><figcaption>The moment everything finally connected</figcaption></figure><p>Three green lights. All containers healthy, all talking to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HJnDeNe7UnE7uTUDZaMo6w.png" /><figcaption>Live application</figcaption></figure><h4>What I Actually Learned</h4><p>Docker isn’t just about packaging code. It’s about <strong>orchestration</strong> — making sure the drummer, the guitarist, and the vocalist are all playing the same song at the same tempo.</p><p>Every bug in this list came down to one of three things:</p><ol><li><strong>Assumptions</strong> — “I thought Docker would pick that up automatically.”</li><li><strong>Inconsistency</strong> — A variable name off by one character, an argument in the wrong order.</li><li><strong>Timing</strong> — One container wasn’t ready when another expected it.</li></ol><p>Fix those three categories, and most containerization problems solve themselves</p><h4>Quick Reference: The Bug Checklist</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*lzhw_vcv8FoCoIfVXo3_2A.png" /></figure><p>Migration is rarely a straight line. It’s logs, coffee, and <em>“Wait, why is that container exiting with code 1?”</em> But when you finally see those green checkmarks, it’s worth every hour.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe040b264dda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bridging Infrastructure and Application: A Modern CI/CD Pipeline with Azure DevOps, Terraform, and…]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/bridging-infrastructure-and-application-a-modern-ci-cd-pipeline-with-azure-devops-terraform-and-4872059082b4?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4872059082b4</guid>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 02:21:46 GMT</pubDate>
            <atom:updated>2026-04-12T02:21:46.944Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bridging Infrastructure and Application: A Modern CI/CD Pipeline with Azure DevOps, Terraform, and Ansible</h3><p>As a DevOps engineer, establishing a robust Continuous Integration and Continuous Deployment (CI/CD) pipeline isn’t just a requirement; it’s the bedrock of modern application delivery. In a world where application logic changes rapidly, the ability to safely, repeatably, and securely push changes from code commit to production is paramount.</p><p>In this article, I want to walk you through how I structured an end-to-end deployment workflow for a multi-tier application called “EpicBook” using Azure DevOps Pipelines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wOMi6Jl0d9dA5c1CvWfMYw.png" /><figcaption>Epicbook Application</figcaption></figure><p>This specific workflow uses a powerful “separation of concerns” model, utilizing two distinct pipelines and two separate repositories: one dedicated to provisioning infrastructure with Terraform, and the second dedicated to configuring that infrastructure and deploying the application code with Ansible.</p><h3>The Architectural Overview</h3><p>Our goal is to deploy the EpicBook application (Frontend on Nginx, Backend API, MySQL Database) into Azure.</p><p>To achieve this cleanly, we divide the work:</p><ol><li><strong>Repository A: </strong><strong>epicbook-infra (Terraform)</strong> – Responsible for provisioning the raw Azure resources: Resource Groups, Virtual Networks, Subnets, Ubuntu VMs, and Azure Database for MySQL.</li></ol><p><strong>The Repo Structure:</strong></p><pre>terraform/<br>├── modules/<br>│   ├── compute/<br>│   │   ├── main.tf<br>│   │   ├── outputs.tf<br>│   │   └── variables.tf<br>│   ├── database/<br>│   │   ├── main.tf<br>│   │   ├── outputs.tf<br>│   │   └── variables.tf<br>│   └── network/<br>│       ├── main.tf<br>│       ├── outputs.tf<br>│       └── variables.tf<br>├── .gitignore<br>├── azure-pipelines.yaml<br>├── main.tf<br>├── outputs.tf<br>├── provider.tf<br>├── README.md<br>├── terraform.tfvars<br>└── variables.tf</pre><ol><li><strong>Repository B: </strong><strong>epicbook-app (Ansible + App Code)</strong> – Responsible for connecting to the freshly minted VMs, installing software (Nginx, Python, application dependencies), configuring the backend connection to MySQL, and verifying the application deployment.</li></ol><p><strong>The repo structure:</strong></p><pre>epicbook/<br>├── ansible/<br>│   ├── group_vars/<br>│   │   └── web/<br>│   │       ├── vars.yml<br>│   │       └── vault.yml<br>│   └── roles/<br>│       ├── common/<br>│       │   ├── handlers/<br>│       │   │   └── main.yml<br>│       │   └── tasks/<br>│       │       └── main.yml<br>│       ├── epicbook/<br>│       │   ├── tasks/<br>│       │   │   └── main.yml<br>│       │   └── templates/<br>│       │       └── config.json.j2<br>│       └── nginx/<br>│           ├── handlers/<br>│           │   └── main.yml<br>│           ├── tasks/<br>│           │   └── main.yml<br>│           └── templates/<br>├── .gitignore<br>├── .vault_pass<br>├── azure-pipelines.yml<br>├── inventory.ini<br>├── README.md<br>└── site.yml</pre><h3>Phase 1: Preparation and Prerequisites</h3><p>Before writing any automation code, several foundational elements must be configured within Azure and Azure DevOps.</p><h3>1. Azure Setup</h3><p>You require a valid Azure subscription and a Service Principal (SPN) registered in Azure Active Directory. This SPN must have “Contributor” access to your target Resource Group.</p><h3>2. Azure DevOps Setup (The Security Layer)</h3><p>We register that Service Principal in Azure DevOps as an <strong>Azure Resource Manager Service Connection</strong>. Crucially, when setting this up, ensure you check the box that says “Grant access permission to all pipelines.” We must also set up an SSH service connection as well that ensures that our self-hosted agent can securely connect with the Virtual Machine and run workloads.</p><p>Furthermore, we utilize one of Azure DevOps’ most essential security features: <strong>Secure Files</strong>. You should generate an SSH Keypair (id_rsa private key and id_rsa.pub public key). Upload <strong>both</strong> of these to the Pipelines &gt; Library &gt; Secure Files section. Never store private keys in your repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yy08w8AIJJo4GaEcxUDLnA.png" /><figcaption>SSH key stored as a secure file, and ansible secret stored as a variable group</figcaption></figure><h3>Phase 2: Pipeline 1 — Infrastructure Provisioning (Terraform)</h3><p>The epicbook-infra repository contains your standard modularized Terraform code. When a change is pushed to the main branch (specifically within the terraform/ subdirectory), the Infrastructure Pipeline triggers.</p><p>This pipeline uses a <strong>Self-Hosted Agent Pool</strong> (epicbook-agent-pool). This is standard best practice, as it provides a secure environment already configured with required tools and network access.</p><p>Sample pipeline code:</p><pre>trigger:<br>  branches:<br>    include:<br>      - main<br>  paths:<br>    include:<br>      - terraform/**<br><br>stages:<br>  - stage: Terraform_Infra_Deploy<br>    displayName: &quot;Provision Terraform Infrastructure&quot;<br>    jobs:<br>      - job: TerraformApply<br>        displayName: &quot;Terraform Apply&quot;<br>        pool:<br>          name: &quot;epicbook-agent-pool&quot;<br>        steps:<br>          # 1. Download the file from Secure Files<br>          - task: DownloadSecureFile@1<br>            name: ssh_key_task # We use this name to reference the path below<br>            inputs:<br>              secureFile: &quot;id_rsa.pub&quot;<br>          <br>          # 2. Extract/Copy the SSH Key to the specific locations Terraform expects<br>          - script: |<br>              echo &quot;Creating .ssh directory...&quot;<br>              mkdir -p ~/.ssh<br>              <br>              echo &quot;Copying key to agent home...&quot;<br>              cp $(ssh_key_task.secureFilePath) ~/.ssh/id_rsa.pub<br>              <br>              echo &quot;Copying key into Terraform module path...&quot;<br>              # Based on your reference image, Terraform needs it here:<br>              cp $(ssh_key_task.secureFilePath) terraform/modules/compute/id_rsa.pub<br>            displayName: &quot;Extract SSH Public Key for Terraform&quot;<br><br>          # - task: TerraformInstaller@1<br>            # inputs:<br>              # terraformVersion: &quot;1.6.6&quot;<br><br>          # 3. Run Terraform within the &#39;terraform&#39; subdirectory<br>          - task: AzureCLI@2<br>            displayName: &quot;Terraform Init Plan Apply&quot;<br>            inputs:<br>              azureSubscription: &quot;epicbook-azure-connection&quot;<br>              scriptType: &quot;bash&quot;<br>              scriptLocation: &quot;inlineScript&quot;<br>              workingDirectory: &quot;$(System.DefaultWorkingDirectory)/terraform&quot;<br>              inlineScript: |<br>                set -e <br>                <br>                echo &quot;##[group]Terraform Init&quot;<br>                # You MUST add these backend-config lines here:<br>                terraform init -input=false \<br>                  -backend-config=&quot;resource_group_name=tfstate-rg&quot; \<br>                  -backend-config=&quot;storage_account_name=epictfstate260410&quot; \<br>                  -backend-config=&quot;container_name=tfstate&quot; \<br>                  -backend-config=&quot;key=terraform.tfstate&quot;<br>                echo &quot;##[endgroup]&quot;<br><br>                terraform validate<br><br>                echo &quot;##[group]Terraform Plan&quot;<br>                terraform plan -input=false -var=&quot;ssh_public_key_path=$(ssh_key_task.secureFilePath)&quot;<br>                echo &quot;##[endgroup]&quot;<br><br>                echo &quot;##[group]Terraform Apply&quot;<br>                terraform apply -auto-approve -var=&quot;ssh_public_key_path=$(ssh_key_task.secureFilePath)&quot;<br>                echo &quot;##[endgroup]&quot;</pre><p>The pipeline execution flow looks like this:</p><p><strong>1. Secure Key Retrieval:</strong> The pipeline downloads the <em>public</em> SSH key (id_rsa.pub) from Secure Files. Terraform needs this to inject it into the Ubuntu VMs during provisioning so that our application pipeline can connect later.</p><p><strong>2. The Terraform Lifecycle (AzureCLI@2 Task):</strong> We use the Azure CLI task to handle authentication seamlessly using our Service Connection.</p><ul><li><strong>set -e</strong>: Ensures the pipeline halts immediately on any failure.</li><li><strong>terraform init</strong>: Crucially, we pass the backend configuration here dynamically. We store our Terraform State file (.tfstate) in an Azure Storage Account. This prevents state conflicts and allows team collaboration.</li><li><strong>terraform validate</strong>: A final syntax check of our configuration.</li><li><strong>terraform plan</strong>: Generates an execution plan, showing exactly what will be created, modified, or destroyed. We pass the path of our downloaded public key as a variable.</li><li><strong>terraform apply -auto-approve</strong>: Executes the plan without requiring manual intervention, making the process fully automated.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KxfmoYsSZFrHFAkc8seilA.png" /><figcaption>Infra pipeline ready</figcaption></figure><p>Once complete, the raw infrastructure is ready in Azure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TBJssOhZVKmqo0c6Wyd7iA.png" /><figcaption>Ready infrastructure on the Azure Management Console</figcaption></figure><h3>Phase 3: Pipeline 2 — Application Deployment (Ansible)</h3><p>Now that the “house” is built, Pipeline 2 must “furnish” it. The epicbook-app repository triggers upon changes to the main branch.</p><p>This pipeline leverages <strong>Variables and Secrets</strong> from the Library (linking to a variable group called ansible-secrets) to handle the sensitive Ansible Vault password securely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yy08w8AIJJo4GaEcxUDLnA.png" /><figcaption>Variable group (ansible-secret) stored in the pipeline library</figcaption></figure><p>Sample pipeline code:</p><pre>trigger:<br>- main<br><br>pool:<br>  name: &#39;epicbook-agent-pool&#39; <br><br>variables:<br>  - group: ansible-secrets<br>  - name: VM_IP<br>    value: &#39;your_public_ip&#39;<br>  - name: DB_FQDN<br>    value: &#39;your_database_hostname&#39;<br><br>jobs:<br>- job: Deploy_EpicBook<br>  displayName: &#39;Install and Deploy EpicBook via Ansible&#39;<br>  steps:<br><br>  # 1. DOWNLOAD THE KEY (Confirmed name: id_rsa)<br>  - task: DownloadSecureFile@1<br>    name: ssh_key<br>    inputs:<br>      secureFile: &#39;id_rsa&#39;<br><br>  # 2. Prepare Vault Password<br>  - bash: |<br>      echo &quot;$(ANSIBLE_VAULT_PASSWORD)&quot; &gt; .vault_pass<br>      chmod 600 .vault_pass<br>    displayName: &#39;Create Vault Password File&#39;<br><br>  # 3. Create dynamic Inventory<br>  - bash: |<br>      echo &quot;[web]&quot; &gt; ansible/inventory.ini<br>      echo &quot;$(VM_IP)&quot; &gt;&gt; ansible/inventory.ini<br>      echo &quot;&quot; &gt;&gt; ansible/inventory.ini<br>      echo &quot;[web:vars]&quot; &gt;&gt; ansible/inventory.ini<br>      echo &quot;ansible_user=azureuser&quot; &gt;&gt; ansible/inventory.ini<br>      echo &quot;ansible_python_interpreter=/usr/bin/python3&quot; &gt;&gt; ansible/inventory.ini<br>    displayName: &#39;Generate Inventory&#39;<br><br>  # 4. RUN ANSIBLE<br>  - bash: |<br>      # A) Get the path from the download task<br>      KEY_PATH=$(ssh_key.secureFilePath)<br>      <br>      # B) Set permissions (Required by SSH)<br>      chmod 600 &quot;$KEY_PATH&quot;<br>      <br>      # C) Disable fingerprint prompts<br>      export ANSIBLE_HOST_KEY_CHECKING=False<br>      <br>      # D) Run the playbook<br>      ansible-playbook -i ansible/inventory.ini ansible/site.yml \<br>        --private-key &quot;$KEY_PATH&quot; \<br>        --vault-password-file .vault_pass \<br>        --extra-vars &quot;db_host=$(DB_FQDN)&quot;<br>    displayName: &#39;Run Ansible Playbook&#39;<br>    workingDirectory: $(System.DefaultWorkingDirectory)<br><br>  # 5. Cleanup<br>  - bash: |<br>      rm .vault_pass<br>    displayName: &#39;Remove Vault Pass File&#39;<br>    condition: always()</pre><p>The deployment flow is procedural and security-focused:</p><p><strong>1. Secure Connection &amp; Security Setup:</strong></p><ul><li>It downloads the <em>private</em> SSH key (id_rsa) from Secure Files.</li><li>It creates a temporary .vault_pass file containing the secret from our variable group and sets tight permissions (chmod 600) so Ansible can decrypt sensitive data (like DB passwords inside our vault.yml).</li></ul><p><strong>2. Dynamic Inventory Generation:</strong> Instead of maintaining a static inventory file, the pipeline <strong>builds the inventory on the fly</strong>. Since VM IPs are hardcoded in variables for now (a workflow improvement would be to pass them from Terraform outputs), this step dynamically writes ansible/inventory.ini, targeting the web server group and setting the correct ansible_user.</p><p><strong>3. Running the Playbook:</strong> The ansible-playbook site.yml command executes the configuration tasks. It references the dynamic inventory, the securely downloaded private key, the vault password file, and passes the database FQDN as an extra variable so the application knows where its database resides.</p><p><strong>4. Security Cleanup:</strong> This is non-negotiable best practice: A final step uses the condition: always() to ensure the temporary .vault_pass file is deleted from the self-hosted agent’s disk, even if the deployment failed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_51p2vEnc7gHAMMHj9tYXg.png" /><figcaption>Ansible pipeline successfully deployed</figcaption></figure><h3>Troubleshooting the “Tough Stuff”</h3><h4>1. The “Tilde” (~) Expansion Trap</h4><p><strong>The Issue:</strong> As you discovered, Terraform’s file() function and many shell scripts within CI/CD pipelines treat the tilde (~) as a literal string rather than a shortcut to the home directory.</p><p><strong>The Fix:</strong> Always use absolute paths or environment variables like $HOME. In Azure DevOps, the most reliable method is to reference the $(ssh_key_task.secureFilePath) variable directly, as this provides the exact absolute path where the agent temporarily stored the secret.</p><h4>2. Missing Binaries on Self-Hosted Agents</h4><p><strong>The Issue:</strong> Unlike Microsoft-hosted agents which come “pre-loaded” with almost everything, a self-hosted agent is a blank canvas. If your pipeline calls terraform or ansible-playbook and the tool isn&#39;t in the system&#39;s $PATH, the job will fail with a &quot;command not found&quot; error.</p><p><strong>The Fix:</strong> You have two choices:</p><ul><li><strong>Pre-install:</strong> Manually install Terraform and Ansible on the VM hosting your agent.</li><li><strong>On-the-fly:</strong> Use the TerraformInstaller@1 or Pip tasks at the start of your pipeline to ensure the correct version is present every single time.</li></ul><h4>3. SSH Fingerprint Prompt</h4><p><strong>The Issue:</strong> When Ansible tries to connect to a new Azure VM for the first time, SSH usually pauses and asks: “The authenticity of host… can’t be established. Are you sure you want to continue connecting (yes/no)?” In a pipeline, there is no one to type “yes,” so the pipeline just hangs until it times out.</p><p><strong>The Fix:</strong> Use the environment variable export ANSIBLE_HOST_KEY_CHECKING=False in your script block. This tells Ansible to skip that manual verification and proceed with the automation.</p><h4>4. Permission Denied (Private Key Security)</h4><p><strong>The Issue:</strong> SSH is incredibly picky about private key permissions. If your pipeline downloads id_rsa and the file has &quot;777&quot; permissions (readable by anyone), SSH will ignore the key and fail the connection for security reasons.</p><p><strong>The Fix:</strong> Always include a chmod 600 &lt;path_to_key&gt; command immediately after downloading your secure file. This ensures only the owner (the pipeline agent) can read the key, satisfying SSH&#39;s security requirements.</p><h4>5. The “Storage Account” Problem</h4><p><strong>The Issue:</strong> To run terraform init with an Azure backend, the Storage Account and Container must already exist. If you try to run the pipeline before creating the backend storage, the initialization will fail.</p><p><strong>The Fix:</strong> This is a manual prerequisite. You must create the “tfstate” Resource Group and Storage Account via the Azure Portal or CLI before your first pipeline run. Alternatively, use a “Bootstrap” script to create them.</p><h3>Verification</h3><p>Once Pipeline 2 completes successfully, you can verify the deployment by navigating to the Nginx public IP address in your browser. The EpicBook application should load, successfully querying the backend database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lwLEzVbj8UK-jmxdtautBQ.png" /><figcaption>Both pipelines successfully deployed</figcaption></figure><h3>Conclusion</h3><p>By structuring the CI/CD pipeline this way — separating infrastructure (using Terraform’s declarative approach) from configuration (using Ansible’s procedural approach) — we achieve a standard, modular, and highly secure automation workflow. It allows infrastructure teams and application teams to iterate independently, all while maintaining a consistent and reliable deployment pathway.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4872059082b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Two-Tier App with Terraform and Ansible Roles]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/building-a-two-tier-app-with-terraform-and-ansible-roles-22c3d389af9a?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/22c3d389af9a</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <category><![CDATA[ansible-roles]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Fri, 03 Apr 2026 18:04:21 GMT</pubDate>
            <atom:updated>2026-04-03T18:04:21.236Z</atom:updated>
            <content:encoded><![CDATA[<p>In the early stages of learning DevOps, it’s common to rely on “one-liner” commands or massive, monolithic playbooks. But as infrastructure scales, those methods break.</p><p>In this project, I leveled up my automation game by deploying a full-stack, two-tier application called <strong>Epicbook</strong>. This project wasn’t just about “making it work” — it was about building a professional, modular, and secure deployment pipeline using <strong>Terraform</strong>, <strong>Ansible Roles</strong>, and <strong>AWS</strong>. And I would love for you to do the same.</p><h4>The Architecture: A Two-Tier Approach</h4><p>The goal was simple: Build a “House” (Infrastructure) and then “Furnish” it (Configuration).</p><ol><li><strong>The Infrastructure (Terraform):</strong> Provisioning the AWS resources, including a VPC, an EC2 instance for the web server, and an RDS MySQL instance for the database.</li><li><strong>The Configuration (Ansible):</strong> Once the server was live, Ansible took over to install Nginx, Node.js, and PM2, while also seeding the database and securing the application.</li></ol><h4>Why “Roles” Changed Everything</h4><p>Initially, I was running ad-hoc commands. It was messy. By moving to <strong>Ansible Roles</strong>, I was able to break my configuration into three reusable modules:</p><ul><li><strong>common</strong>: Standardized the environment (OS updates, basic tools).</li><li><strong>nginx</strong>: Handled the reverse proxy setup using Jinja2 templates for dynamic configuration.</li><li><strong>epicbook</strong>: Cloned the source code, installed dependencies, and managed the application lifecycle.</li></ul><p>This modularity means if I want to deploy a different app tomorrow, I can reuse my common and nginx roles without changing a single line of code.</p><h4>The file structure:</h4><pre>.<br>├── terraform/                # Infrastructure Provisioning<br>│   ├── main.tf               # Core AWS resources<br>│   ├── provider.tf           # AWS Provider settings<br>│   ├── variable.tf           # Variable definitions<br>│   └── terraform.tfvars      # Environment-specific values (Git Ignored)<br>├── ansible/                  # Configuration Management<br>│   ├── inventory.ini         # Target host details<br>│   ├── site.yml              # Main playbook (Orchestration)<br>│   ├── group_vars/<br>│   │   ├── web.yml           # App &amp; environment configuration<br>│   │   └── vault.yml         # Encrypted secrets (DB passwords)<br>│   └── roles/                # Modular logic<br>│       ├── common/           # Base OS setup &amp; tools<br>│       ├── nginx/            # Nginx installation &amp; config<br>│       └── epicbook/         # App deployment &amp; DB seeding<br>├── .gitignore                # Prevents secrets/binaries from being committed<br>├── .vault_pass               # Local Ansible Vault password (Git Ignored)<br>└── README.md</pre><p>In fact, going ahead to create all of these, you can make use of these Linux commands if you want to get started:</p><pre>mkdir -p epicbook-prod/terraform/ <br>mkdir -p epicbook-prod/ansible/group_vars<br>mkdir -p epicbook-prod/ansible/roles/common/tasks<br>mkdir -p epicbook-prod/ansible/roles/common/handlers<br>mkdir -p epicbook-prod/ansible/roles/nginx/tasks<br>mkdir -p epicbook-prod/ansible/roles/nginx/templates <br>mkdir -p epicbook-prod/ansible/roles/nginx/handlers<br>mkdir -p epicbook-prod/ansible/roles/epicbook/tasks<br>mkdir -p epicbook-prod/ansible/roles/epicbook/templates</pre><pre>touch epicbook-prod/README.md<br>touch epicbook-prod/.vault_pass<br>touch epicbook-prod/.gitignore<br>touch epicbook-prod/terraform/{main.tf,provider.tf,output.tf,variable.tf,terraform.tfvars}<br>touch epicbook-prod/ansible/{inventory.ini,site.yml}<br>touch epicbook-prod/ansible/group_vars/web.yml<br>touch epicbook-prod/ansible/group_vars/vault.yml<br>touch epicbook-prod/ansible/roles/common/handlers/main.yml<br>touch epicbook-prod/ansible/roles/common/tasks/main.yml<br>touch epicbook-prod/ansible/roles/nginx/tasks/main.yml<br>touch epicbook-prod/ansible/roles/nginx/handlers/main.yml<br>touch epicbook-prod/ansible/roles/nginx/templates/epicbook.conf.j2<br>touch epicbook-prod/ansible/roles/epicbook/tasks/main.yml<br>touch epicbook-prod/ansible/roles/epicbook/templates/config.json.j2</pre><p>The content of each file can be found in my GitHub repository. I’ll attach that to the writeup at the very end.</p><h4>Note: Before running this project, ensure you have met the following prereqs:</h4><ul><li>An AWS account with <strong>AWS CLI</strong> configured (aws configure).</li><li><strong>Terraform</strong> (&gt;= 1.0) installed.</li><li><strong>Ansible</strong> installed in your local Python environment.</li><li>An SSH Key Pair generated</li></ul><p>From here, we can run the deployment in just three simple steps:</p><h4>Step 1: Infrastructure Provisioning</h4><p>Navigate to the terraform directory and apply the configuration:</p><pre>cd terraform<br>terraform init<br>terraform apply</pre><p><em>Output: Note the Public IP of the EC2 instance and the RDS Endpoint.</em></p><h4>Step 2: Configure Ansible</h4><ol><li>Update ansible/inventory.ini with the new Public IP and the DB Host.</li><li>Ensure your secret database password is stored in ansible/group_vars/vault.yml.</li><li>Encrypt your secrets file if you haven’t already:codeBash</li></ol><h4>Step 3: Run the Playbook</h4><p>From the root directory, execute the deployment:</p><pre>ansible-playbook -i ansible/inventory.ini ansible/site.yml --vault-password-file .vault_pass</pre><h4>Security First: Enter Ansible Vault</h4><p>One of the biggest risks in DevOps is “Secret Leakage” — accidentally pushing a database password to GitHub.</p><p>To solve this, I implemented <strong>Ansible Vault</strong>. Instead of hardcoding the database password in my vars.yml file, I moved it to an encrypted vault.yml file. This allows me to safely commit my configuration to version control while keeping the sensitive credentials under lock and key.</p><p>The .gitignore file is strictly configured to exclude .tfstate, .terraform/, and .vault_pass to prevent infrastructure drift and credential leaks.</p><h4>Issues Faced:</h4><p>No deployment is perfect. In fact, the most valuable lessons came from the moments the “Plan” failed.</p><p><strong>1. The Virtual Environment Trap</strong></p><p>When I first ran terraform plan, it crashed. I realized that while I had the AWS CLI installed on my machine, it wasn’t configured within the specific <strong>Python virtual environment</strong> I was using for this project.</p><ul><li><strong>Lesson:</strong> Always verify your environment’s path and tool access before starting a deployment.</li></ul><p><strong>2. The Case of the Missing .conf</strong></p><p>During the Nginx setup, my “Deploy” task was creating a file named epicbook.conf, but my “Enable” task was looking for a file named epicbook. The missing extension broke the symbolic link and the web server wouldn’t start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOixnkeKlDNQMsxH7Z38bA.png" /><figcaption>The playbook failed at first due to wrong configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYvSAVY5iRaDsLh9UFU0Pw.png" /><figcaption>Configuration was done, and fixed</figcaption></figure><ul><li><strong>Lesson:</strong> Consistency in naming conventions across tasks isn’t just about “neatness” — it’s about preventing broken dependencies in your automation.</li></ul><h4>Testing for Reliability (Idempotency)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aEQEkgMxHF2qal9kMiT1GQ.png" /><figcaption>Idempotency Testing</figcaption></figure><p>A key principle of Infrastructure as Code is <strong>Idempotency</strong>: the ability to run your code 100 times and get the same result every time without breaking anything.</p><p>After my first successful deployment, I reran the playbook. Seeing a sea of “OK” and “Skipping” (meaning no unnecessary changes were made) was the ultimate confirmation that the automation was stable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0P59bpJ1YH0eK0VE6AOs3w.png" /><figcaption>Testing the cart function of the live application</figcaption></figure><h4>Tearing down the whole infrastructure.</h4><p>To tear down the environment and avoid AWS costs:</p><pre>cd terraform<br>terraform destroy</pre><h4>Wrapping Up</h4><p>Moving from manual commands to a structured Terraform/Ansible workflow is a major shift in mindset. It’s the difference between “fixing a server” and “managing an environment.”</p><p>By focusing on modularity (Roles), security (Vault), and reliability (Idempotency), I’ve built a foundation that can scale.</p><p><strong>What’s next?</strong> I’m looking into integrating a CI/CD pipeline to trigger these deployments automatically on every code push.</p><h3>Tech Stack Used:</h3><ul><li><strong>IaC:</strong> Terraform</li><li><strong>Configuration:</strong> Ansible (Roles &amp; Vault)</li><li><strong>Cloud:</strong> AWS (EC2, RDS, VPC)</li><li><strong>Web:</strong> Nginx &amp; Node.js</li></ul><p><em>Check out the full repository here: </em><a href="https://github.com/Thormie-Harshey/epicbook-application.git">https://github.com/Thormie-Harshey/epicbook-application.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22c3d389af9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DEPLOYING A THREE-TIER BOOK REVIEW APPLICATION ON AWS WITH TERRAFORM: A COMPLETE GUIDE]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/deploying-a-three-tier-book-review-application-on-aws-with-terraform-a-complete-guide-b7afa29450a4?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7afa29450a4</guid>
            <category><![CDATA[three-tier-architecture]]></category>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Tue, 24 Mar 2026 09:24:19 GMT</pubDate>
            <atom:updated>2026-03-24T09:45:13.541Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. INTRODUCTION</h3><p>Modern cloud deployments are no longer just about launching servers, they are about building secure, scalable, and maintainable systems. To build these systems, we have to deploy infrastructure.</p><p>Deploying cloud infrastructure can be complex and error-prone. Terraform, an Infrastructure-as-Code (IaC) tool by HashiCorp, enables you to define, version, and manage AWS resources in a declarative manner.</p><p>This guide walks you through deploying a <strong>three-tier book review application</strong> on AWS using Terraform, following a modular Infrastructure as Code design. The application was divided into three logical layers:</p><ul><li><strong>Presentation Layer (Web Tier):</strong> Next.js frontend running on Ubuntu behind Nginx and a public Application Load Balancer</li><li><strong>Business Layer (App Tier):</strong> Node.js backend running on private EC2 instances behind an internal Application Load Balancer</li><li><strong>Data Layer (Database Tier):</strong> Amazon RDS for MySQL deployed across private subnets with Multi-AZ enabled</li></ul><p>By the end of this guide, you’ll have a fully operational application running on AWS with proper networking, security, load balancing, and database infrastructure.</p><h3>2. ARCHITECTURE OVERVIEW</h3><h4>2.1 Three-Tier Architecture</h4><p>The application follows a classic three-tier architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EQE8pAo7MyfrD-rnNJKXBg.png" /><figcaption>The 3 logical layers for the infrastructure</figcaption></figure><h4>2.2 Network Architecture</h4><p><strong>VPC CIDR</strong>: 10.0.0.0/16</p><p><strong>PUBLIC SUBNETS (Web Tier)</strong>:</p><ul><li>Subnet 1 (AZ-a): 10.0.1.0/24</li><li>Subnet 2 (AZ-b): 10.0.2.0/24</li><li>Has access to Internet via Internet Gateway</li><li>NAT Gateway for private subnet outbound traffic</li></ul><p><strong>PRIVATE APP SUBNETS (App Tier)</strong>:</p><ul><li>Subnet 1 (AZ-a): 10.0.3.0/24</li><li>Subnet 2 (AZ-b): 10.0.4.0/24</li><li>No direct internet access</li><li>Routes through NAT Gateway for outbound traffic</li></ul><p><strong>PRIVATE DB SUBNETS (Database Tier)</strong>:</p><ul><li>Subnet 1 (AZ-a): 10.0.5.0/24</li><li>Subnet 2 (AZ-b): 10.0.6.0/24</li><li>Completely isolated from internet</li><li>Multi-AZ RDS deployment</li></ul><p>Six subnets were created across two Availability Zones. This gives us high availability and fault tolerance.</p><h4>2.3 Security Architecture</h4><p>Five security groups enforce the principle of least privilege:</p><p><strong>Web ALB Security Group</strong></p><p>Allows: HTTP (80) from 0.0.0.0/0</p><p><strong>Web EC2 Security Group</strong><br> Allows: HTTP (80) from Web ALB SG only Allows: SSH (22) from admin IP</p><p><strong>App ALB Security Group</strong><br> Allows: Port 3001 from Web EC2 SG only</p><p><strong>App EC2 Security Group</strong><br> Allows: Port 3001 from App ALB SG only Allows: SSH (22) from Web EC2 (bastion)</p><p><strong>Database Security Group</strong><br> Allows: MySQL (3306) from App EC2 SG</p><p>This creates a strict trust chain:</p><pre>Internet → Web Tier → App Tier → Database Tier</pre><h3>3. PLANNING YOUR INFRASTRUCTURE</h3><h4>3.1 Prerequisites</h4><p>Before writing Terraform code, ensure you have:</p><ol><li>AWS Account with appropriate permissions</li><li>AWS CLI configured (aws configure)</li><li>Terraform installed (version 1.5.0 or later)</li><li>AWS key pair created (aws-ft in our case)</li><li>SSH key pair downloaded locally</li></ol><h4>3.2 Directory Structure</h4><p>The recommended modular structure organizes code logically:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*NLOKfXVf7qRgfy-fV8Gcbw.png" /><figcaption>The directory structure</figcaption></figure><h3>4. WRITING TERRAFORM CONFIGURATION FILES</h3><h4>4.1 The Root Module (main.tf)</h4><p>The root module serves as the orchestration layer, calling all child modules:</p><pre>terraform {<br>  required_version = &quot;&gt;= 1.5.0&quot;<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 5.0&quot;<br>    }<br>  }<br>}<br><br>provider &quot;aws&quot; {<br>  region = var.region<br>}<br><br># VPC Module - Creates network infrastructure<br>module &quot;vpc&quot; {<br>  source = &quot;./modules/vpc&quot;<br><br>  vpc_cidr                  = var.vpc_cidr<br>  region                    = var.region<br>  project_name              = var.project_name<br>  public_subnet_1_cidr      = var.public_subnet_1_cidr<br>  public_subnet_2_cidr      = var.public_subnet_2_cidr<br>  private_app_subnet_1_cidr = var.private_app_subnet_1_cidr<br>  private_app_subnet_2_cidr = var.private_app_subnet_2_cidr<br>  private_db_subnet_1_cidr  = var.private_db_subnet_1_cidr<br>  private_db_subnet_2_cidr  = var.private_db_subnet_2_cidr<br>}<br><br># Security Groups Module - Creates security rules<br>module &quot;security_groups&quot; {<br>  source = &quot;./modules/security_groups&quot;<br><br>  vpc_id       = module.vpc.vpc_id<br>  project_name = var.project_name<br>  ssh_cidr     = var.ssh_cidr<br>}<br><br># ALB Module - Creates load balancers<br>module &quot;alb&quot; {<br>  source = &quot;./modules/alb&quot;<br><br>  vpc_id                  = module.vpc.vpc_id<br>  project_name            = var.project_name<br>  web_alb_sg_id           = module.security_groups.web_alb_sg_id<br>  app_alb_sg_id           = module.security_groups.app_alb_sg_id<br>  public_subnet_1_id      = module.vpc.public_subnet_1_id<br>  public_subnet_2_id      = module.vpc.public_subnet_2_id<br>  private_app_subnet_1_id = module.vpc.private_app_subnet_1_id<br>  private_app_subnet_2_id = module.vpc.private_app_subnet_2_id<br>}<br><br># EC2 Module - Creates compute instances<br>module &quot;ec2&quot; {<br>  source = &quot;./modules/ec2&quot;<br><br>  instance_type           = var.instance_type<br>  key_name                = var.key_name<br>  project_name            = var.project_name<br>  public_subnet_1_id      = module.vpc.public_subnet_1_id<br>  private_app_subnet_1_id = module.vpc.private_app_subnet_1_id<br>  web_ec2_sg_id           = module.security_groups.web_ec2_sg_id<br>  app_ec2_sg_id           = module.security_groups.app_ec2_sg_id<br>  web_target_group_arn    = module.alb.web_target_group_arn<br>  app_target_group_arn    = module.alb.app_target_group_arn<br>}<br><br># RDS Module - Creates database<br>module &quot;rds&quot; {<br>  source = &quot;./modules/rds&quot;<br><br>  project_name           = var.project_name<br>  db_sg_id               = module.security_groups.db_sg_id<br>  private_db_subnet_1_id = module.vpc.private_db_subnet_1_id<br>  private_db_subnet_2_id = module.vpc.private_db_subnet_2_id<br>  db_instance_class      = var.db_instance_class<br>  db_allocated_storage   = var.db_allocated_storage<br>  db_name                = var.db_name<br>  db_username            = var.db_username<br>  db_password            = var.db_password<br>}</pre><p>Key Points:</p><ul><li>Terraform version requirement ensures consistent behavior</li><li>Provider block specifies AWS as the cloud provider</li><li>Each module call passes outputs from previous modules as inputs</li><li>This creates implicit dependencies that Terraform respects</li></ul><h4><strong>4.2 Variables Declaration (variables.tf)</strong></h4><p>Define all input variables with descriptions and defaults:</p><pre># General Variables<br>variable &quot;region&quot; {<br>  description = &quot;AWS region&quot;<br>  type        = string<br>  default     = &quot;eu-north-1&quot;<br>}<br><br>variable &quot;project_name&quot; {<br>  description = &quot;Project name used for tagging and naming resources&quot;<br>  type        = string<br>  default     = &quot;bookreview&quot;<br>}<br><br># Network Variables<br>variable &quot;vpc_cidr&quot; {<br>  description = &quot;CIDR block for the VPC&quot;<br>  type        = string<br>  default     = &quot;10.0.0.0/16&quot;<br>}<br><br>variable &quot;public_subnet_1_cidr&quot; {<br>  description = &quot;CIDR for public subnet 1 (Web Tier, AZ-a)&quot;<br>  type        = string<br>  default     = &quot;10.0.1.0/24&quot;<br>}<br><br>variable &quot;public_subnet_2_cidr&quot; {<br>  description = &quot;CIDR for public subnet 2 (Web Tier, AZ-b)&quot;<br>  type        = string<br>  default     = &quot;10.0.2.0/24&quot;<br>}<br><br>variable &quot;private_app_subnet_1_cidr&quot; {<br>  description = &quot;CIDR for private app subnet 1 (App Tier, AZ-a)&quot;<br>  type        = string<br>  default     = &quot;10.0.3.0/24&quot;<br>}<br><br>variable &quot;private_app_subnet_2_cidr&quot; {<br>  description = &quot;CIDR for private app subnet 2 (App Tier, AZ-b)&quot;<br>  type        = string<br>  default     = &quot;10.0.4.0/24&quot;<br>}<br><br>variable &quot;private_db_subnet_1_cidr&quot; {<br>  description = &quot;CIDR for private DB subnet 1 (DB Tier, AZ-a)&quot;<br>  type        = string<br>  default     = &quot;10.0.5.0/24&quot;<br>}<br><br>variable &quot;private_db_subnet_2_cidr&quot; {<br>  description = &quot;CIDR for private DB subnet 2 (DB Tier, AZ-b)&quot;<br>  type        = string<br>  default     = &quot;10.0.6.0/24&quot;<br>}<br><br># EC2 Variables<br>variable &quot;instance_type&quot; {<br>  description = &quot;EC2 instance type for web and app tiers&quot;<br>  type        = string<br>  default     = &quot;t3.micro&quot;<br>}<br><br>variable &quot;key_name&quot; {<br>  description = &quot;AWS key pair name for EC2 SSH access&quot;<br>  type        = string<br>  # No default - must be provided in terraform.tfvars<br>}<br><br># RDS Variables<br>variable &quot;db_instance_class&quot; {<br>  description = &quot;RDS instance class&quot;<br>  type        = string<br>  default     = &quot;db.t3.micro&quot;<br>}<br><br>variable &quot;db_allocated_storage&quot; {<br>  description = &quot;Allocated storage in GB for RDS&quot;<br>  type        = number<br>  default     = 20<br>}<br><br>variable &quot;db_name&quot; {<br>  description = &quot;Database name&quot;<br>  type        = string<br>  # No default - must be provided in terraform.tfvars<br>}<br><br>variable &quot;db_username&quot; {<br>  description = &quot;Database master username&quot;<br>  type        = string<br>  # No default - must be provided in terraform.tfvars<br>}<br><br>variable &quot;db_password&quot; {<br>  description = &quot;Database master password&quot;<br>  type        = string<br>  sensitive   = true<br>  # No default - must be provided in terraform.tfvars<br>}</pre><p>Key Points:</p><ul><li>Variables with defaults are optional</li><li>Variables without defaults are required</li><li>sensitive = true hides values in terraform output</li><li>Descriptions help team members understand each variable</li></ul><h4><strong>4.3 terraform.tfvars File</strong></h4><p>Create this file with your actual values. NEVER commit this to Git!</p><pre>region               = &quot;eu-north-1&quot;<br>project_name         = &quot;bookreview&quot;<br>vpc_cidr             = &quot;10.0.0.0/16&quot;<br>public_subnet_1_cidr = &quot;10.0.1.0/24&quot;<br>public_subnet_2_cidr = &quot;10.0.2.0/24&quot;<br>private_app_subnet_1_cidr = &quot;10.0.3.0/24&quot;<br>private_app_subnet_2_cidr = &quot;10.0.4.0/24&quot;<br>private_db_subnet_1_cidr  = &quot;10.0.5.0/24&quot;<br>private_db_subnet_2_cidr  = &quot;10.0.6.0/24&quot;<br><br>instance_type = &quot;t3.micro&quot;<br>key_name      = &quot;aws-ft&quot;<br><br>db_instance_class = &quot;db.t3.micro&quot;<br>db_allocated_storage = 20<br>db_name             = &quot;bookreview&quot;<br>db_username         = &quot;admin&quot;<br>db_password         = &quot;YourSecurePassword123!&quot;</pre><h4><strong>4.4 Outputs (outputs.tf)</strong></h4><p>Define outputs to display important values after deployment:</p><pre>output &quot;web_alb_dns_name&quot; {<br>  description = &quot;Public ALB DNS name — use this to access the frontend&quot;<br>  value       = module.alb.web_alb_dns_name<br>}<br><br>output &quot;app_alb_dns_name&quot; {<br>  description = &quot;Internal ALB DNS name — used by web tier to reach backend&quot;<br>  value       = module.alb.app_alb_dns_name<br>}<br><br>output &quot;web_instance_id&quot; {<br>  description = &quot;Web EC2 instance ID&quot;<br>  value       = module.ec2.web_instance_id<br>}<br><br>output &quot;web_instance_public_ip&quot; {<br>  description = &quot;Web EC2 public IP&quot;<br>  value       = module.ec2.web_instance_public_ip<br>}<br><br>output &quot;app_instance_id&quot; {<br>  description = &quot;App EC2 instance ID&quot;<br>  value       = module.ec2.app_instance_id<br>}<br><br>output &quot;app_instance_private_ip&quot; {<br>  description = &quot;App EC2 private IP&quot;<br>  value       = module.ec2.app_instance_private_ip<br>}<br><br>output &quot;db_endpoint&quot; {<br>  description = &quot;RDS MySQL endpoint&quot;<br>  value       = module.rds.db_endpoint<br>}</pre><h4><strong>4.5 .gitignore Configuration</strong></h4><p>With this file present in the root directory, it will prevent committing sensitive files:</p><pre># Terraform state files<br>*.tfstate<br>*.tfstate.*<br>terraform.tfstate<br>terraform.tfstate.backup<br><br># Terraform variables (contains secrets!)<br>terraform.tfvars<br>terraform.tfvars.json<br>*.auto.tfvars<br><br># Local Terraform directory<br>.terraform/<br>.terraform.lock.hcl<br><br># IDE files<br>.vscode/<br>*.swp<br>*.swo</pre><h3>5. INFRASTRUCTURE COMPONENTS</h3><p>I shall be generating some of the code snippets used in this infrastructure, touching each module that was used in this deployment.</p><h4><strong>5.1 VPC Module (modules/vpc/main.tf)</strong></h4><p>Creates the foundational network infrastructure:</p><p>AWS VPC Configuration:</p><pre>resource &quot;aws_vpc&quot; &quot;main&quot; {<br>  cidr_block           = var.vpc_cidr<br>  enable_dns_support   = true<br>  enable_dns_hostnames = true<br>  tags = {<br>    Name    = &quot;bookreview-vpc&quot;<br>    Project = var.project_name<br>  }<br>}</pre><p>Internet Gateway (enables public internet access):</p><pre>resource &quot;aws_internet_gateway&quot; &quot;main&quot; {<br>  vpc_id = aws_vpc.main.id<br>  tags = {<br>    Name    = &quot;bookreview-igw&quot;<br>    Project = var.project_name<br>  }<br>}</pre><p><strong>Public Subnets (for web tier):</strong></p><ul><li>Automatically assign public IPs to instances</li><li>Route traffic to Internet Gateway</li></ul><p><strong>Private Subnets (for app and database tiers):</strong></p><ul><li>No direct internet access</li><li>Route outbound traffic through NAT Gateway</li></ul><p><strong>NAT Gateway </strong>(provides private subnet internet access):</p><pre>resource &quot;aws_nat_gateway&quot; &quot;main&quot; {<br>  allocation_id = aws_eip.nat.id  # Elastic IP for stability<br>  subnet_id     = aws_subnet.public_1.id<br>  depends_on    = [aws_internet_gateway.main]<br>}</pre><h4><strong>5.2 Security Groups Module (modules/security_groups/main.tf)</strong></h4><p>Implements a layered security model:</p><p>Web ALB Security Group:</p><pre>resource &quot;aws_security_group&quot; &quot;web_alb&quot; {<br>  name = &quot;bookreview-web-alb-sg&quot;<br>  ingress {<br>    from_port   = 80<br>    to_port     = 80<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]  # HTTP from anywhere<br>  }<br>}</pre><p>We also have:</p><p><strong>Web EC2 Security Group:</strong></p><ul><li>Allows HTTP from Web ALB only</li><li>Allows SSH from admin IP (ssh_cidr variable)</li><li>Denies all other inbound traffic</li></ul><p><strong>App ALB Security Group:</strong></p><ul><li>Allows port 3001 from Web EC2 security group only</li><li>No direct internet access</li></ul><p><strong>App EC2 Security Group:</strong></p><ul><li>Allows port 3001 from App ALB only</li><li>Allows SSH from Web EC2 (bastion pattern)</li></ul><p><strong>Database Security Group:</strong></p><ul><li>Allows MySQL (3306) from App EC2 only</li><li>Most restrictive — completely isolated</li></ul><h4>5.3 Load Balancers Module (modules/alb/main.tf)</h4><p>Public ALB (Web Tier):</p><pre>resource &quot;aws_lb&quot; &quot;web&quot; {<br>  name               = &quot;bookreview-web-alb&quot;<br>  internal           = false  # Internet-facing<br>  load_balancer_type = &quot;application&quot;<br>  security_groups    = [var.web_alb_sg_id]<br>  subnets            = [var.public_subnet_1_id, var.public_subnet_2_id]<br>}</pre><p>Features:</p><ul><li>Spans two availability zones for high availability</li><li>Distributes traffic to web EC2 instances</li><li>Health checks every 30 seconds</li><li>Replaces unhealthy instances</li></ul><p><strong>Internal ALB (App Tier):</strong></p><pre>resource &quot;aws_lb&quot; &quot;app&quot; {<br>  name               = &quot;bookreview-app-alb&quot;<br>  internal           = true  # NOT internet-facing<br>  load_balancer_type = &quot;application&quot;<br>  subnets            = [var.private_app_subnet_1_id, var.private_app_subnet_2_id]<br>}</pre><p>Features:</p><ul><li>Only accessible from within VPC</li><li>Routes traffic on port 3001</li><li>Health check endpoint: /health</li><li>Essential for inter-tier communication</li></ul><h4><strong>5.4 EC2 Module (modules/ec2/main.tf)</strong></h4><p>Web Tier EC2:</p><pre>resource &quot;aws_instance&quot; &quot;web&quot; {<br>  ami                    = data.aws_ami.ubuntu.id<br>  instance_type          = var.instance_type<br>  subnet_id              = var.public_subnet_1_id<br>  vpc_security_group_ids = [var.web_ec2_sg_id]<br>  key_name               = var.key_name<br>  associate_public_ip_address = true<br>}</pre><p>Key Features:</p><ul><li>Latest Ubuntu 22.04 LTS AMI (via data source)</li><li>Public IP automatically assigned</li><li>Attached to web ALB target group</li><li>Accessible via SSH for maintenance</li></ul><p><strong>App Tier EC2:</strong></p><pre>resource &quot;aws_instance&quot; &quot;app&quot; {<br>  ami                    = data.aws_ami.ubuntu.id<br>  instance_type          = var.instance_type<br>  subnet_id              = var.private_app_subnet_1_id<br>  vpc_security_group_ids = [var.app_ec2_sg_id]<br>  key_name               = var.key_name<br>  # Note: No public IP assigned for security<br>}</pre><p>Key Features:</p><ul><li>No public IP (private subnet)</li><li>Only accessible via bastion (web EC2)</li><li>Attached to app ALB target group</li><li>Outbound internet access via NAT Gateway</li></ul><h4><strong>5.5 RDS Module (modules/rds/main.tf)</strong></h4><pre>resource &quot;aws_db_instance&quot; &quot;main&quot; {<br>  identifier     = &quot;bookreview-db&quot;<br>  engine         = &quot;mysql&quot;<br>  engine_version = &quot;8.0&quot;<br>  instance_class = var.db_instance_class<br><br>  allocated_storage = var.db_allocated_storage<br>  storage_type     = &quot;gp2&quot;<br><br>  db_name  = var.db_name<br>  username = var.db_username<br>  password = var.db_password<br><br>  multi_az               = true  # High availability<br>  publicly_accessible    = false  # Not on internet<br>  skip_final_snapshot    = false<br><br>  db_subnet_group_name   = aws_db_subnet_group.main.name<br>  vpc_security_group_ids = [var.db_sg_id]<br>}</pre><p>Key Features:</p><ul><li>Multi-AZ: Synchronous replication to standby instance</li><li>Automated failover: If primary fails, standby promoted automatically</li><li>Backups: Daily automated backups retained for 7 days</li><li>Private subnet: Not accessible from internet</li><li>MySQL 8.0: Modern relational database engine</li></ul><h3>6. DEPLOYING THE INFRASTRUCTURE</h3><h4><strong>6.1 Initialize Terraform</strong></h4><p>The first step downloads provider plugins and initializes the working directory:terraform init</p><p>Output:</p><ul><li>Downloads AWS provider (version ~&gt; 5.0)</li><li>Creates .terraform directory with plugins</li><li>Initializes Terraform state backend (local by default)</li><li>Ready for planning and applying</li></ul><h4>6.2 Validate Configuration</h4><p>Check syntax and logic errors before planning:terraform validate</p><p>This verifies:</p><ul><li>HCL syntax is correct</li><li>Resource types are valid</li><li>Required arguments are present</li><li>Module references are correct</li></ul><h4>6.3 Format Code (Optional but Recommended)</h4><p>Terraform has opinions on formatting. Enforce consistency:terraform fmt -recursive</p><p>This:</p><ul><li>Standardizes indentation (2 spaces)</li><li>Aligns attributes for readability</li><li>Sorts blocks consistently</li><li>Helps with code reviews</li></ul><h4>6.4 Plan Deployment</h4><p>Preview all changes before applying:terraform plan</p><p>This produces:</p><ul><li>List of resources to create</li><li>List of resources to modify (if any)</li><li>List of resources to delete (if any)</li><li>Resource dependency order</li><li>Output values preview</li></ul><p>Sample output excerpt: Terraform will perform the following actions:</p><ul><li>aws_vpc.main</li><li>cidr_block = “10.0.0.0/16”</li><li>enable_dns_hostnames = true</li><li>enable_dns_support = true</li><li>aws_subnet.public_1</li><li>cidr_block = “10.0.1.0/24”</li><li>availability_zone = “eu-north-1a”</li><li>map_public_ip_on_launch = true</li></ul><p>[… many more resources …]</p><p>Plan: 37 resources to be created, 0 to be modified, 0 to be destroyed.</p><h4><strong>6.5 Apply Configuration</strong></h4><p>Deploy the infrastructure to AWS:terraform apply</p><p>Terraform will:</p><ol><li>Prompt “Do you want to perform these actions? (yes/no)”</li><li>Create resources in dependency order</li><li>Display progress for each resource</li><li>Return output values upon completion</li></ol><p>Expected Duration:</p><ul><li>VPC and subnets: ~10 seconds</li><li>Security groups: ~5 seconds</li><li>NAT Gateway: ~2–3 minutes (slowest)</li><li>Load balancers: ~2–3 minutes</li><li>EC2 instances: ~1–2 minutes</li><li>RDS database: ~5–10 minutes</li><li>Total: ~15–20 minutes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*Dbk8tIsXIWy3tHiGwefjQQ.png" /><figcaption>Resources added</figcaption></figure><h4><strong>6.6 View Outputs</strong></h4><p>After successful apply, retrieve important values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Dbk8tIsXIWy3tHiGwefjQQ.png" /><figcaption>Output needed for deployment purposes</figcaption></figure><p>Save these values because you’ll need them for application deployment.</p><h3>7. CONFIGURING THE APPLICATIONS</h3><h4><strong>7.1 Prerequisites for Application Deployment</strong></h4><p>Before installing applications, ensure:</p><ol><li>EC2 instances are fully initialized (status checks passed)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCBJCZrKYPKxIpnpQYNYQA.png" /><figcaption>Ec2 fully initialized</figcaption></figure><p>2. RDS database is available (Status: available in AWS console)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uBlqpM5FATha-con_UQRFw.png" /><figcaption>RDS provisioned</figcaption></figure><p>3. Load balancers are healthy (Health: Healthy in target groups)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kly_JluSShekfZ9V_nBpKQ.png" /><figcaption>Load Balancer ready</figcaption></figure><p>4. Security groups are properly configured</p><p>5. You have SSH access to the web EC2 instance</p><h4><strong>7.2 SSH into the Web EC2 Instance</strong></h4><p><strong>Connect to the public web server:</strong></p><pre>$ chmod 400 keypair.pem $ ssh -i keypair.pem ubuntu@&lt;web_instance_public_ip&gt;<br># Example: ssh -i aws-ft.pem ubuntu@16.171.5.42</pre><p>You should see:</p><pre>Welcome to Ubuntu 22.04.x LTS (GNU/Linux 5.15.0-…) ubuntu@ip-10–0–1–100:~$</pre><h4>7.3 Frontend Deployment (Next.js on Web EC2)</h4><p>Step 1: Update system packages</p><pre>ubuntu@web:~$ sudo apt update<br>ubuntu@web:~$ sudo apt install nginx git -y</pre><p>Step 2: Install Node.js 20.x LTS</p><pre>ubuntu@web:~$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -<br>ubuntu@web:~$ sudo apt install nodejs -y</pre><p>Verify:</p><pre>ubuntu@web:~$ node --version<br>v20.x.x</pre><p>Step 3: Install PM2 (process manager)</p><pre>ubuntu@web:~$ sudo npm install -g pm2</pre><p>Step 4: Clone and build frontend</p><pre>ubuntu@web:~$ git clone https://github.com/pravinmishraaws/book-review-app<br>ubuntu@web:~$ cd book-review-app/frontend<br>ubuntu@web:~/book-review-app/frontend$ npm install</pre><p>Step 5: Create environment file</p><pre>ubuntu@web:~/book-review-app/frontend$ cat &gt; .env.local &lt;&lt; EOF<br>NEXT_PUBLIC_API_URL=/api<br>EOF</pre><p>Step 6: Build Next.js application</p><pre>ubuntu@web:~/book-review-app/frontend$ npm run build</pre><p>Expected output: ✓ Compiled successfully</p><p>✓ Linting and checking validity of types</p><p>✓ Collecting page data</p><p>✓ Generating static pages (4/4)</p><p>✓ Finalizing page optimization</p><p>▲ Next.js 14.x.x</p><p>Step 7: Start frontend with PM2</p><pre>ubuntu@web:~/book-review-app/frontend$ pm2 start npm --name frontend -- start</pre><p>Step 8: Enable PM2 startup</p><pre>ubuntu@web:~$ pm2 startup<br>ubuntu@web:~$ pm2 save</pre><p>This ensures the frontend restarts if the instance reboots.</p><p>Step 9: Configure Nginx as reverse proxy</p><p>Get the internal ALB DNS name from terraform output:</p><pre>ubuntu@web:~$ sudo vi /etc/nginx/sites-available/default</pre><p>Replace entire file with:</p><pre>server {<br>listen 80;<br>server_name _;<br># Forward API calls to the internal ALB (Node.js backend on port 3001)<br>location /api/ {<br>    proxy_pass &lt;http://bookreview-app-alb-1234567890.eu-north-1.elb.amazonaws.com:3001/api/&gt;;<br>    proxy_http_version 1.1;<br>    proxy_set_header Host $host;<br>    proxy_set_header X-Real-IP $remote_addr;<br>    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>}<br># Forward all other requests to the Next.js app (running on port 3000)<br>location / {<br>    proxy_pass &lt;http://localhost:3000&gt;;<br>    proxy_http_version 1.1;<br>    proxy_set_header Upgrade $http_upgrade;<br>    proxy_set_header Connection &#39;upgrade&#39;;<br>    proxy_set_header Host $host;<br>    proxy_cache_bypass $http_upgrade;<br>}<br>}</pre><blockquote>Note: Replace “bookreview-app-alb-1234567890.eu-north-1.elb.amazonaws.com” with your actual internal ALB DNS name from terraform output.</blockquote><p>Step 10: Test and enable Nginx</p><pre>ubuntu@web:~$ sudo nginx -t</pre><p>Expected output:</p><pre>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok<br>nginx: configuration file /etc/nginx/nginx.conf test is successful<br>ubuntu@web:~$ sudo systemctl reload nginx<br>ubuntu@web:~$ sudo systemctl enable nginx</pre><p>Step 11: Verify frontend is running</p><pre>ubuntu@web:~$ curl localhost</pre><p>Should return HTML content starting with &lt;!DOCTYPE html&gt;</p><h4>7.4 Backend Deployment (Node.js on App EC2)</h4><p>The app EC2 instance is private and not directly accessible. SSH to it through the web EC2 instance (bastion pattern):</p><pre>$ ssh -i keypairpem -J ubuntu@&lt;web_public_ip&gt; ubuntu@&lt;app_private_ip&gt;<br># Example:<br>$ ssh -i aws-ft.pem -J [ubuntu@16.171.5.42](&lt;mailto:ubuntu@16.171.5.42&gt;) [ubuntu@10.0.3.10](&lt;mailto:ubuntu@10.0.3.10&gt;)</pre><p>Step 1: Update system packages</p><pre>ubuntu@app:~$ sudo apt update &amp;&amp; sudo apt upgrade -y<br>ubuntu@app:~$ sudo apt install git mysql-client -y</pre><p>Step 2: Install Node.js 20.x LTS</p><pre>ubuntu@app:~$ curl -fsSL &lt;https://deb.nodesource.com/setup_20.x&gt; | sudo -E bash -<br>ubuntu@app:~$ sudo apt install nodejs -y</pre><p>Step 3: Install PM2</p><pre>ubuntu@app:~$ sudo npm install -g pm2</pre><p>Step 4: Clone and install backend</p><pre>ubuntu@app:~$ git clone &lt;https://github.com/pravinmishraaws/book-review-app&gt;<br>ubuntu@app:~$ cd book-review-app/backend<br>ubuntu@app:~/book-review-app/backend$ npm install</pre><p>Step 5: Create environment file</p><pre>ubuntu@app:~/book-review-app/backend$ cat &gt; .env &lt;&lt; EOF<br>DB_HOST=[bookreview-db.c9akciq32.eu-north-1.rds.amazonaws.com](&lt;http://bookreview-db.c9akciq32.eu-north-1.rds.amazonaws.com/&gt;)<br>DB_USER=admin<br>DB_PASSWORD=Password123!<br>DB_NAME=bookreview<br>PORT=3001<br>ALLOWED_ORIGIN=http://bookreview-web-alb-0987654321.eu-north-1.elb.amazonaws.com<br>EOF</pre><p>Note: Replace values with your actual outputs:</p><ul><li>DB_HOST: from terraform output “db_endpoint” (without :3306)</li><li>DB_PASSWORD: from your terraform.tfvars</li><li>ALLOWED_ORIGIN: from terraform output “web_alb_dns_name”</li></ul><p>Step 6: Initialize database schema</p><pre>ubuntu@app:~$ mysql -h [bookreview-db.c9akciq32.eu-north-1.rds.amazonaws.com](&lt;http://bookreview-db.c9akciq32.eu-north-1.rds.amazonaws.com/&gt;) \\<br>-u admin -pPassword123! bookreview &lt; db/schema.sql</pre><p>Expected: Command completes silently (no errors)</p><p>Step 7: Start backend with PM2</p><pre>ubuntu@app:~/book-review-app/backend$ pm2 start src/server.js --name backend</pre><p>Step 8: Enable PM2 startup</p><pre>ubuntu@app:~$ pm2 startup<br>ubuntu@app:~$ pm2 save</pre><p>Step 9: Verify backend is running</p><pre>ubuntu@app:~$ curl localhost:3001/health</pre><p>Expected response: {“status”:”ok”,”timestamp”:”2024–01–20T10:30:45Z”}</p><p>Congratulations! Both frontend and backend are now running!</p><h3>8. TESTING AND VERIFICATION</h3><h4>8.1 Test Frontend Access</h4><p>Open a browser and navigate to the web ALB DNS name:</p><p>http://bookreview-web-alb-0987654321.eu-north-1.elb.amazonaws.com</p><p>You should see:</p><ul><li>The book review application homepage</li><li>Fully styled Next.js interface</li><li>Responsive design working correctly</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i0y83-F-NHSAUC3umIcmmA.png" /><figcaption>Application Homepage</figcaption></figure><p>8.2 Test Backend Connectivity</p><p>From the web instance, test the internal ALB:</p><pre>ubuntu@web:~$ curl &lt;http://bookreview-app-alb-1234567890.eu-north-1.elb.amazonaws.com:3001/health&gt;</pre><p>Expected response: {“status”:”ok”,”timestamp”:”2024–01–20T10:30:45Z”}</p><p>8.3 Test Database Connectivity</p><p>From the app instance, verify database connection:</p><pre>ubuntu@app:~$ mysql -h [bookreview-db.c9akciq32.eu-north-1.rds.amazonaws.com](&lt;http://bookreview-db.c9akciq32.eu-north-1.rds.amazonaws.com/&gt;) \\<br>-u admin -pPassword123! -e &quot;SHOW DATABASES;&quot;</pre><h4>8.4 View Application Logs</h4><p>Frontend logs:</p><pre>ubuntu@web:~$ pm2 logs frontend</pre><p>Backend logs:</p><pre>ubuntu@app:~$ pm2 logs backend</pre><h4>8.5 Simulate a Request Flow</h4><p>Complete flow from browser to database:</p><ol><li>Browser sends request to: <a href="http://web-alb/">http://web-alb</a>.../</li><li>Web ALB routes to: web-ec2 (port 80)</li><li>Nginx listens on port 80</li><li>Nginx reverse proxies to: Next.js on localhost:3000</li><li>User sees frontend</li></ol><p>When user clicks a book to drop a review:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T_UW2QKhrjRNtXto_RDYFQ.png" /><figcaption>A user picks a book</figcaption></figure><ol><li>Browser sends request to: /api/books/1</li><li>Nginx sees /api/ and routes to: internal-alb:3001</li><li>App ALB routes to: app-ec2 (port 3001)</li><li>Node.js backend receives and processes request</li><li>Backend connects to: RDS database</li><li>Query executes and returns book data</li><li>Backend sends response back to frontend</li><li>Frontend renders and displays data</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QZi8Wwd3tzJjzJ_Ld-Tqg.png" /><figcaption>Review was successful</figcaption></figure><h3>9. CONCLUSION</h3><p>With this successful and comprehensive deployment of a three-tier application on AWS using Terraform, you have been able to accomplish:</p><p>✓ Infrastructure as Code: Created modular, reusable Terraform configuration</p><p>✓ Network Architecture: Built a VPC with 6 subnets across 2 availability zones</p><p>✓ Security: Implemented layered security groups following least-privilege</p><p>✓ Load Balancing: Deployed public and internal load balancers for traffic</p><p>✓ Compute: Launched EC2 instances with proper IAM and key pair management</p><p>✓ Database: Provisioned RDS MySQL with Multi-AZ for high availability</p><p>✓ Application Deployment: Installed and configured Next.js and Node.js</p><p>✓ Reverse Proxy: Set up Nginx to route traffic between tiers</p><h4>Key Takeaways:</h4><ol><li>Modular Design: Separating infrastructure into modules makes code reusable and maintainable.</li><li>Infrastructure as Code: Terraform provides version control, reproducibility, and easy rollback of infrastructure changes.</li><li>Security First: Security groups implement defense in depth with each tier only accessing what it needs.</li><li>High Availability: Multi-AZ deployments (load balancers, RDS) provide automatic failover and disaster recovery.</li><li>Auto-recovery: Load balancers automatically replace unhealthy instances, and RDS can failover to standby replicas.</li></ol><h4>Next Steps:</h4><p>You can take this project further by:</p><p>→ Automating deployments using CI/CD (GitHub Actions, GitLab CI)</p><p>→ Implementing auto-scaling based on CPU or request metrics</p><p>→ Adding HTTPS/TLS encryption for production security</p><p>→ Implementing database backups and point-in-time recovery</p><p>→ Monitoring infrastructure with CloudWatch dashboards and alarms</p><p>→ Setting up automatic scaling policies for traffic spikes</p><p>→ Implementing container orchestration with ECS or EKS</p><p>→ Setting up AWS Backup for centralized backup management</p><h4>Troubleshooting Tips:</h4><p><strong>If frontend can’t reach backend:</strong></p><ul><li>Check app ALB security group allows traffic from web EC2</li><li>Verify app EC2 is healthy in target group</li><li>Confirm Nginx proxy_pass URL is correct</li></ul><p><strong>If database connection fails:</strong></p><ul><li>Verify RDS security group allows port 3306 from app EC2</li><li>Check environment variables in app instance</li><li>Confirm RDS database is available (not creating/rebooting)</li><li>Verify credentials in .env file</li></ul><p><strong>If EC2 instance is unreachable:</strong></p><ul><li>Confirm security group allows SSH from your IP</li><li>Verify instance is running (not stopping/stopped)</li><li>Check subnet route tables have proper routes</li><li>Verify key pair permissions (chmod 600)</li></ul><h4>Destroying Infrastructure:</h4><p>When you’re done and want to clean up (careful — this deletes everything):</p><pre>terraform destroy</pre><p>Terraform will:</p><ul><li>List all resources to be deleted</li><li>Prompt for confirmation</li><li>Delete resources in reverse dependency order</li><li>Take 10–15 minutes total</li></ul><p>This frees up AWS resources and stops incurring charges.</p><h3>THE END</h3><p>For more information:</p><ul><li>Terraform Documentation: <a href="https://www.terraform.io/docs">https://www.terraform.io/docs</a></li><li>AWS Terraform Provider: <a href="https://registry.terraform.io/providers/hashicorp/aws">https://registry.terraform.io/providers/hashicorp/aws</a></li><li>AWS Well-Architected Framework: <a href="https://aws.amazon.com/architecture/well-architected/">https://aws.amazon.com/architecture/well-architected/</a></li><li>Infrastructure as Code Best Practices: <a href="https://www.terraform.io/cloud-docs/guides/recommended-practices">https://www.terraform.io/cloud-docs/guides/recommended-practices</a></li></ul><p>Good luck with your cloud infrastructure journey!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7afa29450a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agentic DevOps: Less Writing Infrastructure Codes, More Designing AI-Driven Delivery Systems]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/agentic-devops-less-writing-infrastructure-codes-more-designing-ai-driven-delivery-systems-9d3feeec8a17?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d3feeec8a17</guid>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Fri, 13 Mar 2026 20:16:27 GMT</pubDate>
            <atom:updated>2026-03-13T20:16:27.868Z</atom:updated>
            <content:encoded><![CDATA[<p>Traditional DevOps has always promised speed, automation, and consistency. Yet in practice, one major bottleneck remains: engineers still spend most of their time writing repetitive code, configurations, and infrastructure definitions rather than making higher-value engineering decisions.</p><p>If we roughly break down a traditional workflow, nearly 80% of effort goes into implementation — writing Terraform, editing configs, wiring deployments, troubleshooting syntax — while only 20% is spent on actual decision-making.</p><p>That imbalance is exactly where <strong>Agentic DevOps</strong> becomes powerful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*IYcelEWuyn_QTGAHVIRv_A.png" /><figcaption>The Agentic Loop</figcaption></figure><p>Instead of treating AI as a chatbot that answers isolated questions, Agentic DevOps treats AI as an <strong>active engineering system made up of context-aware agents, specialized skills, controlled permissions, live external integrations, and safety boundaries</strong>.</p><p>The goal is simple:</p><blockquote><em>Reduce the time spent manually writing infrastructure and operational code, while increasing the time engineers spend supervising architecture, security, and delivery outcomes.</em></blockquote><p>In this write-up, I’ll show how I built an agent-driven workflow that deploys infrastructure to Amazon Web Services using Terraform, with Anthropic Claude acting as the execution layer.</p><h3>Why Traditional DevOps Still Slows Engineers Down</h3><p>Even in mature DevOps environments, engineers repeatedly do the same things:</p><ul><li>Write infrastructure files manually</li><li>Run plans and verify outputs</li><li>Fix policy mistakes</li><li>Apply resources</li><li>Deploy artifacts</li><li>Troubleshoot permissions</li><li>Repeat across environments</li></ul><p>The real challenge is not lack of automation — it is that <strong>automation itself still requires heavy human construction every time</strong>.</p><p>What changes with Agentic DevOps is that we stop thinking only in terms of scripts and pipelines, and start thinking in terms of <strong>agents that understand intent and execute structured tasks safely</strong></p><h3>The Core Idea: Build the Environment Before You Ask AI to Work</h3><p>AI does not become useful simply because it exists inside your terminal.It becomes useful only when you give it the right project context, the right file structure, task-specific skills, safe permissions, live external data, clear execution boundaries. Without these, AI guesses but with them, AI becomes operational.</p><h3>Environment Setup: The Minimum Foundation</h3><p>Before building agents, the local environment must be prepared with the required tools and they include: Docker Desktop, Terraform, uvx, AWS CLI, Visual Studio Code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*t6foxwRfyduCyTupLXRihg.png" /><figcaption>Environment setup</figcaption></figure><p>If Terraform is already installed on Windows, upgrading through Chocolatey helps avoid compatibility issues:</p><pre>choco upgrade terraform-y</pre><p>You also need a GitHub account and an Anthropic account</p><h3>Setting Up Claude with the $5 Console Option</h3><p>For learning purposes, the lowest paid entry point is enough.</p><p>The setup flow:</p><ol><li>Search for Claude advanced setup in your browser</li><li>Select your operating system</li><li>Copy the install command into terminal</li><li>Open terminal inside VS Code, run claude</li></ol><p>Claude presents three onboarding options.</p><p>The second option — <strong>Anthropic Console Account</strong> — requires a $5 initial credit. That credit generates enough API tokens to run meaningful workloads for learning and experimentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*BrORKd78zRN0vOUNQEj8wA.png" /><figcaption>Claude successfully installed</figcaption></figure><p>Every successful task consumes tokens, so learning how to structure tasks efficiently matters.</p><h3>Starting with the Project…</h3><p>I forked this repository:</p><p>GitHub repository: <strong>pravinmishraaws/Ultimate-Agentic-DevOps-with-Claude-Code</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*IsSCI_OWnf1jrhVCkffosA.png" /><figcaption>The project repository</figcaption></figure><p>This project became the practical environment for testing how far agents can take over repetitive DevOps work.</p><h3>Section 1: The First Brain — <a href="http://claude.md/">CLAUDE.md</a></h3><p>The first thing Claude generates is project memory.</p><p>Inside terminal:</p><pre>/init</pre><p>This creates CLAUDE.md file. In this project, Claude analyzed the repository and correctly detected: static HTML/CSS portfolio site, no JavaScript framework, no build system, educational deployment workflow</p><p>The generated file in CLAUDE.md included: Project Overview, Deployment, Architecture</p><p><strong>But raw generation is never enough., it needs some</strong> <strong>refinement</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*U0D2OPT2KrT9OdaSiAuPqw.png" /><figcaption>The prompt: What is this project about?</figcaption></figure><p>Claude understood the base project but missed critical constraints. I improved it by adding:</p><ul><li>AWS deployment target using Amazon Web Services S3 + CloudFront</li><li>asset clarity (logo, profile images, thumbnails, hero image)</li><li>project conventions: no JavaScript, mobile-first CSS, images stored in /images</li></ul><p>Then I tested whether Claude truly understood the constraints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*qjxCn2resSKA9aH-NrXxBQ.png" /><figcaption>Testing if Claude now understands the project</figcaption></figure><p>I intentionally asked it to add a React component. The pushback confirmed that the context was now strong enough. That is the real goal: <em>not just giving AI context, but verifying that it respects it.</em></p><h3>SECTION 2: CLAUDE.md vs Skills- The Difference That Changes Everything</h3><h4>CLAUDE.md</h4><p>CLAUDE.md is a global project memory and is always loaded upon starting every session in Claude. It defines architecture, conventions, constraints and deployment rules</p><h4>Skills</h4><p>These are task-specific execution modules which are loaded only when triggered. Skills are written in a SKILL.md file (markdown style), and inside of this file, we have the Frontmatter and the Body.</p><p>Without skills, we just have another LLM giving general answers to prompts. More time would be consumed trying to solve a task. And since it’s our own project we are working on, we want a more custom-made approach to solving tasks.</p><blockquote><em>“CLAUDE.md tells the Agent WHO it is working with. Skills tell the agent WHAT to do right now.</em></blockquote><p>CLAUDE.md loads automatically, captures entire project context, and has one main file</p><p>Skills load on-demand, gives specific task instructions, and we can have many of it in one project</p><p>This separation is what turns general AI into specialized DevOps infrastructure.</p><h3>Building Specialized Skills</h3><p>Inside the .claude/skills/ folder, I created four core skills.</p><h4>1. /scaffold-terraform</h4><p><strong>Purpose:</strong> To generate full Terraform infrastructure for: S3 and CloudFront</p><p><strong>Allowed Tools:</strong> Read, Write, Bash, Glob, Grep</p><p><strong>Why Write Permission Matters</strong></p><p>Write permission is a right tool to give this skill because this skill creates: <a href="http://main.tf/">main.tf</a>, <a href="http://variables.tf/">variables.tf</a>, <a href="http://outputs.tf/">outputs.tf</a> and <a href="http://provider.tf/">provider.tf</a>.</p><h4>2. /tf-plan</h4><p><strong>Purpose:</strong> To run terraform plan and inspect risk before deployment.</p><p><strong>Allowed Tools</strong>: Bash, Read, Grep</p><p><strong>Why No Write Permission</strong></p><p>Write permissions aren’t given to this particular tool because planning should never edit or change infrastructure definitions. This skill only needs to read and analyze.</p><h4>3. /tf-apply</h4><p><strong>Purpose:</strong> To run: terraform apply in order to create or update infrastructure.</p><p><strong>Allowed Tools:</strong> Bash and Read</p><p><strong>Why No Write Permission</strong></p><p>At this point, files are already approved. Execution happens against approved definitions only.</p><h4>4. /deploy</h4><p><strong>Purpose:</strong> Deploy website contents to S3 and invalidate CloudFront cache.</p><p><strong>Allowed Tools:</strong> Bash and Read</p><p>The deployment skill reads Terraform outputs, extracts the bucket name and the distribution ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*0SzbZQJndjvG-RlivEYDIA.png" /><figcaption>File structure for skill creation</figcaption></figure><p>Then performs live deployment.</p><h3>Running the Full Pipeline</h3><p>In order to run the full pipeline, I made sure I have confirmed my AWS identity using aws sts get-caller-identity. I then initiated the Claude session by typingclaude on my terminal, then ran the commands. The full sequence is this:</p><h4>1. Scaffold infrastructure</h4><pre>/scaffold terraform &lt;your_aws_region&gt; &lt;project_name&gt;</pre><h4>2. Initialize Terraform</h4><pre>terraform init</pre><h4>3. Run plan</h4><pre>/tf-plan</pre><h4>4. Apply infrastructure</h4><pre>/tf-apply</pre><h4>5. Deploy website</h4><pre>/deploy</pre><p>The result of this :</p><ul><li>S3 bucket created</li><li>CloudFront distribution created</li><li>site synced live</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*YM2sM7W-hWKpJgUVhQayrg.png" /><figcaption>The website is live</figcaption></figure><h3>SECTION 3: Making It Better with Subagents</h3><p>A single AI agent becomes expensive and inefficient when used for every task. It won’t be as sharp and focused as it is expected to be unless we reduce its workloads in an efficient manner. The better pattern is specialization and the concept is Subagents.</p><p>Subagents are your specialist workers that come in with the right tools, do their job, and leave without caring about your other business. This means there is no context pollution.</p><p>For this project, you have to create a folder called agents inside of the .claude directory and add three markdown files.</p><p>Inside: .claude/agents/</p><p>I added:</p><ul><li>security-auditor.md: To preform an analysis and audit of my entire infrastructure, reporting to me about the vulnerabilities.</li><li>tf-writer.md: To write terraform infrastructure files.</li><li>cost-optimizer.md: To perform a look up on how much has been spent, and how to save reasonably.</li></ul><p>Each subagent had to match:</p><ul><li>filename</li><li>internal declared name</li></ul><h3>Multi-Agent Design: Right Model for the Right Task</h3><p>Each of these tasks could be performed by different AI models depending on what exactly the task does. If tasks require a review, you can go for the Sonnet AI model. If you want a quick scan and fast answers, the Haiku model is fine. For higher analysis of work, then Claude Opus is the right fit.</p><p>This matters because: <em>expensive reasoning should only be used where deep reasoning is necessary.</em></p><h3>SECTION 4: MCP Servers -Giving AI Agents Live Infrastructure Awareness</h3><p>One major limitation of AI in engineering is that even powerful models are still bounded by training data.</p><p>That means an agent may understand Terraform syntax, AWS architecture patterns, or common security practices — but it may still fail when asked about something that changed recently, something environment-specific, or something only visible inside your own account.</p><p>This is exactly where <strong>Model Context Protocol (MCP)</strong> becomes essential.</p><p>MCP stands for <strong>Model Context Protocol</strong>, an open standard introduced by Anthropic to allow AI agents connect directly to live systems through structured interfaces rather than relying only on pattern prediction.</p><p>What makes MCP important is that it changes how the agent gets information:</p><ul><li>without MCP, the model predicts based on prior training</li><li>with MCP, the model queries the source directly</li></ul><p>Instead of guessing bucket names, IAM relationships, provider arguments, or current resource definitions, the agent can retrieve live information from the actual source.</p><h3>How I Configured MCP in My Project</h3><p>To make this work inside my DevOps workflow, I configured two MCP servers for the project:</p><ul><li>Terraform MCP server</li><li>AWS MCP server</li></ul><p>These were the two live systems my agent needed most because the project involved provisioning infrastructure and deploying resources directly to AWS.</p><p><strong>There are two files that make MCP work:</strong></p><p>settings.local.json: This file is where local environment-specific settings live.</p><p>I used it to: enable MCP servers, define environmental variables, and keep sensitive credentials local</p><p>.mcp.json: This file defines which MCP servers the project uses. It tells the client — in this case Claude — how to start and communicate with each server.</p><h4>Credentials Belong in settings.local.json, Not .mcp.json</h4><p>This separation is critical for security</p><p>.mcp.json is structural configuration.That means it often lives with project files and may eventually be committed to version control.</p><p>If credentials are placed there and pushed accidentally to GitHub, the result could be immediate infrastructure exposure.</p><p>Sensitive values such as AWS access keys, tokens, private environment variables belong inside settings.local.json, which should remain excluded through .gitignore.</p><p>That way, project logic remains shareable and secrets remain local</p><p>This is one of the first real security disciplines Agentic DevOps forces engineers to learn.</p><h4>Using stdio and restricted MCP to this project</h4><p>The MCP connection itself used <strong>stdio</strong>. That means communication happens through:</p><ul><li>standard input</li><li>standard output</li></ul><p>The MCP server runs locally as a process, and Claude communicates with it directly through that channel. This matters because we now have a simple local communication meaning no hidden charges anywhere, fast execution since communication is internal and no unnecessary networking complexity</p><p>The second important decision was restricting MCP to project scope.</p><p>This ensures the agent only sees the working project directory — not the full machine. That improves security, focus, and context cleanliness</p><p>Without project scope, the agent could potentially scan unrelated directories and pollute context unnecessarily.</p><h4>Verifying MCP Connection</h4><p>After configuration, I verified prerequisites: Docker Desktop, Terraform, AWS CLI and uvx</p><p>Then inside Claude Code I ran /mcp</p><p>This confirmed both servers were connected successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*6RuYlInBgKmxvWI0_iLXdw.png" /><figcaption>MCP servers connected successfully</figcaption></figure><p>That moment matters because until /mcp shows active connections, the agent is still operating without live external awareness.</p><h3>MCP now works, but what’s next: Audit → Fix → Verify</h3><p>Once MCP was working, I tested it on a real Terraform issue using the full MCP loop (audit, fix and verify). I started a session with Claude, and the conversation began this way:</p><h4>Step 1: Audit</h4><p>I started with:</p><pre>Audit my Terraform files for security issues</pre><p>The goal was to let the agent inspect the infrastructure rather than manually reading every resource block.</p><h4>Step 2: Pick a Real Finding</h4><p>One issue identified was: missing S3 server-side encryption. That is a real production concern because unencrypted storage introduces unnecessary exposure.</p><h4>Step 3: Fix Through the Agent</h4><p>I then instructed the agent: <em>Add S3 server-side encryption using AES256</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*ZYPWeEvOTUASlDi6bjE2ow.png" /><figcaption>Agent ficing the s3 encryption at rest</figcaption></figure><p>The agent updated the Terraform definition accordingly. This meant I was no longer manually writing the encryption block — the agent performed the modification inside project rules.</p><h4>Step 4: Verify Again</h4><p>I reran:</p><pre>Audit my Terraform files for security issues</pre><p>The finding was improved.</p><h3>SECTION 5: Hooks- The Safety Layer That Makes Agentic DevOps Trustworthy</h3><p>Once agents can generate infrastructure, query live systems through MCP, and execute tasks through tools, a new problem immediately appears: <em>How do you stop an intelligent agent from doing something destructive?</em></p><p>Because at that point, the risk is no longer theoretical. An agent connected to your infrastructure can:</p><ul><li>run shell commands</li><li>modify Terraform files</li><li>trigger deployments</li><li>interact with cloud resources</li></ul><p>Without safety controls, one poorly interpreted instruction can become expensive — or irreversible. That is why hooks are essential. Hooks are small scripts that execute at specific moments during the agent lifecycle.</p><p>You can think of them as <strong>security guards positioned at every critical checkpoint of execution</strong></p><p>Instead of trusting the agent blindly, hooks let you:</p><ul><li>allow actions</li><li>block dangerous operations</li><li>record what happened</li></ul><h3>Setting Up the Hook Framework</h3><p>To introduce safety into the workflow, I created a dedicated hook directory inside the project:</p><pre>.claude/hooks/</pre><p>Inside that folder, I added three scripts:</p><ul><li>user-prompt-guard.sh</li><li>pre-tool-guard.sh</li><li>post-tool-logger.sh</li></ul><p>Each script represents a different safety checkpoint.</p><p>After placing them correctly, I made the scripts executable and wired them into:</p><pre>.claude/settings.json</pre><p>Inside settings, I added a hooks block for:</p><ul><li>UserPromptSubmit</li><li>PreToolUse (with Bash matcher)</li><li>PostToolUse (with Bash matcher)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*lU6d-clwOJkSWFFQE35dvg.png" /><figcaption>Hook Blocks</figcaption></figure><p>After restarting Claude, the environment loaded cleanly without JSON or configuration errors. That validation matters because hook failures can silently disable your protection layer.</p><h3>The Hook Lifecycle</h3><p>Hooks operate across the full execution lifecycle. There are three primary stages, often easiest remembered as:</p><h4>SAY → DO → LOG</h4><p><strong>SAY — UserPromptSubmit</strong></p><p>This is the first line of defense. Before the agent even begins reasoning, the prompt itself can be inspected.</p><p>If a prompt is destructive, unsafe, or ambiguous, it can be blocked before the model interprets it. This matters because sometimes the danger is already present in user intent. It could be simple sentences like: delete all infrastructure, wipe everything, destroy bucket contents</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*5JXNsPetixgJk9XVl6g4Eg.png" /><figcaption>SAY hooks catching dangerous prompts</figcaption></figure><p>A prompt-level guard prevents these instructions from even becoming reasoning candidates. That means safety starts before the model thinks.</p><p><strong>DO — PreToolUse</strong></p><p>This is the execution guard. At this stage, the agent has already reasoned and selected a tool. Now the system checks if this command should actually run? This is where dangerous shell operations are intercepted directly.</p><p>Even if a destructive prompt somehow bypasses the first guard, PreToolUse still blocks dangerous execution. That creates a second defensive wall. This dual protection matters because:</p><ul><li>one layer protects intent</li><li>one layer protects execution</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*LjrRZp5mxITwZuexefsglQ.png" /><figcaption>PreTool Hook catching the dangerous commands.</figcaption></figure><p>Even if intent slips through, execution still remains governed.</p><p><strong>LOG — PostToolUse</strong></p><p>Once a tool completes, something equally important happens in that the event is recorded.</p><p>PostToolUse exists to answer “What exactly happened after execution”?</p><p>This creates an audit trail.For every successful or failed action, you can capture the command executed and timestamp</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*7p7_Ot1AL3reYKfDm6yTCQ.png" /><figcaption>Post tool hook showing time stamp on a /tf-plan command</figcaption></figure><p>This matters because in production systems, traceability is as important as prevention. Without logs, you cannot explain how infrastructure changed.</p><h3>We must use both Prompt-Level Guard and Tool-Level Guard.</h3><p>Using only one guard is insufficient. If you protect prompts but not commands, then, unsafe execution can still happen after imperfect reasoning.</p><p>If you protect commands but not prompts, then, the agent wastes cycles reasoning through dangerous intent.</p><h3>Real Deployment Outcome</h3><p>The final test was a real deployment.</p><p>Workflow:</p><ol><li>TF Writer generated infrastructure</li><li>Security Auditor flagged an open bucket policy</li><li>Agent corrected the policy</li><li>Deploy skill published the site</li></ol><p>The cost optimizer also identified savings: <em>approximately $85/year by changing CloudFront price class</em></p><h3>What This Means for DevOps Engineers</h3><p>The role is shifting. We are no longer just people who write commands.</p><p>We are becoming:</p><ul><li>system designers</li><li>AI workflow architects</li><li>policy builders</li><li>safety engineers</li></ul><p>Agentic DevOps does not replace engineering. It amplifies it. The engineer still owns judgment. The agents own repetition. And that is where the future gets interesting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d3feeec8a17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Secure Three-Tier Application Architecture on Azure (Step-by-Step)]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/building-a-secure-three-tier-application-architecture-on-azure-step-by-step-9edfe7b7cb71?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9edfe7b7cb71</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[three-tier-architecture]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Fri, 06 Mar 2026 16:00:11 GMT</pubDate>
            <atom:updated>2026-03-06T16:00:11.671Z</atom:updated>
            <content:encoded><![CDATA[<p>When building modern cloud applications, one principle shows up everywhere: <strong>separation of concerns</strong>.</p><p>Instead of putting everything on one server, production systems are usually split into <strong>three tiers</strong>:</p><ul><li><strong>Web Tier</strong> — handles user requests</li><li><strong>Application Tier</strong> — processes logic</li><li><strong>Database Tier</strong> — stores data</li></ul><p>This architecture improves <strong>security, scalability, and reliability</strong>.</p><p>Recently, I deployed a <strong>three-tier Book Review application on Microsoft Azure</strong>, and in this blog post, I’ll walk you through the entire journey from networking to load balancing to deploying the application.</p><p>If you’re learning <strong>cloud architecture, DevOps, or Azure networking</strong>, this guide should help you understand how the pieces fit together.</p><h3>Architecture Overview</h3><p>At a high level, the architecture looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*scbyQqVfXh2etJCuHx7Yew.png" /><figcaption>Three tier architecture at a high-level view</figcaption></figure><p>Key goals of the architecture:</p><ul><li>No VMs have <strong>public IP addresses</strong></li><li>All administration is done through <strong>Azure Bastion</strong></li><li>Internal services communicate through <strong>private networking</strong></li><li>Only the <strong>load balancer is exposed to the internet</strong></li></ul><p>This design drastically reduces the attack surface of the infrastructure.</p><h3>Step 1 — Creating the Foundation: Resource Group</h3><p>Everything in Azure starts with a <strong>Resource Group</strong>, which acts as a logical container for all the resources.</p><p>I created:</p><pre>book-review-rg</pre><p>This resource group holds everything for the project:</p><ul><li>Virtual network</li><li>Virtual machines</li><li>Load balancers</li><li>Database</li><li>Networking resources</li></ul><h3>Step 2 — Designing the Virtual Network</h3><p>The <strong>Virtual Network (VNet)</strong> acts like the <strong>private data center network</strong> for the application.</p><pre>book-review-vnet</pre><p>While creating the VNet, I also enabled <strong>Azure Bastion</strong>, which allows secure SSH access to VMs <strong>without exposing them to the internet</strong>.</p><p>The Bastion subnet was created automatically with a CIDR range 0f 10.0.1.0/26, that is, it has a CIDR range of:</p><pre>10.0.1.0 – 10.0.1.63</pre><h3>Step 3 — Subnet Architecture</h3><p>To implement the three-tier design properly, I divided the VNet into <strong>six subnets</strong>.</p><h3>Public (Web Tier)</h3><pre>book-review-public-subnet-1   10.0.0.0/24<br>book-review-public-subnet-2   10.0.2.0/24</pre><h3>Application Tier</h3><pre>book-review-private-subnet-1  10.0.3.0/24<br>book-review-private-subnet-2  10.0.4.0/24</pre><h3>Database Tier</h3><pre>book-review-db-subnet-1       10.0.5.0/24<br>book-review-db-subnet-2       10.0.6.0/24</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FODYMiXVgahMHmLi4WJ4jA.png" /><figcaption>The subnet creation process</figcaption></figure><h3>Step 4 — Locking Down the Network with Security Groups</h3><p>Once the network was ready, I created <strong>Network Security Groups (NSGs)</strong> to control traffic between the tiers.</p><p>Think of NSGs as <strong>firewalls for Azure subnets</strong>.</p><h3>Web Tier NSG</h3><pre>book-review-web-nsg</pre><p>Rules:</p><ul><li>Allow SSH from Bastion subnet</li><li>Allow HTTP from Azure Load Balancer</li></ul><h3>Application Tier NSG</h3><pre>book-review-app-nsg</pre><p>Rules:</p><ul><li>Allow SSH from Bastion</li><li>Allow traffic from Web Tier on port <strong>3001</strong></li></ul><h3>Database Tier NSG</h3><pre>book-review-db-nsg</pre><p>Rules:</p><ul><li>Allow MySQL traffic (3306) <strong>only from the App tier</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJp8wf-bc9Rm9Q2kihwByQ.png" /><figcaption>VNets with Network Security Group Attached</figcaption></figure><p>After creating the NSGs, I associated them with the corresponding subnets.</p><h3>Step 5 — Creating the Public Load Balancer (Web Entry Point)</h3><p>Since none of the VMs have public IPs, the application needs an <strong>entry point</strong>.</p><p>That entry point is a <strong>Public Azure Load Balancer</strong>:</p><pre>book-review-public-alb</pre><p>Key configuration:</p><ul><li><strong>Static Public IP</strong></li><li><strong>Standard SKU</strong></li><li><strong>Zone redundant</strong></li></ul><p>The load balancer forwards traffic from:</p><pre>Internet → Web VMs</pre><p>I also created:</p><ul><li><strong>Backend Pool:</strong> web-backend-pool</li><li><strong>Health Probe:</strong> checks port 80</li><li><strong>Load balancing rule:</strong> HTTP traffic on port 80</li></ul><h3>Step 6 — Creating the Private Load Balancer</h3><p>The next step was creating an <strong>internal load balancer</strong> for the application tier.</p><pre>book-review-private-alb</pre><p>Instead of a public IP, this load balancer uses a <strong>private IP inside the VNet</strong>:</p><pre>10.0.3.50</pre><p>Traffic flow now becomes:</p><pre>Web VM → Private Load Balancer → App VM</pre><p>This ensures the application tier is <strong>completely invisible from the internet</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lo7ySwkCpRydz4lnNojIgg.png" /><figcaption>Load Balancers created</figcaption></figure><h3>Step 7 — Deploying the Virtual Machines</h3><p>With networking ready, it was time to deploy the servers.</p><h3>Web VM</h3><pre>book-review-web-vm1</pre><p>Configuration:</p><ul><li>Ubuntu 22.04</li><li>Standard_B1s</li><li>No public IP</li><li>Connected to the Public Load Balancer</li><li>Located in the Web subnet</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1w8xs9Xl01RmhlPMS4ISdg.png" /><figcaption>Web Virtual Machine with appropriate attached security group</figcaption></figure><p>All SSH access is done through Azure Bastion.</p><h3>App VM</h3><pre>book-review-app-vm1</pre><p>Configuration:</p><ul><li>Ubuntu 22.04</li><li>Private subnet</li><li>Behind the <strong>Private Load Balancer</strong></li><li>Runs the Node.js backend</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XP28i8QaTwFmL1gnWxZOQg.png" /><figcaption>App Virtual Machine with appropriate attached security group</figcaption></figure><h3>Step 8 — Creating the Database</h3><p>The application uses <strong>Azure Database for MySQL Flexible Server</strong>.</p><p>Important configurations to take Note of:</p><ul><li><strong>Private access (VNet integration)</strong></li><li>Dedicated database subnet</li><li>No public connectivity</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ApxZWxhAe7I1peQeGS3P1w.png" /><figcaption>Database created and placed in the right subnet</figcaption></figure><p>During deployment, Azure requires a delegated subnet. I also integrated it with a Private DNS Zone (privatelink.mysql.database.azure.com). This ensures the App Tier can connect using a clean FQDN rather than a brittle IP address.</p><h3>Step 9 — Deploying the Backend Application</h3><p>I SSH’ed into the app VM and once I was inside, I ran:</p><pre>sudo apt update<br>sudo apt install nodejs npm mysql-client-y<br>sudonpm install-g pm2</pre><p>Then I cloned the backend repository:</p><pre>git clone &lt;Repo_URL&gt;<br>cd book-review-app/backend<br>npm install</pre><p>The database connection is handled through environment variables where we create a .env file and fill in the appropriate database credentials:</p><pre>DB_HOST=book-review-db-server.mysql.database.azure.com<br>DB_USER=bookreview<br>DB_PASS=********<br>PORT=3001</pre><p>Also, in the .env file, set ALLOWED_ORIGINS to the Public Load Balancer IP to prevent CORS issues</p><pre>pm2 start src/server.js --name &quot;bookreview&quot;<br>pm2 startup # Run the sudo command it outputs!<br>pm2 save</pre><p>The backend service was started and kept so using <strong>PM2</strong> for process management.</p><h3>Step 10 — Deploying the Frontend</h3><p>On the Web VM:</p><pre>sudo apt update<br>sudo apt install nodejs npm nginx-y<br>sudonpm install-g pm2</pre><p>The frontend was deployed and built using:</p><pre>git clone &lt;Repo_URL&gt;<br>cd book-review-app/backend<br>npm install<br>npm run build<br>pm2 start npm --name &quot;frontend&quot; -- run start<br>pm2 startup # Run the sudo command it outputs!<br>pm2 save</pre><h3>Step 11 — Configuring Nginx as a Reverse Proxy on the Frontend</h3><p>Nginx routes traffic like this:</p><pre>/          → frontend (port 3000)<br>/api       → backend (private load balancer)</pre><p>Example of the configuration for /api:</p><pre>location /api/ {<br>    rewrite ^/api/(.*) /$1 break;<br>    proxy_pass &lt;http://10.0.3.50:3001&gt;;<br>}</pre><p>This allows the browser to interact with the backend <strong>without exposing the App VM directly</strong>.</p><h3>Troubleshooting: Handling Outbound Internet Access</h3><p>A tricky issue appeared during setup where my VMs couldn’t run:</p><pre>sudo apt update</pre><p>The reason?</p><p><strong>Azure Standard Load Balancers do not allow outbound internet traffic unless you configure outbound rules.</strong></p><p>I solved it by using a <strong>NAT Gateway</strong> attached to the private subnet and this provides a lot of benefits including the fact that:</p><ul><li>There is a secure outbound internet</li><li>No public exposure</li><li>It scales automatically</li></ul><p><strong>Another </strong>way to fix it if you dont want to make use of the NAT Gateway probably because of cost is to create an Outbound rule for the Load Balancer.</p><ol><li>Go to your Public Load Balancer (book-review-public-alb).</li><li>On the left menu, click <strong>Outbound rules</strong>.</li><li>Click <strong>+ Add</strong> and use these settings:</li></ol><ul><li><strong>Name:</strong> web-outbound-rule</li><li><strong>Frontend IP address:</strong> Select your public-lb-ip.</li><li><strong>Protocol:</strong> All.</li><li><strong>Idle timeout:</strong> 4 minutes.</li><li><strong>Backend pool:</strong> web-backend-pool.</li><li><strong>Port allocation:</strong> Keep it on “Manually choose number of selected ports” or “Use default” — either is fine for a single VM.</li></ul><h3>Final Architecture</h3><p>The completed architecture looked like this:</p><pre>Users<br>  │<br>Public Load Balancer<br>  │<br>Web VM (Nginx + Frontend)<br>  │<br>Private Load Balancer<br>  │<br>App VM (Node.js Backend)<br>  │<br>Azure MySQL Database</pre><p>Everything except the <strong>load balancer entry point</strong> lives inside the <strong>private network.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KDkTJlQDHX_l0hrblo5Zyg.png" /><figcaption>Successful registration showing frontend can communicate with the backend</figcaption></figure><p>A user hits the Public IP → Traffic enters the Public LB → Nginx on a Web VM serves the UI → Nginx proxies API calls to the Private LB → The Node.js App processes logic and queries the Private MySQL Server.</p><p><strong>The 3-tier dream is alive!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDSSMG4E8O-xs86eBjiWug.png" /><figcaption>A successful write to the database is also successful</figcaption></figure><h3>Key Lessons from This Deployment I find useful:</h3><h4>1. Always build networking first</h4><p>Getting subnets, NSGs, and routing right makes the rest of the deployment easier.</p><h4>2. Bastion is incredibly useful</h4><p>It eliminates the need for public SSH access.</p><h4>3. Azure Standard Load Balancers require explicit outbound configuration</h4><p>Without outbound rules or NAT gateways, your VMs cannot reach the internet.</p><h4>4. Service Tags improve security</h4><p>They prevent users from bypassing your load balancer.</p><h4>5. Quota Management is important</h4><p>Public IPs are a finite resource. If your deployment fails, check for “orphaned” IPs.</p><h3>Final Thoughts</h3><p>Deploying a three-tier architecture manually is one of the <strong>best ways to truly understand cloud networking</strong>.</p><p>It forces you to think about:</p><ul><li>network isolation</li><li>security boundaries</li><li>traffic flow</li><li>service dependencies</li></ul><p>If you enjoyed this walkthrough, I’d love to hear how you would improve the architecture especially around <strong>scaling, monitoring, or automation</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9edfe7b7cb71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Architecting for Scalability: A Hands-on Guide to Deploying a Three-Tier Web App on AWS]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/architecting-for-scalability-a-hands-on-guide-to-deploying-a-three-tier-web-app-on-aws-f5f317506caf?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5f317506caf</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[three-tier-architecture]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Tue, 24 Feb 2026 14:36:50 GMT</pubDate>
            <atom:updated>2026-02-24T14:36:50.024Z</atom:updated>
            <content:encoded><![CDATA[<p>In cloud computing, “Three-Tier” isn’t just a buzzword; it’s the blueprint for professional, secure, and scalable applications. By separating the <strong>Presentation</strong>, <strong>Business Logic</strong>, and <strong>Data</strong> layers, we ensure that a failure or a security breach in one doesn’t immediately compromise the others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*YHOIKxxcnvmcZ2olScQz9g.png" /></figure><p>In this guide, I’ll walk you through how I deployed <strong>Book-Review</strong>—a Next.js and Node.js application—using a robust AWS infrastructure.</p><h3>The Architecture Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WK2AiTejzRDgN5IjfWgMWA.png" /><figcaption>The architecture showing how traffic flows within the different layers</figcaption></figure><p>For this project, I broke the application down into three distinct tiers:</p><ol><li><strong>Presentation Tier (Frontend):</strong> Built with <strong>Next.js</strong> for server-side rendering.</li><li><strong>Business Tier (Backend):</strong> A <strong>Node.js/Express</strong> API handling authentication and book metadata.</li><li><strong>Data Tier (Database):</strong> A managed <strong>MySQL</strong> instance (Amazon RDS) for persistent storage.</li></ol><p>Lets go ahead and build…</p><h3>Phase 1: Building the Network Foundation (VPC)</h3><p>You cannot build a house without a solid foundation. In AWS, that foundation is the <strong>Virtual Private Cloud (VPC)</strong>.</p><ol><li><strong>CIDR Block:</strong> 10.0.0.0/20 in the eu-north-1 region.</li><li><strong>Subnet Strategy:</strong> I created <strong>6 subnets</strong> across two Availability Zones (AZs) for High Availability:</li></ol><ul><li><strong>2 Public Subnets:</strong> For the Internet-Facing Load Balancer and NAT Gateway.</li><li><strong>2 Private Subnets (App):</strong> For the Backend EC2 instances.</li><li><strong>2 Private Subnets (DB):</strong> For the RDS MySQL instances.</li></ul><blockquote><strong><em>Tip:</em></strong><em> Use </em><strong><em>Subnet Associations</em></strong><em> to route public traffic through an Internet Gateway (IGW) while keeping the application and database tiers isolated, and use a NAT Gateway only when the private instances need to download updates.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kIqZBSoNAGiXuRxytyeI3g.png" /><figcaption>Resource Map showing the routing of each resource</figcaption></figure><h3>Phase 2: Security Group Chaining (The &quot;Firewall&quot; Logic)</h3><p>Security is about layers. Instead of opening ports to the whole world, I implemented <strong>Security Group Chaining</strong>. This means each layer only accepts traffic from the layer immediately above it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*aDiTKpp0sd2SmWKSsf7A1A.png" /><figcaption>Image showing security group chaining of each resource</figcaption></figure><p>What I have just shown in tables can also be interpreted in words for clearer understanding and to create the security groups more effectively:</p><ul><li><strong>PUBLIC ALB SG</strong>—The Internet-facing Load balancer security group whose inbound rules allow HTTP 80 from 0.0.0.0/0.</li><li><strong>WEB SG</strong>—The public EC2 Instance security group whose inbound rules allow HTTP 80 from ALB SG and SSH 22 from your IP only.</li><li><strong>PRIVATE ALB SG</strong>—The load internal-facing load balancer security group whose inbound rules allow HTTP from the WEB SG.</li><li><strong>APP SG</strong>—The private EC2 Instance Security group whose inbound rules allow Custom TCP from the PRIVATE ALB SG on port 3001.</li><li><strong>RDS SG</strong>—The Database security group whose inbound rules allow MySQL 3306 from APP SG and have no outbound rules.</li></ul><h3>Phase 3: The Data Tier (RDS MySQL)</h3><p>For the database, I chose <strong>Amazon RDS</strong> for its managed capabilities.</p><ul><li><strong>Multi-AZ Deployment:</strong> This ensures that if one data center goes down, a standby database in another zone takes over automatically.</li><li><strong>No Public Access:</strong> The database lives in a completely isolated subnet with no route to the internet. It only talks to our App Tier.</li></ul><h3>Phase 4: Compute &amp; Configuration</h3><p>I launched two EC2 instances. The public instance acts as a <strong>Bastion Host (Jump Box)</strong>, allowing me to securely SSH into the private App instance.</p><h3>Backend Setup:</h3><ol><li>SSH into the Private Instance via the Jump Box (That is, to SSH from the web instance first, then SSH into the App Instance). This can be done with the following steps:</li></ol><pre>## Step 1: Copy the key from your local machine to your ubuntu public EC2 instance<br>scp -i /path/to/keypair keypair.pem ec2_instance@Public_IP:/home/ubuntu<br><br>## Step 2: SSH into your private App EC2 instance from your public Web EC2 instance<br>chmod 400 keypair.pem<br>ssh -i keypair.pem ec2_instance@Public_IP<br>ssh -i keypair.pem ec2_instance@Private_IP</pre><p>2. Once you’re logged in, install Node.js and MySQL-Client.</p><p><strong>3. </strong>Environment Variables<strong>:</strong> Configure the .env file with DB_HOST, DB_USER, and DB_PASSWORD.</p><p>4. Executed node src/server.js to start the engine.</p><p>5. Used <strong>PM2</strong> to run the backend permanently on port 3001.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZs-HKr_dHI8_m0bNBytYw.png" /><figcaption>Ensuring pm2 runs permanently on the backend (daemonization)</figcaption></figure><h3>Frontend Setup:</h3><ol><li>Install <strong>Nginx</strong> to act as a reverse proxy.</li><li>Configure Nginx to forward requests to our Load Balancers.</li><li>Set NEXT_PUBLIC_API_URL to point to the internal load balancer.</li></ol><h3>Phase 5: Load Balancing &amp; Traffic Routing</h3><p>We used two <strong>Application Load Balancers (ALB)</strong>:</p><ul><li><strong>External ALB:</strong> Receives user traffic and sends it to the Nginx frontend.</li><li><strong>Internal ALB:</strong> Receives API calls from the frontend and sends them to the Node.js backend on port 3001.</li></ul><blockquote><strong><em>Tip:</em></strong><em> Remember that a load balancer cannot function alone without a target group. Create a target group for both the internal and external ALB. Both Target groups would have listeners on HTTP Protocol but the ports would be different. Port 80 for External ALB and Port 3001 for Internal ALB.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*18XAICutHhYhP-NNaMGGMg.png" /><figcaption>Target group with the required port and protocols</figcaption></figure><h3>Troubleshooting and Debugging</h3><p>Here’s where the real work is. When everything looks good on paper, but in practice, we hit a few snags, and we resolved them as well.</p><h3>1. The CORS Hurdle</h3><p>Even with perfect architecture, things can actually break. After deployment, I couldn’t log in. The error? <strong>CORS (Cross-Origin Resource Sharing).</strong></p><p><strong>The Issue:</strong> The Node.js backend didn’t recognize the DNS of the new Public Load Balancer.</p><p><strong>The Fix:</strong> I jumped back into the private instance, updated the ALLOWED_ORIGINS in the .env file to include the Load Balancer’s DNS name, and restarted the service. Suddenly, the traffic flowed perfectly.</p><h3>The result</h3><p>A public Load Balancer successfully serving the frontend, securely querying the private backend via the Internal ALB, and fetching the book data directly from the Multi-AZ RDS database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEG7R_mEduWfQ40mPc6ybw.png" /><figcaption>Successful registration showing that the backend works perfectly</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhgF7QnSq365T4D3up0sBA.png" /><figcaption>Successfully writing to the database (dropping a book review)</figcaption></figure><h3>Conclusion</h3><p>Upon building this 3-tier architecture, we have successfully demystified cloud networking by a large extent. VPCs and reverse proxies are no longer just concepts—they are tools used to build a secure, production-grade environment.</p><p><strong>⚠️ A Final Note on Cost:</strong> High availability (NAT Gateways, Multi-AZ RDS) is not free. Once the project was validated, I performed a full teardown of all resources to avoid an unexpected AWS bill. <strong>Always clean up your lab!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5f317506caf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The “Master” vs. “Main” Mismatch: A Guide to Fixing Branch Name Mismatches in GitHub”]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/the-master-vs-main-mismatch-a-guide-to-fixing-branch-name-mismatches-in-github-4e88ad048d41?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e88ad048d41</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 15:17:30 GMT</pubDate>
            <atom:updated>2026-01-29T15:17:30.133Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qJsGwdrkwabh8SHl_6Xigg.png" /></figure><p>I was working on a collaborative project on GitHub and everything felt smooth, until it didn’t.</p><p>You know that nagging feeling when you’re coding and you just <em>know</em> something has gone sideways, even if there isn’t an error message yet? That’s exactly where I found myself.</p><p>The problem that happened to me was a tale of two names:</p><p>On GitHub, the default branch was named main. However, on my local machine, I was still working on a branch named master. When the time came to push my changes, I expected them to “slide right in.” Instead, GitHub greeted me with a curious message: <strong>“master had recent pushes 2 seconds ago.”</strong></p><p>Technically, nothing was “broken,” but I had accidentally created a <strong>split-branch situation</strong>. Because my local branch name didn’t match the remote default, Git did exactly what it’s programmed to do: it created a brand-new branch on GitHub called master instead of updating main.</p><h3><strong>Why You Shouldn’t Just Leave It</strong></h3><p>It’s tempting to just keep working on master, but that leads to three major headaches:</p><ol><li><strong>Confusion:</strong> Your latest code is on master, while the main branch (the one everyone sees first) sits empty or outdated.</li><li><strong>Friction:</strong> Every time you push or pull, you have to remember to specify the “non-standard” branch name. You know who we’re talking about.</li><li><strong>Collaboration Chaos:</strong> If someone else clones your repo, they’ll land on an empty main branch and think the project is a ghost town.</li></ol><h3><strong>The Fix: Aligning Everything to main</strong></h3><p>Since main is the modern industry standard, the cleanest solution was to rename my local branch and sync it properly. Here is the three-step fix I used in my terminal:</p><p><strong>1. Rename the local branch to match the remote</strong></p><pre>git branch -m master main</pre><p><strong>2. Delete the accidental “master” branch from GitHub</strong></p><pre>git push origin — delete master</pre><p><strong>3. Push the newly renamed “main” branch up to GitHub</strong></p><pre>git push -u origin main</pre><h3><strong>Troubleshooting: The “Fetch First” Error</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Zq63yD6uUv6--OTvldtwQ.png" /><figcaption>Common Error Messages you can get</figcaption></figure><p>Sometimes, Git just decides to throw a curveball. You might see an error like this: ! [rejected]msin -&gt; main (fetch first)</p><p>This happens because GitHub has a history of files (like a README or a license) that your local computer doesn’t have yet. Git is essentially saying, <em>“Wait! If I let you push, I’ll lose the files already on the server!”</em></p><h4><strong>The Solution: The Rebase</strong></h4><p>To fix this, you need to grab the remote changes and tuck your local work neatly on top of them. Run:</p><pre>git pull origin main - rebase</pre><h4><strong>What this does</strong></h4><p>It fetches the files from GitHub, places them at the beginning of your commit history, and then “replays” your work on top of them. Once that’s done, you can push freely:</p><pre>git push -u origin main</pre><p>By running those few commands, I aligned my local environment with the remote standard. No more “recent push” warnings, no more split history — just a clean, professional repository.</p><p>I hope you find this useful!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e88ad048d41" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deployment is Day 1. Keeping it alive is the real job]]></title>
            <link>https://medium.com/@ashayeadetomiwa77/deployment-is-day-1-keeping-it-alive-is-the-real-job-ee5d7c15c84c?source=rss-54ac092415f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee5d7c15c84c</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Ashaye Adetomiwa]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 10:05:26 GMT</pubDate>
            <atom:updated>2026-01-21T10:05:26.334Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F5K1Zr3iCFCWwafOdX107Q.png" /></figure><p>I believe that in application deployment, the work doesn’t end once the application is live. A production environment isn’t a “set it and forget it” machine. It’s more like a car such that without routine maintenance, health checks, and a good eye on resources, it will eventually stop working. To ensure high availability and fault tolerance, you have to make these routine checks.</p><p>There are dozens of checks one could perform when it comes to application maintenance and they fall under several categories like Networking &amp; Access Checks, Process Validation, Logs Tracing, System Resource Health, Content Integrity, and many others.</p><p>A category that I would dwell upon this time is what I have termed “Service health”, and I would share 3 commands I find particularly useful:</p><p>- <strong>systemctl status nginx — no-pager</strong>: This command tells you if the Nginx service is active and provides a snapshot of the most recent logs. If something is failing somewhere, the “why” is usually hidden in this output and you can get to the root of the matter.</p><p>- <strong>systemctl is-enabled nginx</strong>: This command verifies if Nginx is set to start automatically after a server reboot. if you decide to perform an emergency reboot at work, you should know if your application would come back online immediately and automatically. If after running this command, it says “disabled,” you’re one reboot away from an outage. To ensure Nginx starts automatically on every boot, run: sudo systemctl enable nginx.</p><p>- <strong>sudo nginx -t</strong>: I find this command particularly useful because it reiterates the point to ‘never restart a service blindly.’ This command validates your configuration syntax before you apply changes (much similar to running “terraform validate,” if you know what I mean :)). But yes, it allows you to catch a missing semicolon or a typo before it crashes your production site.</p><p>The takeaway once again is this: Getting an app live is the easy part. There would be incidents at the workplace, and recovery steps have to be taken<strong><em>. </em></strong>Building the muscle memory to monitor, validate, and recover is what defines a reliable engineer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee5d7c15c84c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>