<?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 Toba Oyetola on Medium]]></title>
        <description><![CDATA[Stories by Toba Oyetola on Medium]]></description>
        <link>https://medium.com/@tobaoyetola?source=rss-7baf6cbfa021------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vHRPdJl95CAqdBiRBMaLcw.png</url>
            <title>Stories by Toba Oyetola on Medium</title>
            <link>https://medium.com/@tobaoyetola?source=rss-7baf6cbfa021------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 04:26:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tobaoyetola/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[Scaling QA Automation: Every Pull Request Gets Its Own Environment, Then Cleans Up After Itself]]></title>
            <link>https://tobaoyetola.medium.com/scaling-qa-automation-every-pull-request-gets-its-own-environment-then-cleans-up-after-itself-aa628b4fdf4a?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa628b4fdf4a</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[container-orchestration]]></category>
            <category><![CDATA[qa-testing]]></category>
            <category><![CDATA[ecs-fargate]]></category>
            <category><![CDATA[cicd-pipeline]]></category>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Sun, 22 Nov 2026 00:43:53 GMT</pubDate>
            <atom:updated>2026-11-22T01:03:54.925Z</atom:updated>
            <content:encoded><![CDATA[<h3>How we extended our QA automation pipeline so every PR tests against its own isolated environment instead of a shared staging one that was quietly undermining the results</h3><p>For a long time, our pull-request pipeline worked the way most teams’ do: open a PR, a CI job runs the test suite against one shared staging environment, a green check appears, you merge. It’s a well-understood pattern, and it mostly works, right up until it doesn’t.</p><p>Shared staging has one structural problem: it’s shared. Two PRs in flight at once means two sets of tests touching the same database, the same feature flags, the same rate limits, the same “temporarily locked” state from whatever the last PR’s tests left behind. The failures that come out of that are real, but they’re rarely about the code in the PR. They’re about contention. And contention failures are expensive in a specific way: they don’t just waste the one CI run, they cost someone’s afternoon figuring out whether the red check means anything.</p><p>So we rebuilt it. Every pull request now gets its own isolated environment: its own running service, its own URL, built from its own exact commit, torn down automatically the moment the PR closes. The test suite runs against that environment, not shared staging. Two PRs in flight don’t know the other exists.</p><h3>The shape of it</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VmGw2PyVbVZrRknJ3HriYQ.png" /><figcaption>Eight moving pieces, two of which are the same two pieces the team already had running a more conventional PR-gate pipeline:</figcaption></figure><p><strong>Dispatche</strong>r: a small webhook handler. It’s the one component that was already there; we extended it rather than replacing it. It reads two kinds of event: PR opened/updated starts a preview build, PR merged/declined starts a teardown build.</p><p><strong>Preview Build: </strong>The new piece. Per commit, it builds the image, runs the real unit test suite <em>inside</em> that image, runs a security scan, and only then pushes and deploys. A failing test never gets as far as a deploy.</p><p><strong>Preview Servic</strong>e: a fresh, ephemeral compute task per PR, running that exact commit. Nothing is reused between PRs except the underlying compute platform.</p><p><strong>Shared Edge: </strong>The load balancer and DNS layer are shared across every PR (you don’t want a new load balancer per PR), but each PR gets its own routing rule and its own hostname, created on the first commit and reused across every subsequent commit on that PR.</p><p><strong>QA Runner: </strong>The existing test-suite runner, now also invoked in a second mode: point it at this PR’s live preview URL instead of shared staging, and run the same suite.</p><p><strong>Run Store: </strong>Every run writes its result here, keyed by PR and commit: preview-PR runs, scheduled suite runs, and individual user-journey and contract-test runs alike. Nothing is only ever visible in a CI log that scrolls away the moment the next build starts.</p><p><strong>QA Dashboard: </strong>a web UI the team already had for browsing scheduled runs and replaying individual test suites by hand. It didn’t need a rebuild, just more rows in the same store: preview-PR runs now show up in the same history, next to everything else, filterable the same way, re-runnable the same way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qbuAhJWtG-uOgEsfMUMJ_w.png" /><figcaption><em>A stand-in for the real UI; same layout and feature set, none of the real names, ids, or numbers.</em></figcaption></figure><p><strong>Notifier: </strong>Also pre-existing, unchanged in spirit: it reads whatever the QA Runner just wrote to the run store and posts the result back to the PR and the team chat. It didn’t need to know or care that the record it was reading now included preview-PR runs alongside every other kind of run.</p><p>The part I’d actually call the interesting design decision is the <strong>Teardown Build</strong>. It’s the same job framework as the Preview Build, but running under a separate, deliberately narrower set of permissions. The role that can create a service and open a network route is not the same role that can delete one. If something ever compromises the deploy path, it still can’t tear environments down; if something ever goes wrong <em>inside</em> the teardown path, it was never able to create anything in the first place. Two keys, not one.</p><h3>Why test-gate the build itself</h3><p>This is the one piece that’s easy to skip and costs you later: run the real unit tests <em>inside the container you’re about to ship</em>, before you push it anywhere, and fail the whole pipeline if they don’t pass. It sounds obvious written down. It’s surprisingly common to see a PR pipeline that builds an image, pushes it, deploys it, and only <em>then</em> runs tests against the running thing, which means a bad build is already live by the time you find out it’s bad. Gating on the build itself means the broken version never gets a URL.</p><h3>What it cost us to get here, specifically</h3><p>Three things broke in ways worth writing down, because none of them were the thing I expected to break.</p><p><strong>The “it’s probably rate limiting” trap.</strong> QA runs against the previews kept failing with what looked exactly like a backend rate-limit response. The obvious theory: CI runners get a rotating pool of public IPs, and whatever we’re testing against doesn’t like that. We moved the build infrastructure into a private network with a fixed outbound IP to test the theory. It didn’t fix anything. The real cause, found by actually diffing which source branch passing versus failing builds were running from, was that one project’s default branch pointer was stale — it was quietly building from an old branch that predated a safety rework in the test suite, and the “old” test code was the thing hammering a shared credential. The lesson isn’t really about rate limits. It’s that a plausible-sounding theory that fits the symptom isn’t the same as a confirmed cause, and the fastest way to tell the difference is to go compare what actually ran, not what you assume ran.</p><p><strong>Permission boundaries are contagious in ways you don’t expect.</strong> Adding new build-time configuration (test credentials, a scan-report bucket) to the <em>deploy</em> job’s permissions seemed harmless and locally scoped. It broke the <em>teardown</em> job on the very next PR close, because the underlying build platform resolves every one of a job’s configured secrets before it even looks at which specific task it’s running — including a teardown invocation using a completely different, narrower role that had never been granted access to the new secrets. The fix was simple once we understood it. Finding it meant realizing that “I only touched the deploy config” doesn’t mean “I only affected deploys,” whenever two jobs share the same underlying project definition.</p><p><strong>Bursts expose races you’ll never see in a single test.</strong> Adding several reviewers to one PR in quick succession fired six near-simultaneous webhook events for the same commit. Our dedup logic — an idempotency key keyed on PR and commit — was built for exactly this, and it mostly worked, except the six events landed close enough together that the dedup check raced itself, and all six builds started. Harmless in our case (they all redeployed the identical commit and converged), but it was a good reminder that anything you dedupe on a shared token needs to survive events that arrive at effectively the same instant, not just events that arrive seconds apart.</p><h3>What it actually gets you</h3><ul><li>A PR with a broken build never gets a URL. A PR with a passing build gets tested against <em>itself</em>, not against whatever state the last ten PRs left in shared staging.</li><li>Two PRs in flight don’t interfere with each other, because nothing about either one’s environment is shared except the edge routing layer in front of both.</li><li>Closing a PR — merge or decline — cleans up completely, automatically, with no “someone should probably delete that old service” ticket six weeks later.</li><li>The dangerous half of the system (deleting live infrastructure) runs with meaningfully less power than the half that creates it.</li><li>Every run, whatever triggered it, ends up in the same browsable history, so “did this actually run, and what happened” is a dashboard lookup, not an archaeology project through old CI logs.</li></ul><p>None of the individual pieces here are novel. Webhook-triggered builds, per-branch environments, least-privilege teardown roles — all well-trodden ground individually. What made this worth building was less any one piece and more the discipline of actually wiring test-gating, isolation, and automatic cleanup together into one system that fails closed by default, rather than three separate half-measures that each assume someone will remember to do the other two.</p><p><em>If you’re running PR tests against a single shared staging environment today and wondering whether per-PR environments are worth the build cost: the honest answer is it depends on how often your team feels the contention. If “is this failure about my code or about someone else’s test run” is a sentence anyone on your team says more than once a month, it’s worth it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa628b4fdf4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we Built a Payment App Lab on AWS ECS Fargate With Terraform and One Pipeline per Service]]></title>
            <link>https://tobaoyetola.medium.com/how-i-built-a-payment-app-lab-on-aws-ecs-fargate-with-terraform-and-one-pipeline-per-service-518e4be670aa?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/518e4be670aa</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[payment-gateway]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs-development]]></category>
            <category><![CDATA[aws-infrastructure]]></category>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Sun, 01 Nov 2026 08:23:03 GMT</pubDate>
            <atom:updated>2026-11-07T11:14:22.692Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A five-service payment app, a real domain, one </em><em>terraform apply, and a </em><em>git push that deploys only the service you changed. Here&#39;s how I built it for a free DevOps class, and what broke along the way.</em></p><p>Most container tutorials stop at docker run. My students wanted to see the part that comes after: how a team actually ships several services to the cloud, keeps secrets out of the code, and deploys on every push without touching a console.</p><p>So for the aricxpoint labs class <strong>Payment Web App Deployment</strong> I built <strong>PayLab</strong>: a small payment app where one person sends money to another person’s wallet. It runs on <strong>Amazon ECS with Fargate</strong>, behind an Application Load Balancer, with a PostgreSQL database, private service discovery, and <strong>one CI/CD pipeline per service</strong>. The whole stack comes up with one terraform apply in about 13 minutes, and goes away with one terraform destroy.</p><p>This article walks through the design decisions, the parts that are easy to get wrong when money is involved, and the lessons I learned the hard way.</p><h3>What PayLab is</h3><p>PayLab is five small services, each with its own Dockerfile, its own container image and its own deployment. Four are Node.js 20 + Express; the frontend is plain HTML and JavaScript served by a non-root nginx.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O3-nSeK0ITljlyvB.png" /></figure><p>A payment goes like this. Ada opens the page and sends ₦1,500 to @bola. The browser calls POST /api/payments on the same domain. The gateway forwards it to payment-svc, which records the payment as pending and asks wallet-svc to transfer the money. wallet-svc debits Ada, credits Bola and writes two ledger rows. payment-svc marks the payment successful and asks notify-svc for receipts. Bola&#39;s page refreshes every few seconds and the money appears.</p><p>Every new wallet gets ₦10,000 of demo money, so students can play both sides from two browser windows.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eY_kceyYB74j4p9l.png" /></figure><p>Everything lives in one AWS region (eu-west-1), in the account’s <strong>default VPC</strong>, across three Availability Zones. I kept the network deliberately simple so the class could focus on containers and delivery.</p><ul><li><strong>Application Load Balancer.</strong> The only thing open to the internet. With a domain, port 80 redirects to HTTPS on 443, using an ACM certificate. /api/* goes to api-gateway; everything else goes to web. Because the page and the API share one origin, there&#39;s no CORS to configure in production.</li><li><strong>ECS on Fargate.</strong> Five services in one cluster, one task each, 0.25 vCPU and 512 MB. No servers to patch.</li><li><strong>Three security groups, chained.</strong> alb-sg accepts 80/443 from anywhere. app-sg accepts traffic only from alb-sg and from itself (service-to-service). db-sg accepts 5432 only from app-sg.</li><li><strong>RDS PostgreSQL 16.</strong> Not publicly accessible, and the services connect to it over TLS. Its password is a SecureString in <strong>SSM Parameter Store</strong>, which ECS injects into the task as an environment variable at start-up. It never appears in code, images or Terraform outputs.</li><li><strong>ECR</strong> holds one image repository per service, and <strong>CloudWatch Logs</strong> collects every container’s output in one log group.</li></ul><p>One honest shortcut: the tasks run in public subnets with public IPs so they can pull images without a NAT gateway, which would cost more than the rest of the lab combined. Security groups still block every inbound connection that doesn’t come from the load balancer. In production I’d use private subnets with a NAT gateway or VPC endpoints.</p><h3>Moving money safely</h3><p>A payment app is a good teaching project because it punishes sloppy code. Four rules kept PayLab honest.</p><p><strong>1. Store money as integers.</strong> Balances are kept in kobo (₦1 = 100 kobo), never as floating-point naira. 0.1 + 0.2 is not 0.3 in JavaScript, and a payment system can&#39;t round its way out of that.</p><p><strong>2. Move money in one database transaction.</strong> The debit, the credit and both ledger rows commit together or not at all. If the process dies halfway, Postgres rolls everything back.</p><p><strong>3. Lock both wallets, always in the same order.</strong> Two transfers running at once, Ada to Bola and Bola to Ada, could each lock one wallet and wait forever for the other. Locking rows in id order makes that deadlock impossible:</p><pre>await client.query(&#39;BEGIN&#39;);</pre><pre>// Lock BOTH wallet rows, always in id order, so A-&gt;B and B-&gt;A<br>// at the same time can&#39;t deadlock each other.<br>const { rows: locked } = await client.query(<br>  &#39;SELECT id, balance_kobo FROM wallets WHERE id = ANY($1::int[]) ORDER BY id FOR UPDATE&#39;,<br>  [[fromWalletId, toWalletId]]<br>);</pre><pre>// Enough money?<br>const payer = locked.find((w) =&gt; w.id === fromWalletId);<br>if (Number(payer.balance_kobo) &lt; amountKobo) {<br>  await client.query(&#39;ROLLBACK&#39;);<br>  return res.status(409).json({ error: &#39;insufficient funds&#39; });<br>}</pre><pre>// Debit, credit, and write both ledger rows, then COMMIT.</pre><p><strong>4. Make every payment idempotent.</strong> Networks fail, and clients retry. Each payment carries a unique reference, and payment-svc inserts it with ON CONFLICT (reference) DO NOTHING. Send the same payment twice and you get the original back with HTTP 200, not a second charge. wallet-svc enforces the same rule on its side, so even a retry between the two services can&#39;t move money twice.</p><p>One more guard sits at the edge. wallet-svc’s /transfers endpoint is what actually moves money, so the api-gateway never exposes it. It forwards only /api/wallets and /api/payments, and checks the path after normalising it, so a trick like /api/wallets/../transfers can&#39;t reach it either. From the internet, /api/transfers is a 404.</p><h3>How the services find each other</h3><p>Fargate tasks get a new private IP every time they start: on every deploy, every crash, every scale-out. So services can’t call each other by IP. They need names.</p><p>ECS gives you two options. <strong>Service Connect</strong> adds an Envoy proxy sidecar to every task, with retries and metrics. <strong>Service discovery</strong> registers each task in <strong>AWS Cloud Map</strong>, which keeps private Route 53 DNS records up to date. My first draft used Service Connect. While preparing the class I asked myself why the services couldn’t just call each other by DNS name, since they all sit in the same network. For a lab, they can, so I switched PayLab to plain DNS.</p><p>Terraform creates a private DNS namespace, paylab.internal. Each service registers there, and its environment points at names, not IPs:</p><pre>WALLET_URL  = http://wallet-svc.paylab.internal:8082<br>PAYMENT_URL = http://payment-svc.paylab.internal:8081<br>NOTIFY_URL  = http://notify-svc.paylab.internal:8083</pre><p>When a task starts and passes its health check, ECS adds its IP as an A record. When the task stops, ECS removes it. The records have a 10-second TTL, so callers pick up a replacement within seconds. No sidecars, no proxy configuration, and students can open the namespace in the console and watch the IPs change during a deploy.</p><h3>One pipeline per service</h3><p>The point of microservices is that teams ship independently, so every service gets its own pipeline: <strong>CodePipeline (V2)</strong> with three stages.</p><ol><li><strong>Source.</strong> A CodeConnections link to GitHub. A push to main starts the pipeline.</li><li><strong>Build.</strong> <strong>CodeBuild</strong> runs the service’s buildspec.yml: log in to ECR, docker build, push two tags (the short commit hash and latest), and write imagedefinitions.json.</li><li><strong>Deploy.</strong> The ECS deploy action reads that file, registers a new task definition revision with the new image, and rolls the service onto it. Old tasks drain only after new ones pass their health checks.</li></ol><p>The commit-hash tag matters. latest tells you nothing about what&#39;s running; paylab/web:7b8bece points straight back to the commit that built it.</p><p>In class, each service had its own GitHub repo. For students I moved everything into <strong>one repo with a folder per service</strong>, so they fork once instead of six times. To keep “one pipeline per service”, each pipeline’s trigger has a file-path filter:</p><pre>trigger {<br>  provider_type = &quot;CodeStarSourceConnection&quot;<br>  git_configuration {<br>    source_action_name = &quot;Source&quot;<br>    push {<br>      branches   { includes = [var.github_branch] }<br>      file_paths { includes = [&quot;${each.key}/**&quot;] }<br>    }<br>  }<br>}</pre><p>The CodeBuild project points at &lt;service&gt;/buildspec.yml, and the buildspec uses the service&#39;s folder as the Docker build context. I tested it by pushing a change that touched only web/: paylab-web-pipeline started, and the other four didn&#39;t move.</p><p>The class finale is that demo live: change the page header, git push, and about four minutes later the change is on the real domain, without anyone opening the AWS console.</p><h3>One terraform apply</h3><p>I first built the stack as a series of numbered AWS CLI scripts, which is great for teaching what each call does. Then I rewrote it in Terraform so I could stand the whole thing up the morning of the class, and so students could too. About 70 resources, around 13 minutes, mostly waiting for RDS.</p><p>The five services are one map in locals.tf: port, CPU and memory, health-check path, environment variables, whether it needs the database, and which load-balancer target group it joins. ECR repos, task definitions, services, Cloud Map entries, CodeBuild projects and pipelines are all for_each over that map, so adding a sixth service is one new entry.</p><p><strong>The bootstrap problem.</strong> On a fresh apply, ECR is empty, but the ECS services need an image. Instead of a separate “build the first images” step, the task definitions start on :latest, and the services ignore later changes to their task definition:</p><pre>lifecycle {<br>  ignore_changes = [task_definition, desired_count]<br>}</pre><p>Until the first build finishes, the tasks fail to pull, which is expected. Meanwhile every new pipeline starts its first run by itself, builds the image, pushes it, and deploys. From then on CodePipeline owns the running version, and a later terraform apply never rolls a service back to an old image.</p><p><strong>What stays outside Terraform.</strong> A few things are created once and survive every destroy: the GitHub connection (it needs a click in the console to authorise), and, for the class domain, the Route 53 hosted zone and the ACM certificate. Terraform only looks them up with data sources. aricxpoint.co&#39;s DNS lives on Cloudflare, so I delegated only the lab subdomain to Route 53 with four NS records. Everything else on the main domain stays where it was.</p><p><strong>Domain is optional.</strong> Students don’t own aricxpoint.co, so with domain_zone left empty the same code skips HTTPS and DNS and serves the app on the load balancer&#39;s own address over HTTP. A local.use_domain flag and a few count expressions switch between the two modes.</p><h3>Cost, teardown, and why not Kubernetes</h3><p>While it runs, the stack costs about <strong>US$0.15 an hour</strong>: the load balancer, a small RDS instance, five tiny Fargate tasks and their public IPv4 addresses. Each CodeBuild run costs cents. The persistent Route 53 zone is $0.50 a month. For a three-hour class that’s well under a dollar, which is why the rule is simple: apply in the morning, terraform destroy the same day.</p><p>Why ECS Fargate and not Kubernetes? For five small services and one team, Kubernetes adds a control plane fee (about $0.10 an hour for EKS on its own), node groups to patch and scale, an ingress controller, and a lot of YAML. All of that is worth learning, and the class ends with a comparison slide. But Fargate let us spend three hours on containers, networking and delivery instead of cluster plumbing. Everything maps across: task definition to Pod spec, ECS service to Deployment, Cloud Map to Kubernetes Service DNS, ALB rules to Ingress.</p><h3>Lessons learned the hard way</h3><p><strong>npm install hung inside Docker on my Mac.</strong> Node 20 tries IPv6 and IPv4 connections in turn with a very short timeout, and on some networks every attempt to the npm registry failed. One line in each Dockerfile fixed it:</p><pre>ENV NODE_OPTIONS=--network-family-autoselection-attempt-timeout=3000</pre><p><strong>Dodge Docker Hub rate limits before they bite.</strong> CodeBuild shares IP addresses, so anonymous pulls of node:20-alpine can hit Docker Hub&#39;s limit. Before that could break a live demo, I switched the base image to the same official image on the ECR Public Gallery, public.ecr.aws/docker/library/node:20-alpine.</p><p><strong>A forgotten stack costs money quietly.</strong> After class the stack kept running for about a day and a half before I noticed, because Cost Explorer showed $0.00 while its data caught up. Now the first step in the student guide is a $5 budget alert, and I check terraform state list instead of trusting my memory.</p><p><strong>Plan files can hold secrets.</strong> A saved terraform plan -out=tfplan contains every value Terraform knows, including the generated database password. tfplan and *.tfstate go in .gitignore before the first commit, and real terraform.tfvars files never leave the laptop.</p><p><strong>A fresh database is an empty database.</strong> My first test after a rebuild failed with “recipient not found”. Nothing was broken: the new database simply had no wallet called bola yet. Create the demo wallets before the class starts.</p><p><strong>Caching can hide a successful deploy.</strong> For the push-to-deploy demo, nginx serves index.html with Cache-Control: no-cache, so a normal refresh shows the new version as soon as ECS finishes the rollout.</p><h3>Try it yourself</h3><p>The full lab is open source: <a href="https://github.com/tobaoyetola-sam/aricxpoint-labs-paylab">github.com/tobaoyetola-sam/aricxpoint-labs-paylab</a>. You need an AWS account, Terraform 1.6 or newer, the AWS CLI and a GitHub account.</p><pre># 1. Fork the repo, then:<br>git clone https://github.com/&lt;you&gt;/aricxpoint-labs-paylab.git<br>cd aricxpoint-labs-paylab/infra/terraform</pre><pre># 2. Create a GitHub connection in the CodePipeline console (status: Available),<br>#    then fill in your account id, region, connection ARN and github_repo:<br>cp terraform.tfvars.example terraform.tfvars</pre><pre># 3. Build it, wait ~8 minutes for the pipelines, open the site:<br>terraform init &amp;&amp; terraform apply<br>terraform output web_url</pre><pre># 4. When you&#39;re done:<br>terraform destroy</pre><p>Set a budget alert first, and destroy the stack the same day.</p><p>PayLab started as a three-hour free class at aricxpoint labs. If you’d like to learn DevOps and cloud this way, building real things and breaking them on purpose, you can pick a course and register at <a href="https://aricxpoint.co/lab/">aricxpoint.co/lab</a>.</p><p><em>Toba Oyetola is a DevOps coach at aricxpoint labs.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=518e4be670aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Native ECS Blue/Green Deployments: Building a Real Automated Rollback Safety Net]]></title>
            <link>https://tobaoyetola.medium.com/native-ecs-blue-green-deployments-building-a-real-automated-rollback-safety-net-899bdb307aee?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/899bdb307aee</guid>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[native-ecs-deployment]]></category>
            <category><![CDATA[blue-green-deployment]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[amazon-ecs]]></category>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Tue, 20 Oct 2026 09:58:49 GMT</pubDate>
            <atom:updated>2026-10-20T10:15:28.023Z</atom:updated>
            <content:encoded><![CDATA[<p>A walkthrough of how we replaced AWS CodeDeploy with ECS’s native Blue/Green deployment controller for a production payment API, and built a real automated safety net around it including the production incident that taught us the most.</p><h3>Why move off CodeDeploy?</h3><p>Our core payment API was already deploying to ECS as a blue/green service using AWS CodeDeploy to orchestrate the swap. CodeDeploy’s blue/green support works, but it comes with its own moving parts: a separate CodeDeploy application and deployment group, an appspec.yaml alongside your task definition, and a mental model that sits on top of ECS rather than inside it.</p><p>In 2024, AWS added a <strong>native Blue/Green deployment controller</strong> directly into ECS itself no CodeDeploy application, no appspec.yaml, just a strategy: BLUE_GREEN field on the service&#39;s own deployment configuration. It supports the same core idea (run two task sets side by side, shift traffic, keep the old one around as a fast rollback target) but as a first-class ECS feature.</p><p>We wanted to validate this before touching our actual payment-critical service, so we built it end-to-end first on a disposable rehearsal application (<a href="https://github.com/spring-projects/spring-petclinic">Spring PetClinic</a>, a well-known open-source Spring Boot demo), proved every mechanism against real deployments, real bugs, and real traffic, and only then migrated the real service over.</p><p>This post covers what we built: the architecture, the deployment lifecycle, the automated safety net (CloudWatch alarms wired to a rollback Lambda), and maybe most usefully, a real production incident that taught us our alarm thresholds were wrong, and how we fixed it.</p><h3>Architecture overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i0eDGtppzBf2mQ0NzMS8eQ.png" /><figcaption><strong>Native ECS Blue/Green Deployment Architecture</strong></figcaption></figure><p>The setup has four layers:</p><ol><li><strong>CI/CD</strong>: a CodePipeline pipeline (Bitbucket source → CodeBuild → ECS deploy action) that triggers automatically on push and registers a new task definition revision.</li><li><strong>ECS native Blue/Green service</strong>: one ECS service with deploymentController.type: ECS and deploymentConfiguration.strategy: BLUE_GREEN, sitting behind an Application Load Balancer with <strong>two target groups</strong> (call them TG-A and TG-B). On any given deployment, one is &quot;blue&quot; (currently live) and the other is &quot;green&quot; (the new revision) and they swap roles on every single deployment, so both must always be treated as potentially live.</li><li><strong>Automated safety net</strong>: four CloudWatch alarms (a 5xx-error alarm and a zero-healthy-host alarm, one pair per physical target group) publishing to an SNS topic, which triggers a Lambda that can automatically roll back a paused deployment.</li><li><strong>Notifications</strong>: Slack messages for both outcomes a rollback message posted directly by the Lambda, and a success message posted by a second Lambda triggered off the pipeline’s own SUCCEEDED event.</li></ol><p>The key design choice is that blue and green are never two separate, fixed services, they’re two target groups that trade places. An ALB listener rule matching a header (X-Test-Traffic: true) always routes to whichever one is currently &quot;green&quot; for a given deployment, letting QA (or an automated check) hit the new revision directly without it ever receiving real customer traffic until it&#39;s proven itself.</p><h3>How a deployment actually flows</h3><ol><li>Code is pushed to main → the pipeline triggers automatically.</li><li>The build compiles, builds and pushes the Docker image, and generates imagedefinitions.json for the ECS deploy action.</li><li>ECS starts a new (green) task alongside the currently-live (blue) one — blue keeps serving 100% of real traffic throughout.</li><li>Green receives 0→100% <strong>test traffic</strong>, isolated from production by the header-matching ALB rule.</li><li>The deployment <strong>pauses</strong> at the POST_TEST_TRAFFIC_SHIFT lifecycle stage and waits this is the QA gate.</li><li>QA (human or automated) hits the service through the test-traffic path and checks for errors.</li><li><strong>Branch point:</strong> either a human clicks Continue, or the automated safety net rolls it back on its own if it detects real errors.</li><li>On continue: production traffic shifts to green, a 15-minute bake time runs (both revisions still alive, still rollback-able), then the old blue task is torn down.</li></ol><p>One detail worth calling out: the pause isn’t indefinite. If nobody tests and nobody clicks anything within 60 minutes, the deployment doesn’t silently go live it defaults to rolling back on its own. Fail-safe by default, not fail-open.</p><h3>The automated safety net</h3><p>QA testing the header path is the primary check, but it only catches a bug if someone actually exercises the broken code path. The alarms exist as a second, independent layer that doesn’t depend on a human noticing anything.</p><h3>The alarms</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZX3u7f5ZSk6_EwnPlUDI4w.png" /></figure><p>One alarm <strong>per physical target group</strong>, not per role since blue and green swap which target group they occupy on every deployment, both must always be watched.</p><h3>The rollback Lambda</h3><p>Alarms publish to an SNS topic subscribed by a Lambda. On invocation, it:</p><ol><li>Looks up the service’s in-progress deployment.</li><li>Checks whether a lifecycle hook is currently AWAITING_ACTION (i.e. genuinely paused).</li><li>If yes: calls ContinueServiceDeployment(action=ROLLBACK), then posts a failure message to Slack.</li><li>If no e.g. the alarm fired during a normal deployment’s brief startup dip, before anything was paused it logs and safely does nothing.</li></ol><p>That last behavior is what makes the zero-healthy alarm safe to run continuously: every new task legitimately shows zero healthy hosts for the first few minutes of its life, before its first successful health check. The Lambda only takes real action once a deployment is genuinely paused — meaning the task already proved itself healthy once before this happened.</p><pre>import os<br>import time<br>import json<br>import urllib.request<br>import boto3</pre><pre>ecs = boto3.client(&quot;ecs&quot;)<br>ssm = boto3.client(&quot;ssm&quot;)</pre><pre>CLUSTER = os.environ[&quot;CLUSTER_NAME&quot;]<br>SERVICE = os.environ[&quot;SERVICE_NAME&quot;]<br>MAX_ATTEMPTS = int(os.environ.get(&quot;MAX_ATTEMPTS&quot;, &quot;4&quot;))<br>RETRY_DELAY_SECONDS = int(os.environ.get(&quot;RETRY_DELAY_SECONDS&quot;, &quot;5&quot;))<br>SLACK_WEBHOOK_PARAM = os.environ.get(&quot;SLACK_WEBHOOK_PARAM&quot;)</pre><pre>_webhook_url_cache = None<br></pre><pre>def lambda_handler(event, context):<br>    for record in event.get(&quot;Records&quot;, []):<br>        sns_message = json.loads(record[&quot;Sns&quot;][&quot;Message&quot;])<br>        alarm_name = sns_message.get(&quot;AlarmName&quot;, &quot;unknown&quot;)<br>        new_state = sns_message.get(&quot;NewStateValue&quot;)</pre><pre>        if new_state != &quot;ALARM&quot;:<br>            continue</pre><pre>        handle_alarm(alarm_name)<br></pre><pre>def handle_alarm(alarm_name):<br>    for attempt in range(1, MAX_ATTEMPTS + 1):<br>        in_progress = ecs.list_service_deployments(<br>            cluster=CLUSTER, service=SERVICE, status=[&quot;IN_PROGRESS&quot;],<br>        )[&quot;serviceDeployments&quot;]</pre><pre>        if in_progress:<br>            arns = [d[&quot;serviceDeploymentArn&quot;] for d in in_progress]<br>            details = ecs.describe_service_deployments(serviceDeploymentArns=arns)[&quot;serviceDeployments&quot;]</pre><pre>            for deployment in details:<br>                for hook in deployment.get(&quot;lifecycleHookDetails&quot;, []):<br>                    if hook.get(&quot;status&quot;) == &quot;AWAITING_ACTION&quot;:<br>                        ecs.continue_service_deployment(<br>                            serviceDeploymentArn=deployment[&quot;serviceDeploymentArn&quot;],<br>                            hookId=hook[&quot;hookId&quot;],<br>                            action=&quot;ROLLBACK&quot;,<br>                        )<br>                        notify_slack(alarm_name)<br>                        return</pre><pre>        if attempt &lt; MAX_ATTEMPTS:<br>            time.sleep(RETRY_DELAY_SECONDS)<br>    # Nothing paused after all attempts — safe no-op.<br></pre><pre>def notify_slack(alarm_name):<br>    global _webhook_url_cache<br>    if _webhook_url_cache is None:<br>        _webhook_url_cache = ssm.get_parameter(<br>            Name=SLACK_WEBHOOK_PARAM, WithDecryption=True<br>        )[&quot;Parameter&quot;][&quot;Value&quot;]</pre><pre>    payload = {&quot;text&quot;: f&quot;Deployment rolled back automatically — alarm: {alarm_name}&quot;}<br>    req = urllib.request.Request(<br>        _webhook_url_cache,<br>        data=json.dumps(payload).encode(&quot;utf-8&quot;),<br>        headers={&quot;Content-Type&quot;: &quot;application/json&quot;},<br>    )<br>    urllib.request.urlopen(req, timeout=10)</pre><p>One packaging gotcha worth flagging: the Lambda console’s built-in Python runtime ships an older botocore that, at the time we built this, didn&#39;t yet know about the lifecycleHookDetails field onDescribeServiceDeploymentsa brand-new API shape. The fix was to vendor a current boto3/botocore directly into the deployment package rather than relying on the runtime&#39;s bundled version. If your rollback Lambda ever silently can&#39;t find a hook that you can clearly see via the CLI, check your SDK version first.</p><h3>Validation: proving it against a real bug</h3><p>It’s one thing to trust a design on paper. We wanted to see it catch something real, so we shipped a temporary endpoint that unconditionally throws a 500, through a real commit and the real pipeline and then just used the system as intended:</p><pre>curl -s https://service.example.com/deploy-validation-check -o /dev/null -w &quot;blue (no header): %{http_code}\n&quot;<br>curl -s -H &quot;X-Test-Traffic: true&quot; https://service.example.com/deploy-validation-check -o /dev/null -w &quot;green (header): %{http_code}\n&quot;</pre><p>The chain of events, evidenced end to end:</p><ol><li>Test traffic hit the broken endpoint on green roughly 85 times, each returning 500.</li><li>The 5xx count on green’s target group crossed the threshold two minutes running.</li><li>The alarm entered ALARM.</li><li>SNS invoked the Lambda; it rolled back on the first attempt, no retries needed.</li><li>ECS unwound the deployment automatically: ROLLBACK_IN_PROGRESS → CLEAN_UP → ROLLBACK_SUCCESSFUL.</li><li>Production never left 200 OK the entire time.</li><li>The tail end of the test-traffic burst flipped from 500 to 404 the exact moment the rollback completed and the buggy code was gone from the target being hit.</li></ol><p>That last point is the one that made us trust the system: we could watch, in the raw HTTP responses, the precise second the bad code stopped existing on the infrastructure with zero impact to real customers the entire time.</p><h3>The lesson that only production could teach us</h3><p>After validating everything on a low-traffic rehearsal service, we migrated the real payment API over. Shortly after, a routine deployment rolled back and the new code was completely innocent.</p><p>Here’s what actually happened. Our 5xx alarm was configured with a threshold of <strong>5 errors in a minute, for 2 consecutive minutes</strong>. That number was chosen during rehearsal testing against a service doing a handful of requests per second. The real production API runs at roughly <strong>1,700+ requests per minute</strong>. At that volume, a completely normal background error rate — well under 1% of traffic was enough to cross a raw count of 5 per minute on its own, with no relation to the deployment at all.</p><p>Worse: the alarm that fired was watching the <strong>blue</strong> target group the already-live, already-proven revision not the green one being tested. The new code was sitting there with zero errors, and still got rolled back, because our Lambda (correctly, by its own logic) doesn’t distinguish <em>which</em> revision tripped the alarm. Any elevated 5xx rate on <em>either</em> physical target group during the pause window triggers a rollback.</p><p><strong>The fix</strong> was straightforward once we pulled the real numbers: we looked at two hours of actual production 5xx counts, found a normal baseline of roughly 2–22 errors per minute with occasional genuine spikes into the 80–106 range, and moved the threshold from 5 to 60 comfortably above all observed baseline noise, comfortably below every real spike we’d actually seen. Same evaluation window (2 consecutive minutes), same everything else. We verified it against live traffic data before rolling it out, then proved it across two real deployments with zero false triggers.</p><p>The takeaway: <strong>a threshold calibrated during low-traffic testing does not automatically survive contact with real production volume.</strong> Raw error <em>counts</em> scale with traffic; if you set a count-based threshold early, revisit it once real traffic arrives or better, consider an error-rate-based alarm (5xx as a percentage of total requests) instead of a raw count, so it stays correctly calibrated as traffic grows or shrinks.</p><h3>Key takeaways</h3><ul><li><strong>Rehearse on a disposable service first.</strong> Everything here was proven with real killed tasks, a real shipped bug, and real traffic on a low-stakes app before it ever touched the payment API.</li><li><strong>Alarms, not just QA, are your real safety net.</strong> A QA check only catches what someone thinks to test; an independent alarm-driven rollback catches what nobody thought to look for.</li><li><strong>Watch both physical target groups, not both roles.</strong> Blue and green swap which target group they occupy every single deployment alarms scoped by role instead of by target group will silently watch the wrong thing half the time.</li><li><strong>A zero-healthy alarm needs to tolerate normal startup.</strong> Every new task is briefly unhealthy by design; the safety net has to distinguish “still starting up” from “genuinely paused and broken.”</li><li><strong>Recalibrate thresholds when traffic changes.</strong> A threshold tuned against rehearsal-scale traffic is a guess, not a measurement, once real production volume arrives go back and set it from actual observed data.</li><li><strong>Check your Lambda’s bundled SDK version</strong> before assuming an API field doesn’t exist it might just be newer than what the runtime ships.</li></ul><p>Native ECS Blue/Green gets you most of the way to a safe, CodeDeploy-free deployment story. The part worth investing real time in is everything <em>around</em> it — the alarms, the rollback logic, and the discipline to revisit your assumptions once real traffic shows up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=899bdb307aee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Maestro Automation: Automating Mobile UI Testing on Real Devices with AWS Device Farm]]></title>
            <link>https://tobaoyetola.medium.com/mobile-maestro-automation-automating-mobile-ui-testing-on-real-devices-with-aws-device-farm-aecd7776a28f?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/aecd7776a28f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[aws-codebuild]]></category>
            <category><![CDATA[mobile-maestro-automation]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[qa-automation]]></category>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 14:20:22 GMT</pubDate>
            <atom:updated>2026-09-11T15:21:50.442Z</atom:updated>
            <content:encoded><![CDATA[<p>How I built a zero-touch pipeline that runs Maestro UI tests on a real Android device for every PR and nightly against production.</p><h3>Overview</h3><p>This project holds the Maestro UI test flows for an Android app and the AWS infrastructure that runs them automatically, on a real Android device, via AWS Device Farm reporting results to Slack with zero manual steps once triggered.</p><p>Two repos are involved:</p><ul><li><strong>android-project-repo:</strong>the actual Android app project.</li><li><strong>mobile-maestro-automation:</strong>holds the Maestro flows for both Android and iOS. This particular project was focused on the Android side of it, and this repo is connected to CodeBuild, which runs the runner project (mobile-maestro-qa-runner).</li></ul><p>Two distinct pipelines exist, built at different times for different reasons:</p><ol><li><strong>Nightly regression</strong>: A full Android Maestro suite runs once a day against whatever the latest production build is, independent of any pull request, to catch regressions that have nothing to do with a code change (a backend API change, an SDK update, a feature flag flip).</li><li><strong>PR-time gate</strong>: Built later, in response to a specific need before a pull request merges, build a debug APK from that exact PR, run the Maestro suite against it, and let QA review the result, all without touching the existing production build pipeline in any way.</li></ol><h3>Goals &amp; Constraints</h3><p><strong>What needed to be built:</strong></p><ul><li>A CI job that builds the app, runs Maestro against it on a real device, and reports pass/fail. The app features covered and their current result:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rmyx19_LBEWtfc1yiM1sA.png" /></figure><ul><li>A PR flow where a merge to master/production only happens after QA has reviewed a real test result for that exact PR.</li></ul><h4><strong>Architecture</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5BiU3lJ-kXW3QcAsk3BAbA.png" /></figure><p>The two pipelines share no infrastructure except read-only awareness of each other separate CI projects, separate S3 buckets, separate Slack identities, separate IAM statements. The only place they ever meet is a human merging a PR, exactly as before this project existed.</p><p>At a glance, the diagram walks through both flows end to end:</p><ul><li><strong>PR-time gate (top left):</strong> a PR raised or updated on the Android repo triggers a CI build that mirrors the production buildspec, minus the PR-validation gate that would otherwise skip it. That build posts a “build success” Slack message, uploads a debug APK to its own dedicated S3 bucket, and hands off cross-region to the Device Farm runner via a direct codebuild:StartBuild call.</li><li><strong>Nightly schedule (top right):</strong> an EventBridge Scheduler cron rule kicks off the same runner once a day, with no PR involved at all.</li><li><strong>Test run (center):</strong> the runner project uploads the APK and test package to AWS Device Farm, which runs the Maestro flows on a real device and returns a pass/fail result. A build-state-change event fires a separate notifier Lambda, which posts the actual test outcome to its own Slack webhook decoupled from the runner’s own build steps.</li><li><strong>Merge gate (bottom):</strong> QA reviews the result from both the build-success webhook and the test-result webhook. Once approved, the Android team merges the PR into the untouched production pipeline, which builds the real release APK into the production bucket completely independent of everything above it.</li></ul><h4>Part 1: Nightly Regression Pipeline</h4><p>Built first, as an AWS SAM template, deployed as its own CloudFormation stack in one region.</p><h4>Device Farm setup</h4><p>AWS Device Farm’s Project/DevicePool resources only exist in a single region, which pins the entire nightly stack to that region no exceptions. The template defines:</p><ul><li>A <strong>Device Farm Project</strong>: the logical container Device Farm groups uploads and runs under.</li><li>A <strong>Device Pool</strong>: the specific set of real physical Android devices a run is scheduled against.</li><li>A <strong>Custom Test Environment spec</strong>: Device Farm’s “custom” test type doesn’t have a literal SDK label for what this project does, so the buildspec uses a placeholder value purely as a required field the spec file fully overrides what actually runs, which is a shell script completely unchanged from how a QA engineer would run it locally.</li></ul><h4>The runner project (mobile-maestro-qa-runner)</h4><p>A CodeBuild project that does <em>not</em> build the app itself. Its buildspec:</p><ol><li><strong>install</strong>: Resolves 20 maestro-* test-identity values from SSM Parameter Store into MAESTRO_* environment variables (never logged/echoed).</li><li><strong>pre_build</strong>: Downloads a pre-built debug APK from S3 (it decides <em>which</em> commit’s APK to fetch).</li><li><strong>build</strong>: Uploads the APK, the test package (this repo’s android/ flows + scripts/), and the test spec to Device Farm; schedules a run; polls until it reaches a terminal state.</li><li><strong>post_build</strong>: Downloads the run’s result artifacts, extracts the real JUnit XML report and archives it to S3, and exits non-zero if the Device Farm result wasn’t PASSED.</li></ol><p><strong>Why the runner doesn’t build the app:</strong> by the time this pipeline needs an APK, the app’s own CI has already built one. Re-building from source here would mean maintaining a second, parallel Gradle/JDK/Android-SDK toolchain for no benefit just fetch what already exists.</p><h4>The notifier Lambda</h4><p>A standalone Lambda, decoupled from the runner’s own build steps. It’s invoked by an event rule that fires on <em>any</em> “Build State Change” event for the runner project, regardless of what triggered that build (manual, PR hand-off, or nightly schedule). It re-reads the finished build via the CI provider’s API, pulls the real test summary, formats a Slack Block Kit message (colored bar, pass/fail counts, log/report links), and posts it using a webhook URL it reads from a parameter store at invoke time so rotating that webhook never needs a redeploy.</p><h4>Enabling the nightly schedule</h4><pre>Name: mobile-maestro-qa-nightly<br>ScheduleExpression: cron(0 2 * * ? *)<br>ScheduleExpressionTimezone: &lt;local timezone&gt;  # fixed UTC offset, no DST<br>Target: mobile-maestro-qa-runner, with explicit overrides:<br>  ANDROID_APK_BUCKET=&lt;production apk bucket&gt;<br>  ANDROID_APK_PREFIX=&lt;prefix&gt;<br>  ANDROID_APK_BUCKET_REGION=&lt;region&gt;<br>  # ANDROID_COMMIT_ID deliberately left unset —<br>  # pre_build auto-resolves whichever commit&#39;s dev/debug APK<br>  # was uploaded most recently.</pre><p>Explicit overrides matter here specifically because the runner project’s own <em>persisted default</em> bucket now points at the PR-gate’s dedicated bucket for its own purposes without these overrides, a nightly run would silently test the wrong artifact.</p><h4>Part 2: PR-Time Gate Pipeline</h4><p>Built later, as a plain CloudFormation template, deployed as its own stack in the same region the real production pipeline runs in.</p><h4>Why a separate project, not a change to the real pipeline</h4><p>The design goal (“gate a PR merge on a real Maestro run”) could theoretically have been bolted onto the production pipeline directly. That was rejected outright: any mistake in new logic added to that pipeline risks the real release process. Instead, a brand-new CI project was created to carry 100% of the new logic, leaving the original completely untouched.</p><h4>Mirroring the buildspec, byte-for-byte</h4><p>The new project’s build steps aren’t a rewrite they’re the production pipeline’s own live build steps, fetched directly from the CI provider’s API and copied verbatim: same JDK/Android SDK install steps, same lint → static-analysis → permissions-check → test task sequence, same bundle/assemble step, same Gradle JVM args. Only three things were deliberately changed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7eyJEzl0pBots3BMSlu62Q.png" /></figure><p>Everything else JDK setup, SDK license acceptance, Gradle flags, even a stale-looking tooling URL was left exactly as the real pipeline has it, on purpose: fidelity to production behavior was the entire point.</p><h4>Dedicated bucket + cache</h4><p>A new bucket holds both this project’s APK uploads (with a 30-day lifecycle) and its own Gradle/SDK build cache deliberately not sharing anything with the production bucket. IAM access to it is granted as its own narrowly-scoped policy statement, additive to the shared CI service role used across many unrelated projects in the account.</p><h4>Cross-region hand-off, not polling</h4><p>The very last build step calls the CI provider’s “start build” API directly on the nightly runner project (a different project, in a different region), passing the exact commit ID and bucket as environment overrides. This is fire-and-forget: the PR-gate project doesn’t wait for the Device Farm run to finish, and its own success/failure is independent of the Maestro result. QA reviews the actual test outcome later, via Slack.</p><pre>PR_BRANCH=&quot;${CODEBUILD_WEBHOOK_HEAD_REF##refs/heads/}&quot;<br><br>aws codebuild start-build \<br>  --project-name mobile-maestro-qa-runner \<br>  --region &lt;runner-region&gt; \<br>  --environment-variables-override \<br>    name=ANDROID_COMMIT_ID,value=${IMAGE_TAG},type=PLAINTEXT \<br>    name=ANDROID_APK_BUCKET,value=${MAESTRO_BUCKET},type=PLAINTEXT \<br>    name=TRIGGER_SOURCE,value=pr:${PR_BRANCH},type=PLAINTEXT</pre><h3>Slack branding, kept separate</h3><p>The build-success message for this project posts through its own dedicated Slack app/webhook rather than the shared one the production pipeline uses a glance at Slack alone now tells you which pipeline posted a message. One message still has to share a webhook (the QA-facing “APK ready for review” ping, which reuses the existing QA Slack channel); there, a per-message username override achieves the same visual separation without touching the shared app&#39;s own identity:</p><pre>curl -X POST -H &quot;Content-type: application/json&quot; \<br>  --data &quot;{\&quot;username\&quot;: \&quot;maestro-bot\&quot;, \&quot;text\&quot;: \&quot;$QA_SLACK_MESSAGE\&quot;}&quot; \<br>  &quot;$SLACK_QA_WEBHOOK_URL&quot;</pre><h4>Build webhook</h4><p>The live webhook’s filter groups match the production pipeline’s own pattern exactly: push and PR-created/updated/merged events across release, RC, feature, development, and regression branches, plus an unfiltered catch-all for everything else. Comment approval is disabled a matching event triggers the build immediately, no manual approval step.</p><h3>How I Used SAM in my Mobile Maestro Automation</h3><p><strong>Why SAM for this part:</strong> SAM (Serverless Application Model) is a thin layer over CloudFormation, purpose-built for stacks that mix serverless pieces, like the notifier Lambda, with regular infrastructure like the Device Farm project, IAM roles, and the EventBridge schedule. It gave a few things that plain CloudFormation would have meant writing by hand: shorthand resource types for Lambda functions and their event sources, sam build/sam deploy as a single local workflow for packaging and pushing the Lambda code, and automatic handling of the S3 upload/versioning that Lambda deployments need. The PR-time gate pipeline, by contrast, has no serverless component of its own, so it&#39;s a plain CloudFormation template instead. SAM&#39;s extra syntax wouldn&#39;t have bought anything there.</p><h4>How SAM is used here, specifically</h4><p>SAM manages exactly one stack in this project: the nightly-regression infrastructure. It has never touched the PR-gate pipeline; that one is deployed as plain CloudFormation. The one place SAM’s shorthand actually matters is the notifier Lambda. It’s declared as AWS::Serverless::Function rather than a raw AWS::Lambda::Function. That single resource type expands into the function itself, its execution role, and its EventBridge trigger wiring, instead of three or four separate resources written by hand. Everything else in the stack, the runner CodeBuild project, the Device Farm project and device pool, the EventBridge schedules, is plain CloudFormation that happens to live inside a SAM template; SAM&#39;s packaging step just doesn&#39;t have anything to do for those.</p><p><strong>What’s SAM-managed vs. not:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FqS6eU11xipkn_8SoCkLLA.png" /></figure><p>Keeping this boundary straight matters day to day: mixing up which pipeline is SAM-managed is exactly how you accidentally revert someone’s manual fix on a deploy that had nothing to do with it.</p><h4>The workflow</h4><p>Every change to the SAM-managed stack went through the same three commands, in the same order:</p><pre># 1. Validate<br>sam validate --lint --region &lt;device-farm-region&gt;</pre><p>The explicit --region matters: Device Farm&#39;s Project and DevicePool resource types only exist in one specific region, and cfn-lint defaults to a different region if you don&#39;t pin it. The first validation attempt failed for that reason alone, not a real template error.</p><pre># 2. Build<br>sam build</pre><p>Installs the notifier Lambda’s dependencies and zips it up for deployment. For everything else in the template, the CodeBuild project, Device Farm resources, schedules, this step is a no-op; there’s nothing to package.</p><pre># 3. Deploy<br>sam deploy --no-confirm-changeset</pre><p>samconfig.toml sets confirm_changeset = true by default, a sensible guard for an interactive terminal, but every deploy here ran non-interactively, so the override was needed every time to avoid hanging on a prompt nothing was there to answer.</p><h4>samconfig.toml</h4><p>The config file is gitignored on purpose. It carries this specific AWS account’s stack name, region, and parameter choices, so sam deploy runs the same way every time without --guided:</p><pre>[default.deploy.parameters]<br>stack_name = &quot;mobile-maestro-qa&quot;<br>region = &quot;&lt;device-farm-region&gt;&quot;<br>resolve_s3 = true<br>capabilities = &quot;CAPABILITY_NAMED_IAM&quot;<br>confirm_changeset = true<br>parameter_overrides = &quot;&quot;&quot;\<br>EnableIosRunner=&quot;false&quot; \<br>EnableAndroidNightly=&quot;true&quot; \<br>Env=&quot;staging&quot; \<br>AndroidApkBucket=&quot;&lt;production apk bucket&gt;&quot; \<br>AndroidApkPrefix=&quot;api-ci&quot; \<br>AndroidApkBucketRegion=&quot;&lt;production region&gt;&quot; \<br>...<br>&quot;&quot;&quot;</pre><p>That AndroidApkBucket value is worth noticing: it&#39;s not the account&#39;s original default. It was changed deliberately so the PR-gate hand-off works without needing an override on every call, and it&#39;s captured here so a future sam deploy doesn&#39;t quietly undo that decision.</p><h4>Real deploys, in order</h4><ol><li><strong>Initial stack creation:</strong> the nightly Android and iOS runner infrastructure, Device Farm project/pool, and notifier Lambda. The original scope of this project, before the PR-gate work existed.</li><li><strong>Reporting fix:</strong> added an unzip step to the runner’s post-build phase so Device Farm’s JUnit output actually reaches the build’s own report collection instead of being silently skipped.</li><li><strong>Nightly schedule enabled + timezone + commit auto-resolve:</strong> two deploys, not one. The first correctly enabled the schedule but exposed a missing s3:ListBucket permission that had been patched in via CLI rather than the template, so the very next sam deploy silently reverted it. The second deploy added the fix into the template itself.</li><li><strong>Test-identity SSM key rename:</strong> updated the install-phase key list and env-var derivation logic so the renamed parameter-store paths resolve without changing what the Maestro flow files actually reference.</li></ol><h4>The drift lesson, generalized</h4><p>The rule this project kept re-learning: <strong>any resource CloudFormation manages gets reset to whatever the template and parameters say on the next deploy, regardless of what a direct console or CLI edit changed in between.</strong> A fix that isn’t in the template doesn’t survive. It happened once with the IAM policy behind the nightly commit auto-resolve, and the lesson from then on was simple: any change meant to persist goes into the template first, confirmed by re-checking the live resource right after every subsequent deploy.</p><h4>Bugs Found &amp; Fixed</h4><p>Each of these was confirmed live against real AWS resources before being fixed, nothing here is theoretical.</p><h4>Bug 1: Slack said “no tests ran” despite Device Farm running real tests</h4><p>Device Farm’s JUnit output only ever comes back inside a customer-artifact zip, nested several directories deep never as a loose .xml file. The build steps downloaded that zip but never unzipped it, so the report-matching glob found nothing, silently skipped the regroup script, and the CI provider&#39;s own reports block also found zero XML files registering an empty report even though Device Farm had genuinely run and reported real pass/fail counts. <strong>Fix:</strong> unzip (flattened) each downloaded artifact before the existing checks run.</p><h4>Bug 2: Nightly’s commit auto-resolve had no S3 ListBucket permission</h4><p>Enabling the nightly schedule required a way to find “the latest” commit’s APK without an explicit override. The IAM policy backing this lookup only granted s3:GetObject, scoped to a single parameter that had since been repointed at the PR-gate&#39;s dedicated bucket for its own purposes. <strong>Fix:</strong> split into explicit statements so access to the production bucket plus the s3:ListBucket the lookup itself needs no longer depends on whatever that parameter happens to be set to.</p><h4>Bug 3: AWS CLI pagination silently broke “find the latest” logic</h4><p>sort_by(...)[-1] inside a CLI --query gets applied <strong>per page</strong>, not over the fully-merged result, once a listing spans more than one page confirmed directly: one prefix had 15+ pages of objects, and the naive query returned one &quot;latest&quot; per page (15 results) instead of one true latest. <strong>Fix:</strong> keep --query to a plain filter/projection only; do the actual sort and take-last with jq after the CLI has merged every page into one JSON array.</p><h4>Bug 4: A direct CLI edit was silently reverted by the next deploy</h4><p>An IAM policy was patched directly via the CLI to unblock testing quickly. The next routine infrastructure deploy (for an unrelated change) silently reverted it back to whatever the template said, since CloudFormation owns that exact resource. <strong>Lesson, applied from then on:</strong> any change meant to persist has to go into the template itself, not just live infrastructure confirmed by re-checking the live resource immediately after every subsequent deploy.</p><blockquote><strong>Bug 5:</strong> ScheduleExpressionTimezone vs. ScheduleExpressionTimeZone</blockquote><p>A simple casing mistake (capital Z) on the scheduler property name was rejected outright by CloudFormation (&quot;extraneous key... is not permitted&quot;) the real property uses a lowercase z, confirmed against the actual resource schema rather than guessed a second time.</p><h4>Reading the Slack Messages</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6yZdXtBOidOAWiBNkJpsA.png" /></figure><h4>Where to look when something fails</h4><ol><li>Check the build’s failed phase for the exact failing command.</li><li>Pull the full build log output for that build ID.</li><li>For a Device Farm result specifically: walk down from the run, to jobs, to suites, to tests, to artifacts, to get the actual Maestro flow output — the real pass/fail per-flow breakdown.</li></ol><h4>Project Status</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7B890PezhHiwGa8Yu8_Uw.png" /></figure><blockquote>This project was built solo, end to end: infrastructure as code, two independent CI pipelines, a notification Lambda, and the debugging that came with getting real device automation to behave reliably in production. If you’re setting up something similar with AWS Device Farm and Maestro, I’m happy to talk through any of it, feel free to reach out.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aecd7776a28f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ECS & EKS Weighted Traffic Routing]]></title>
            <link>https://tobaoyetola.medium.com/ecs-eks-weighted-traffic-routing-c8786b2c41e6?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8786b2c41e6</guid>
            <category><![CDATA[weighted-routing]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[backend-architecture]]></category>
            <category><![CDATA[amazon-ecs]]></category>
            <category><![CDATA[amazon-eks]]></category>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Sat, 20 Jun 2026 13:37:03 GMT</pubDate>
            <atom:updated>2026-06-20T15:27:55.910Z</atom:updated>
            <content:encoded><![CDATA[<p>This write-up demonstrates the implementation of AWS Route 53’s Weighted Routing Policy to distribute traffic evenly between two backend environments, Amazon ECS and Amazon EKS both serving the Spring Petclinic demo application under the unified domain demo-app.cloudlab.dev.</p><blockquote>Goal: Achieve a 50/50 traffic split between ECS and EKS deployments using Route 53Weighted Routing, verified via 1,000-request load testing.</blockquote><h4><strong>Architecture</strong></h4><p>The traffic flow follows this path:<br>● User sends HTTPS request to demo-app.cloudlab.dev<br>● Route 53 applies Weighted Routing Policy (Weight 50/50) and resolves to one of two CNAME targets<br>● Request hits the selected Application Load Balancer (ALB)<br>● ALB matches the Host Header rule for demo-app.cloudlab.dev and forwards to the Target Group<br>● Target Group routes to the healthy ECS Task or EKS Pod<br>● ALB Access Logs are delivered to S3 every ~5 minutes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCkNpaEYJVNH5kmhIEbsYg.jpeg" /><figcaption><em>ECS &amp; EKS Weighted Routing Architecture: </em>cloudlab.dev</figcaption></figure><h4>Component Summary</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*lCJXoBjHt5euXJVpcpQRig.png" /></figure><h4>Route 53 Configuration</h4><p>DNS Records: Two weighted CNAME records were created under the hosted zone cloudlab.dev:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*1LiH82Fwoik4FFz7jSLz1Q.png" /></figure><h4><strong>Key Configuration Decisions</strong></h4><p>● Weight 50/50: Equal weights ensure even traffic distribution between ECS and EKS<br>● TTL 60s: Reduced from 300s to 60s to allow faster DNS switching and more balanced distribution during testing<br>● CNAME values use bare hostnames only (no https:// prefix) as required by DNS standards</p><h4><strong>ALB Host Header Configuration</strong></h4><p>Why Host Headers Were Required When Route 53 resolves demo-app.cloudlab.dev to an ALB via CNAME, the HTTP request carries:</p><blockquote>Host: demo-app.cloudlab.dev</blockquote><p>Without a matching listener rule, the ALB returns a 404 Not Found error because it only knew about its original domain. The fix was to add demo-app.cloudlab.dev as an OR condition on each ALB’s listener<br>rule.</p><h4><strong>ALB Listener Rule — EKS ALB</strong></h4><p>Listener: HTTPS:443 | Rule: demo-app-https-rule</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*02jyyXzrJZ1JQiml8h9xyw.png" /></figure><h4>ALB Listener Rule — ECS ALB</h4><p>Listener: HTTPS:443 | Rule: demo-app-ecs-https-rule</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*3i8lZAEI-yvgeoO8VTiyFw.png" /></figure><h4>ALB Access Logs</h4><p><strong>Configuration: </strong>ALB Access Logs were enabled on both load balancers to monitor and audit traffic distribution. Logs are delivered to dedicated S3 buckets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ThAfxR0lY67JZVo9NpvHzg.png" /></figure><h4>S3 Log Path Structure</h4><blockquote>s3://your-bucket/AWSLogs/{account-id}/elasticloadbalancing/<br>eu-west-1/{year}/{month}/{day}/<br>{account-id}_elasticloadbalancing_eu-west-1_{alb-name}_{timestamp}.log.gz</blockquote><h4>Reading Logs</h4><p>To download and read logs from S3:</p><blockquote>aws s3 cp s3://your-bucket/path/to/file.log.gz .<br>gunzip file.log.gz<br>cat file.log</blockquote><h4>Traffic Distribution Verification</h4><p>Test Methodology</p><p>A bash script was used to send 1,000 HTTPS requests to demo-app.cloudlab.dev. DNS resolution was forced through Google’s public DNS (8.8.8.8) using dig to bypass local and ISP-level DNS caching. Each resolved IP was tracked and mapped back to its respective ALB.</p><blockquote>#!/bin/bash<br>echo “Sending 1000 requests to demo-app.cloudlab.dev…”<br>echo “============================================”<br>results=””<br>for i in $(seq 1 1000); do<br> IP=$(dig +short demo-app.cloudlab.dev <a href="http://twitter.com/8">@8</a>.8.8.8 | tail -1)<br> curl -s -o /dev/null -H “Host: demo-app.cloudlab.dev” <a href="https://$ip/">https://$IP</a> — insecure<br> results=”$results$IP”$’\n’<br> echo “Request $i → $IP”<br> sleep 0.1<br>done<br>echo “”<br>echo “============================================”<br>echo “RESULTS SUMMARY”<br>echo “============================================”<br>echo “$results” | python3 -c “<br>import sys<br>from collections import Counter<br>ips = [line.strip() for line in sys.stdin if line.strip()]<br>total = len(ips)<br>counts = Counter(ips)<br>for ip, count in counts.most_common():<br> percent = count * 100 / total<br> print(f’IP: {ip} → {count} requests ({percent:.1f}%)’)<br>print(f’Total: {total} requests across {len(counts)} ALB(s)’)<br>“<br>echo “============================================”</blockquote><h4>IP to ALB Mapping</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*b0Syvq5U1LZJQ_kP7BkVZA.png" /></figure><h4>Test Results: Run 1 (1,000 Requests)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*U8ryJKWWPtVjEZCXCYlcUQ.png" /></figure><h4>Test Results: Run 2 (1,000 Requests)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*Hs9ig9hHZMW1P20ZTkPIgg.png" /></figure><h4>Conclusion:</h4><blockquote>Across two independent 1,000-request tests, traffic distribution was 52/48 and 51/49 — confirming that Route 53 Weighted Routing is correctly splitting traffic ~50/50 between ECS and EKS as configured.</blockquote><h4>Troubleshooting &amp; Lessons Learned</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*OY6mD8qX4sSaJMbnzNchdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*19fQd8ndmQ4lSa4HuC_tew.png" /></figure><h4>Summary</h4><p>The implementation successfully achieves a 50/50 traffic split between Amazon ECS and Amazon EKS deployments under the domain demo-app.cloudlab.dev. Route 53 Weighted Routing with equal weights (50/50) and a 60-second TTL ensures near-real-time traffic balancing. Both ALBs are configured with the correct Host Header rules and Access Logs are<br>enabled for ongoing observability.</p><h4>Key Outcomes</h4><blockquote>● Route 53 Weighted Routing configured and verified<br>● Both ALBs accepting traffic under demo-app.cloudlab.dev<br>● Traffic distribution confirmed at ~50/50 across 2,000 test requests<br>● ALB Access Logs enabled on both load balancers<br>● Each ALB has 3 IPs across 3 Availability Zones for high availability</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8786b2c41e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blue/Green Deployment for Payment Infrastructure on Amazon ECS Using AWS CodeDeploy & CodePipeline…]]></title>
            <link>https://tobaoyetola.medium.com/blue-green-deployment-poc-for-payment-infrastructure-on-amazon-ecs-using-aws-codedeploy-33f89be4885a?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/33f89be4885a</guid>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[blue-green-deployment]]></category>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 18:12:40 GMT</pubDate>
            <atom:updated>2026-04-23T07:21:23.500Z</atom:updated>
            <content:encoded><![CDATA[<h3>Blue/Green Deployment for Payment Infrastructure on Amazon ECS Using AWS CodeDeploy &amp; CodePipeline (Traffic header route Implementation)</h3><h4>How i implemented zero-downtime deployments with intelligent traffic routing across a microservice payment architecture</h4><h3>Background</h3><p>Deploying to production in a payment infrastructure is never trivial. A failed deployment doesn’t just mean an error page — it can mean failed transactions, broken checkout flows, and a direct hit to revenue. For a long time, the standard approach was to deploy, hope for the best, and roll back manually if something went wrong. That approach carries too much risk.</p><p>This article documents a proof of concept (POC) I built to implement Blue/Green deployment for a microservice-based payment platform running on Amazon ECS, using AWS CodeDeploy and CodePipeline — with a custom traffic header routing strategy that allows QA to test new deployments on production infrastructure before a single real user is affected.</p><h3>The Architecture</h3><p>The platform is built on a microservice architecture with four core services:</p><ul><li><strong>Payment Service</strong> — the primary service, handles payment orchestration</li><li><strong>Authentication Service</strong> — handles auth and identity</li><li><strong>Transaction Service</strong> — manages transaction records and state</li><li><strong>Direct Debit Service</strong> — processes direct debit operations</li></ul><p>These services are tightly coupled in their call chains:</p><ul><li>Payment Service calls Authentication, Transaction, and Debit services</li><li>Authentication Service calls Transaction and Debit services</li><li>Transaction Service calls Authentication and Payment services</li></ul><p>This interdependency is what makes deployment interesting — and risky. Deploying a new version of Payment Service while it calls three downstream services means you need confidence that the new version works correctly end-to-end, not just in isolation.</p><h3>The Problem with Traditional Deployments</h3><p>Before this POC, deployments followed a rolling update pattern: push a new version, ECS gradually replaces tasks, and if something breaks you roll back. The problems with this approach in a payment context are:</p><ul><li><strong>No pre-production validation on real infrastructure</strong> — staging environments never perfectly mirror production</li><li><strong>Rollback takes time</strong> — during a rolling rollback, some users are still hitting the broken version</li><li><strong>No way to test the full call chain</strong> — you cannot verify how a new Payment Service version interacts with downstream services until it is already live</li></ul><p>Blue/Green deployment solves all three of these.</p><h3>What is Blue/Green Deployment?</h3><p>Blue/Green deployment runs two identical environments simultaneously:</p><ul><li><strong>Blue</strong> = the current live version, serving 100% of production traffic</li><li><strong>Green</strong> = the new version, fully deployed and running but serving 0% production traffic</li></ul><p>Traffic only shifts from Blue to Green after the new version is verified healthy. If Green has a problem, you simply do not reroute — Blue keeps running without interruption. There is no rollback process because Blue never went away.</p><pre>Before deployment:    Blue (100% traffic) | Green (0% — not deployed)<br>During QA window:     Blue (100% traffic) | Green (0% production — available for test traffic)<br>After approval:       Blue (0% traffic)   | Green (100% traffic)</pre><h3>Architecture Diagram</h3><p>The following diagram illustrates the end-to-end architecture of the Blue/Green deployment pipeline, from developer code push through to the live ECS Fargate service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*giO8dpV5rgm-BAMfacObJQ.png" /></figure><h3>The Core Challenge — Testing Across a Microservice Call Chain</h3><p>Here is where it gets interesting. When QA tests the Green deployment of Payment Service, that service in turn calls Authentication, Transaction, and Debit services. Those downstream services have not been updated — they only have Blue deployments.</p><p>The question is: <strong>how do you route test traffic intelligently across the entire call chain?</strong></p><p>The solution is a test-traffic header that propagates through every service call. The Payment Service ALB checks for this header and routes accordingly. Downstream services do not need special routing rules — they only have one deployment each, so all traffic (including test traffic carrying the header) automatically goes to their Blue deployments.</p><pre>QA Mobile App (test-traffic: true)<br>  ↓<br>Payment ALB → GREEN (Payment Service — new version)<br>  ↓ propagates test-traffic: true header<br>Authentication ALB → BLUE (only deployment — routes all traffic here)<br>  ↓ propagates test-traffic: true header<br>Transaction ALB → BLUE (only deployment)<br>  ↓ propagates test-traffic: true header<br>Debit ALB → BLUE (only deployment)</pre><p>Production users without the header flow entirely through Blue across all services, completely unaffected.</p><h4>Blue/Green Deployment — Payment Service (ECS + CodeDeploy) Traffic header route Implementation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*pEg51-P-gFA55z21cCdfkg.png" /></figure><h3>Infrastructure Setup (ECS Service Configuration)</h3><p>The key requirement for Blue/Green on ECS is that the service must be created with the CODE_DEPLOY deployment controller. This cannot be changed after creation — it must be set at service creation time.</p><pre>aws ecs create-service \<br>  --cluster your-cluster \<br>  --service-name payment-service \<br>  --task-definition payment-service:latest \<br>  --desired-count 1 \<br>  --launch-type FARGATE \<br>  --deployment-controller type=CODE_DEPLOY \<br>  --load-balancers &quot;targetGroupArn=YOUR_TG1_ARN,containerName=payment-service,containerPort=8080&quot; \<br>  --network-configuration &quot;awsvpcConfiguration={subnets=[subnet-xxx],securityGroups=[sg-xxx],assignPublicIp=ENABLED}&quot;</pre><p>Verify the controller was set correctly:</p><pre>aws ecs describe-services \<br>  --cluster your-cluster \<br>  --services payment-service \<br>  --query &#39;services[0].deploymentController&#39;</pre><pre># Expected output:<br>{ &quot;type&quot;: &quot;CODE_DEPLOY&quot; }</pre><h3>Target Groups</h3><p>Two target groups are required — one for Blue, one for Green:</p><ul><li>payment-TG-1 — Blue (production)</li><li>payment-TG-2 — Green (new deployment)</li></ul><h4>ALB Listeners</h4><p>Two HTTPS listeners on the same ALB:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*sGRpAlGBlUs5EPtSDTmuDg.png" /></figure><p>Both listeners use the same SSL certificate. Port 8443 is fully encrypted — the security comes from the HTTPS protocol, not the port number.</p><h4>CodeDeploy Configuration</h4><p><strong>Application type:</strong> Amazon ECS</p><p><strong>Deployment group settings:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*lQhSiKKjmpCOVufMpUhtTw.png" /></figure><p>The 1-hour wait window is the QA testing period. Blue continues serving production traffic throughout. Rollback is available for 1 hour after rerouting.</p><h4>Traffic Header Routing — The Smart Part, Port 443 (Production)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*XyVWLaXv_t9R58LqhAMHqg.png" /></figure><p><strong>Production users always hit Blue. Simple. Port 8443 (Test traffic)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*zmFlcD8kNkY2jDzpyKpGTQ.png" /></figure><p>The weighted forwarding rule (999:1 in favour of Green) is what enables automatic fallback. If Green has no healthy running tasks, AWS ALB automatically removes it from the distribution pool — the single Blue weight becomes the only option and absorbs 100% of test traffic. No manual intervention, no errors.</p><p>This directly satisfies a critical requirement: <em>the load balancer must fall back to Blue if there is no active Green deployment, even when the configured header value exists in the request.</em></p><h3>Build Pipeline</h3><p>The CI/CD pipeline is built on AWS CodePipeline with three stages:</p><pre>Source (Bitbucket) → Build (CodeBuild) → Deploy (ECS Blue/Green via CodeDeploy)</pre><h3>Build Artifacts</h3><p>Three files are required in the build artifact for Blue/Green ECS deployments:</p><p><strong>imageDetail.json</strong> — tells CodePipeline which image to deploy:</p><pre>{&quot;ImageURI&quot;:&quot;123456789.dkr.ecr.eu-west-1.amazonaws.com/payment-service:abc1234&quot;}</pre><p><strong>taskdef.json</strong> — ECS task definition with image placeholder:</p><pre>{<br>  &quot;family&quot;: &quot;payment-service&quot;,<br>  &quot;networkMode&quot;: &quot;awsvpc&quot;,<br>  &quot;requiresCompatibilities&quot;: [&quot;FARGATE&quot;],<br>  &quot;cpu&quot;: &quot;256&quot;,<br>  &quot;memory&quot;: &quot;512&quot;,<br>  &quot;executionRoleArn&quot;: &quot;arn:aws:iam::ACCOUNT_ID:role/ecsTaskExecutionRole&quot;,<br>  &quot;containerDefinitions&quot;: [<br>    {<br>      &quot;name&quot;: &quot;payment-service&quot;,<br>      &quot;image&quot;: &quot;&lt;IMAGE1_URI&gt;&quot;,<br>      &quot;portMappings&quot;: [{ &quot;containerPort&quot;: 8080, &quot;protocol&quot;: &quot;tcp&quot; }]<br>    }<br>  ]<br>}</pre><p><strong>appspec.yaml</strong> — CodeDeploy deployment spec:</p><pre>version: 0.0<br>Resources:<br>  - TargetService:<br>      Type: AWS::ECS::Service<br>      Properties:<br>        TaskDefinition: &lt;TASK_DEFINITION&gt;<br>        LoadBalancerInfo:<br>          ContainerName: &quot;payment-service&quot;<br>          ContainerPort: 8080</pre><p>&lt;IMAGE1_URI&gt; and &lt;TASK_DEFINITION&gt; are literal placeholders — CodePipeline and CodeDeploy replace these automatically at deploy time. Do not fill them in manually.</p><h3>buildspec.yml (post_build section)</h3><pre>post_build:<br>  commands:<br>    - docker push $REPOSITORY_URI:$IMAGE_TAG<br>    - printf &#39;{&quot;ImageURI&quot;:&quot;%s:%s&quot;}&#39; $REPOSITORY_URI $IMAGE_TAG &gt; imageDetail.json</pre><pre>artifacts:<br>  files:<br>    - appspec.yaml<br>    - taskdef.json<br>    - imageDetail.json</pre><p>The key difference from a standard ECS rolling deployment is imageDetail.json (capital D) instead of imagedefinitions.json. Blue/Green deployments require this specific file name and format.</p><h4>Deployment Workflow, For developers</h4><ol><li>Build and merge to master branch</li><li>Reach out to DevOps to initiate the deployment</li><li>DevOps triggers the pipeline — CodeDeploy deploys Green and pauses for 1 hour</li><li>Notify QA that Green is available for testing</li><li>QA carries out testing during the 1-hour window</li><li>On QA sign-off, DevOps clicks <strong>Reroute traffic</strong> in the CodeDeploy console</li></ol><h4>For QA</h4><p><strong>Testing Green (new deployment):</strong></p><pre>GET https://api.payment.ng:8443/<br>Headers:<br>  test-traffic: true</pre><p><strong>Testing Blue (production — baseline comparison):</strong></p><pre>GET https://api.payment.ng/<br>(no header required)</pre><p><strong>What to verify during the 1-hour window:</strong></p><ul><li>All Payment Service API endpoints return expected responses on Green</li><li>Downstream services (Authentication, Transaction, Debit) respond correctly when called from Payment Green</li><li>Error handling and edge cases behave as expected on Green</li><li>Response times and performance are acceptable before approving the traffic shift</li></ul><h4>Manual traffic reroute via CLI</h4><pre>aws codedeploy continue-deployment \<br>  --deployment-id YOUR_DEPLOYMENT_ID \<br>  --deployment-wait-type READY_WAIT</pre><h4>Key Lessons Learned</h4><p><strong>1. The deployment controller is permanent.</strong> It must be set to CODE_DEPLOY at service creation. If you create a service with the default ECS controller, you cannot change it — you must delete and recreate the service entirely.</p><p><strong>2. File naming is case-sensitive.</strong> The image artifact file must be imageDetail.json with a capital D for Blue/Green deployments. Using imagedefinitions.json (which is used in rolling deployments) will cause the pipeline to fail with a confusing error message.</p><p><strong>3. Production and test listeners must be on different ports.</strong> CodeDeploy requires two separate listener ports. You cannot use port 443 for both. Port 8443 over HTTPS is a clean solutio, fully encrypted, just not the default standard port.</p><p><strong>4. The weighted fallback rule is not optional.</strong> Pointing the test header rule directly to Green only means any request with the header fails if Green is not running. The 999:1 weighted rule provides automatic fallback with zero additional configuration.</p><p><strong>5. Header propagation must be intentional.</strong> Every service in the call chain must explicitly forward the test-traffic header in outbound requests. If any service strips headers before calling downstream, the routing breaks silently — this is easy to miss and difficult to debug.</p><h3>Results</h3><p>The setup successfully demonstrated:</p><ul><li>Zero-downtime deployments for Payment Service on ECS Fargate</li><li>Full end-to-end QA testing on production infrastructure before any real user traffic is affected</li><li>Automatic fallback routing when Green is unavailable</li><li>A clear, repeatable deployment process that developers, DevOps, and QA can all follow</li></ul><p>The pilot ran for one week on the Paylater service with no production incidents, and the pattern is now being extended to the full payment platform.</p><h4>What’s Next</h4><ul><li>Extend Blue/Green to Authentication, Transaction, and Debit services — each would then have its own Blue/Green pair with header-based routing at every tier</li><li>Automate the QA sign-off step using smoke tests that trigger the reroute on pass</li><li>Add CloudWatch alarms to auto-rollback if Green shows elevated error rates after reroute</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33f89be4885a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Deployed a Production‑Grade Agency Banking & POS Merchant Platform on AWS ECS]]></title>
            <link>https://tobaoyetola.medium.com/how-we-deployed-a-production-grade-agency-banking-pos-merchant-platform-on-aws-ecs-1406ab7655d9?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/1406ab7655d9</guid>
            <category><![CDATA[aws-ecs-fargate]]></category>
            <category><![CDATA[devops-fintech]]></category>
            <category><![CDATA[agency-banking-solution]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Tue, 14 Apr 2026 07:51:18 GMT</pubDate>
            <atom:updated>2026-04-14T07:51:18.345Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Nine microservices. Zero downtime deployments. Full infrastructure as code. Here’s the complete DevOps story behind taking a fintech platform from a blank AWS account to a live, auto-scaling production system.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N-Xh31EG2eGtIguwMx-vUA.png" /></figure><p>When we were approached to build a full Agency Banking and POS Merchant solution from scratch, the brief was ambitious: a hardware POS application, Android and iOS mobile apps, a merchant web portal, a business management dashboard, and a Terminal Management System all backed by a cloud-native microservices API, deployed and running in production within 22 weeks.</p><p>This article covers the DevOps side of that build: how we architected the infrastructure on AWS, containerised nine payment services, wired up a full CI/CD pipeline, and shipped to production without a single minute of planned downtime. I’m writing this partly as a project post-mortem, partly because I genuinely wish a resource like this had existed when we started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6twvIuTQhjjIHjCuScxn-w.png" /></figure><h3>Why microservices? Why now?</h3><p>The instinct on a time-constrained project is to reach for a monolith fewer moving parts, simpler deployments, less cognitive overhead. We considered it. But the domain made microservices the right call for three specific reasons.</p><p>First, <strong>the data ownership boundaries were crystal clear.</strong> Authentication, wallets, transactions, payments, bill settlements, these are genuinely separate concerns with separate compliance and audit requirements. Forcing them into one database would have been architecturally dishonest.</p><p>Second, <strong>the failure modes needed to be contained.</strong> If the Notification Service goes down, a POS card withdrawal should still complete. If the Bill Payment Service is degraded, wallet balance checks should be unaffected. A monolith makes blast radius containment nearly impossible.</p><p>Third, <strong>teams needed to ship independently.</strong> With separate pipelines per service, the payment team could deploy a hotfix at 11pm without touching the authentication team’s release schedule.</p><h3>The nine services</h3><p>Every backend service is a Spring Boot 3.x application running on Java 17, containerised with Docker, and deployed as an independent ECS Fargate task. Here’s the full map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l9aXkfalQYZkTFCgRSwR9A.png" /></figure><h3>The full system architecture at a glance</h3><p>Before we get into the deployment details, here’s the layered view of the entire system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IgrplHsrIXsQQZkztM80g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oF2dpn_SY1uwEORZgTQnSg.png" /></figure><h3>Choosing AWS ECS Fargate</h3><p>We evaluated three options: ECS Fargate, EKS (Kubernetes), and plain EC2 with Docker Compose. EKS was eliminated early, the operational complexity of managing a Kubernetes control plane is not something a 22-week project with a lean team should absorb. EC2 + Docker Compose would have worked but left us managing OS patching, instance sizing, and manual scaling.</p><p>ECS Fargate hit the right balance. <strong>No servers to manage. No AMIs to maintain. No capacity planning guesswork.</strong> You define a task (container + resource requirements), AWS runs it somewhere. You scale by adjusting numbers, not by SSH-ing into boxes.</p><p>The one genuine downside of Fargate is cold start latency, a new task takes 20–40 seconds to become healthy. For our scaling policy, we set a 120-second cooldown and a minimum of 2 tasks per service, so scaling events never hit user-facing traffic.</p><h3>Dockerising the services — the multi-stage pattern</h3><p>Every service uses the same Dockerfile structure. Multi-stage builds keep production images small (~120MB vs ~500MB for a single-stage build) by compiling with a full JDK and shipping only the JRE runtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zcmiqb26YV-554FXQROs9g.png" /></figure><p>A few security defaults we enforced across all images without exception: <strong>non-root user</strong> (no container runs as root), <strong>no secrets in the image</strong> (credentials are injected at runtime from AWS Secrets Manager), and <strong>Amazon Inspector scanning on every push </strong>critical CVEs block the deployment pipeline automatically.</p><h3>Image tagging strategy</h3><p>We never use the latest tag in production. Every image is tagged with the short Git commit SHA:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cbFAVbD_aAhUBl3ZmbSmXg.png" /></figure><p>This means every running container in production maps to an exact commit in version control. Rollbacks become trivial, you know precisely which SHA to revert to and what changed between them.</p><h3>The CI/CD pipeline — nine services, nine independent pipelines</h3><p>Each service has its own AWS CodePipeline. This was a deliberate choice over a single shared pipeline. Independent pipelines mean:</p><ul><li>A broken Notification Service build doesn’t block a Payment Service hotfix</li><li>Teams see only their own pipeline status without noise from other services</li><li>Pipeline configuration evolves independently per service</li></ul><p>The flow for each service is identical:</p><ol><li><strong>Source</strong> — GitHub push to main triggers the pipeline</li><li><strong>Build</strong> — CodeBuild runs mvn clean package, executes unit tests</li><li><strong>Dockerise</strong> — Docker image built with the commit SHA tag</li><li><strong>Scan</strong> — Amazon Inspector scans the image; critical findings halt the pipeline</li><li><strong>Push</strong> — Image pushed to the service’s private ECR repository</li><li><strong>Deploy to Staging</strong> — ECS task definition updated, rolling deploy to staging cluster</li><li><strong>Smoke Tests</strong> — Postman/Newman collection runs health and critical path checks</li><li><strong>Manual Approval Gate</strong> — Production deployments require explicit approval</li><li><strong>Deploy to Production</strong> — Blue/green via AWS CodeDeploy; traffic shifts 10% → 100% over 5 minutes</li><li><strong>Notify</strong> — SNS sends deploy result to team Slack</li></ol><p>The buildspec.yml that drives steps 2–5 looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5n-rkRdq6VRq1KVrI3fErg.png" /></figure><h3>Blue/green deployments — why it matters in fintech</h3><p>We could not afford even a 30-second outage window during a production deploy. POS terminals process real money. A mid-transaction outage means failed reconciliations, unhappy merchants, and support tickets.</p><p>AWS CodeDeploy’s blue/green strategy for ECS solves this cleanly. New containers (Green) start alongside the existing ones (Blue). Traffic shifts gradually — 10% immediately, then 100% five minutes later if health checks pass. If the 5xx error rate on Green exceeds 1% at any point, CodeDeploy automatically shifts all traffic back to Blue and the deployment is marked as failed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-_nqMQG7Uxl3tHUMgUrWA.png" /></figure><h3>Database design — one database per service</h3><p>The Database-per-Service pattern is non-negotiable in this architecture. No two services share a database not a schema, not a table. This prevents the accidental coupling that kills microservice independence: the moment two services share a database, they’re effectively one service.</p><p>Each service owns a PostgreSQL 15 instance on Amazon RDS. For the transaction-heavy services (Payment, Transaction, Wallet), we provisioned read replicas. For all services, Multi-AZ is enabled if the primary instance fails, RDS promotes the standby automatically, typically within 60 seconds.</p><h3>Schema migrations with Flyway</h3><p>Schema changes are managed by Flyway, embedded in each Spring Boot service. On startup, the service runs any pending migrations before accepting traffic. This means schema changes are always in sync with the application version, no separate DBA migration step, no version skew.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOYWN8WCi4_0eJndQqoq5A.png" /></figure><h3>Redis for the fast-path cases</h3><p>Not everything needs a relational database. We use ElastiCache Redis for four specific patterns:</p><ul><li><strong>JWT blacklisting</strong> — Auth Service writes invalidated tokens with a TTL equal to the token’s remaining expiry. Fast O(1) lookup on every request.</li><li><strong>OTP storage</strong> — 5-minute TTL. Redis auto-expires them. No cron job needed.</li><li><strong>Transaction idempotency keys</strong> — 24-hour TTL. If the same POS terminal resends a payment request (network retry), the duplicate is detected and the original response is returned.</li><li><strong>Rate limiting counters</strong> — Sliding window counters on the API Gateway, incremented in Redis with a 1-minute TTL. Distributed across all gateway tasks without shared state issues.</li></ul><h3>Event-driven architecture with Kafka (Amazon MSK)</h3><p>The Notification Service consumes events from seven different sources — transactions, payments, bill completions, user registrations, KYC approvals. If we’d built this synchronously, a slow SMS gateway response would add latency to every POS transaction. That’s unacceptable.</p><p>Amazon MSK (Managed Streaming for Apache Kafka) provides the event bus. Services that complete a meaningful action publish an event. Downstream services consume at their own pace. The core transaction flow is completely decoupled from notification delivery.</p><p>The topics we use:</p><ul><li>agency.transaction.completed — consumed by Notification, Support, Wallet</li><li>agency.payment.processed — consumed by Notification, Transaction</li><li>agency.bill.paid — consumed by Notification, Support</li><li>agency.user.kyc.approved — consumed by Wallet (triggers auto wallet creation)</li><li>agency.audit.log — consumed by Support (append-only audit trail)</li></ul><p>Replication factor is 3 across the three MSK broker nodes (one per AZ). Minimum in-sync replicas is set to 2, meaning we can lose one broker without any data loss or producer failures.</p><h3>Security — layers, not locks</h3><p>Financial platforms attract targeted attacks. We designed security as a layered system where a breach at any single layer does not compromise the whole. Here’s the stack from edge to database:</p><ol><li><strong>AWS WAF</strong> — OWASP Top 10 ruleset, IP rate limiting (1,000 req/min per IP), geo-restriction</li><li><strong>TLS everywhere</strong> — HTTPS only at the ALB (TLS 1.2 minimum), SSL enforced on all RDS connections, TLS on MSK Kafka brokers</li><li><strong>JWT + RBAC</strong> — Every API request carries a signed JWT validated by the API Gateway before any service sees it. Four roles: AGENT, MERCHANT, BANK_ADMIN, SUPER_ADMIN</li><li><strong>AWS Secrets Manager</strong> — Zero hardcoded credentials. DB passwords, API keys, JWT secrets are all stored in Secrets Manager and injected into containers at runtime. Auto-rotation enabled</li><li><strong>VPC isolation</strong> — All ECS tasks run in private subnets. No container has a public IP. The only inbound path is: internet → ALB (public subnet) → ECS (private subnet)</li><li><strong>Container hardening</strong> — Non-root user in every container. Amazon Inspector CVE scanning blocks deployments with critical vulnerabilities</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*18GHs9sPJGIDKPnXI5KfSQ.png" /></figure><h3>Monitoring — if you can’t measure it, you can’t run it</h3><p>We implemented the three pillars of observability: Metrics, Logs, and Traces.</p><h3>Metrics</h3><p>CloudWatch collects container-level metrics (CPU, memory, network) automatically from ECS. Spring Boot Actuator exposes application metrics (request rates, JVM heap, DB connection pool utilisation) via a CloudWatch Agent sidecar in each task. We built dashboards for: overall system health, per-service error rates, Kafka consumer lag, and transaction throughput broken down by type (POS, USSD, NFC).</p><h3>Structured logging</h3><p>All services log in structured JSON to stdout using Logback with the logstash encoder. Every log entry includes: timestamp, level, service, traceId, spanId, userId, message. ECS ships these to CloudWatch Logs via the awslogs driver. Log retention: 90 days in production.</p><p>The traceId is critical. Every inbound request gets an X-Trace-ID header at the API Gateway, which is propagated through all downstream service calls. When a transaction fails, you can pull every log line across all services involved in that single request by filtering on one ID.</p><h3>Distributed tracing</h3><p>AWS X-Ray is integrated into all services. A trace for a POS card withdrawal spans: API Gateway → Auth validation → Transaction Service → Payment Service → NIBSS switch → response path back. End-to-end latency breakdowns per segment make performance regressions obvious.</p><h3>Infrastructure as Code — the whole thing, every time</h3><p>Every AWS resource in this platform was provisioned with Terraform. No clicking in the console. The repository structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H0JgQkiAkbYloqZd5F1Acg.png" /></figure><p>Terraform state lives in an S3 backend with DynamoDB state locking. Infrastructure PRs trigger Atlantis, which posts the terraform plan output directly into the GitHub pull request. Reviewers approve or reject based on the plan output, no one applies changes from their laptop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pcdn97fk1QBS5K2xqLK-qw.png" /></figure><h3>Go-live and the checklist that saved us once</h3><p>The go-live itself was anticlimactic and that’s how it should be. Everything we tested in staging had been running in a production-identical environment (same VPC layout, same RDS configuration, same Kafka broker count) for weeks. The production deployment was just another pipeline run.</p><p>We ran through a 15-point go-live checklist on the day. The item that mattered most:</p><p><strong>End-to-end transaction test on production hardware.</strong> A real POS terminal. A real debit card. A real NGN transaction. Verified the full path: terminal → API Gateway → Transaction Service → Payment Service → NIBSS → response → Notification Service → SMS delivered. That test passing was the signal to open traffic.</p><h3>What I’d do differently</h3><p>A few things I’d change if I started over:</p><ul><li><strong>Provision MSK earlier.</strong> We underestimated how long MSK takes to provision (20–30 minutes for a fresh cluster). On a tight timeline, that’s a scheduling constraint you want to know about in week 1, not week 8.</li><li><strong>Write smoke tests before the services.</strong> Our Postman collections were written after services were built. Writing them contract-first would have caught several integration issues earlier.</li><li><strong>Set container memory reservations conservatively.</strong> Java’s JVM can surprise you with memory usage at startup. We had two services OOM-killed in staging before we tuned the heap flags and Fargate memory allocation to match.</li><li><strong>Log correlation from day one.</strong> Adding the X-Trace-ID header propagation as an afterthought meant retrofitting it into seven services. It should be in the shared library baseline from the first commit.</li></ul><h3>Wrapping up</h3><p>Building and deploying a production financial platform in 22 weeks is achievable, but not by accident. The architectural decisions that made it possible were made in the first two weeks: ECS Fargate for zero-ops containers, Database-per-Service for data isolation, Kafka for async decoupling, Terraform for reproducible infrastructure, and blue/green pipelines for zero-downtime deploys.</p><p>The fintech domain adds constraints that make you sharper engineers. Real money, real compliance requirements, and real consequences for downtime force you to take observability, security, and rollback procedures seriously from the start, not as afterthoughts.</p><p>If you’re building something similar, I hope this gives you a concrete starting point. Happy to answer questions in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1406ab7655d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hidden Risk in AWS Architectures: Single Availability Zone Dependency]]></title>
            <link>https://tobaoyetola.medium.com/the-hidden-risk-in-aws-architectures-single-availability-zone-dependency-07168ebad186?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/07168ebad186</guid>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Wed, 18 Mar 2026 16:34:32 GMT</pubDate>
            <atom:updated>2026-03-18T16:34:32.364Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zcvxGjOUV70KgQiwHZf4TQ.png" /><figcaption>High Availability Design Patterns in AWS</figcaption></figure><p>A common misconception in cloud adoption is that deploying workloads on Amazon Web Services inherently guarantees high availability and fault tolerance. In practice, architectures constrained to a single Availability Zone (AZ) introduce a critical single point of failure.</p><p>An AWS Region is composed of multiple, physically isolated AZs, each representing independent fault domains with separate power, networking, and cooling infrastructure. These AZs are explicitly designed as <strong>failure isolation boundaries</strong>.</p><p>Despite this, many production workloads are deployed within a single AZ, exposing the system to infrastructure-level failures such as:</p><ul><li>Underlying hardware faults (compute/storage)</li><li>Network partitioning or misconfiguration</li><li>Control plane or service-level disruptions</li></ul><p>In such scenarios, applications lacking AZ redundancy experience full service outages.</p><p>Historical service disruptions affecting Amazon EC2 and Amazon S3 have demonstrated that <strong>single-AZ architectures fail catastrophically</strong>, whereas <strong>multi-AZ architectures maintain service continuity</strong>.</p><h3>High Availability Design Patterns in AWS</h3><p>AWS provides native primitives to architect for resilience across AZs:</p><ul><li><strong>Compute Layer</strong><br>Deploy stateless services across multiple AZs using Auto Scaling Groups (ASGs) with subnet distribution.</li><li><strong>Traffic Distribution</strong><br>Elastic Load Balancing distributes incoming traffic across healthy targets in multiple AZs, ensuring failover at the application entry point.</li><li><strong>Data Layer</strong><br>Amazon RDS Multi-AZ deployments maintain synchronous standby replicas in a separate AZ and perform automatic failover during primary instance failure.</li><li><strong>Storage Layer</strong><br>Services like S3 inherently replicate data across multiple AZs within a Region.</li></ul><h3>Architectural Principle</h3><p>The AWS Well-Architected Framework (Reliability Pillar) explicitly recommends designing systems to:</p><ul><li><strong>Eliminate single points of failure</strong></li><li><strong>Automatically recover from infrastructure failures</strong></li><li><strong>Distribute workloads across multiple AZs</strong></li></ul><h3>Cost vs Risk Trade-off</h3><p>While multi-AZ deployments introduce additional cost (duplicate compute, cross-AZ data transfer, standby resources), they significantly reduce:</p><ul><li>Mean Time to Recovery (MTTR)</li><li>Revenue loss during outages</li><li>Customer trust degradation</li></ul><p>From a reliability engineering perspective, <strong>the cost of redundancy is predictable</strong>, while <strong>the cost of downtime is unbounded</strong>.</p><h3>Reference Architecture (Multi-AZ Resilient Design)</h3><p>You can use this as your <strong>standard production architecture baseline</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zcvxGjOUV70KgQiwHZf4TQ.png" /></figure><h3>1. Entry Layer (Edge)</h3><ul><li>DNS → Route 53 (Health Checks + Failover Routing)</li><li>Optional: CloudFront (CDN + edge caching)</li></ul><h3>2. Load Balancing Layer</h3><ul><li>Application Load Balancer spanning <strong>2+ AZs</strong></li><li>Health checks for target groups</li></ul><h3>3. Compute Layer</h3><ul><li>Auto Scaling Group</li><li>Instances distributed across:</li><li>AZ-A (private subnet)</li><li>AZ-B (private subnet)</li></ul><h3>4. Data Layer</h3><ul><li>RDS (Multi-AZ enabled)</li><li>Primary → AZ-A</li><li>Standby → AZ-B (synchronous replication)</li></ul><h3>5. Caching Layer (Optional but recommended)</h3><ul><li>ElastiCache (Redis cluster mode enabled, multi-AZ)</li></ul><h3>6. Storage Layer</h3><ul><li>S3 (regionally resilient by default)</li></ul><h3>7. Networking</h3><ul><li>VPC spanning multiple AZs</li><li>Public subnets (ALB)</li><li>Private subnets (App + DB)</li><li>NAT Gateway per AZ (to avoid cross-AZ dependency)</li></ul><h3>Failure Scenario (What Happens During AZ Outage)</h3><p>If <strong>AZ-A fails</strong>:</p><ul><li>ALB automatically routes traffic to AZ-B targets</li><li>ASG replaces failed instances in healthy AZ</li><li>RDS fails over to standby in AZ-B</li><li>Application remains available with minimal disruption</li></ul><h3>Key Takeaway (More Technical Framing)</h3><p>High availability in AWS is not implicit — it is <strong>an architectural decision</strong>.</p><p>Resilience emerges from:</p><ul><li>Fault domain isolation (AZ design)</li><li>Redundancy (multi-AZ deployment)</li><li>Automation (failover + scaling)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07168ebad186" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Architecting PCI DSS–Aligned Network Segmentation with Terraform and CI/CD]]></title>
            <link>https://tobaoyetola.medium.com/architect-a-pci-dss-aligned-network-segmentation-pipeline-with-terraform-70d0376aad11?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/70d0376aad11</guid>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Wed, 28 Jan 2026 23:53:28 GMT</pubDate>
            <atom:updated>2026-02-07T17:36:45.105Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>This project uses Terraform, orchestrated through AWS Code-pipeline as CI/CD , to automate the provisioning of multi-region cloud infrastructure for validating network segmentation controls aligned with PCIDSS requirements.</p><p>The setup spans multiple AWS regions (for example, North America and Europe) and includes a <strong>logically isolated Cardholder Data Environment (CDE)</strong>. The purpose is to demonstrate how segmentation can be implemented and validated between <strong>CDE and non-CDE workloads</strong> using network-level controls.</p><p>The design focuses on enforcing isolation through:</p><ul><li>VPC boundaries</li><li>Subnet separation</li><li>Security groups and NACLs</li><li>Explicit routing rules</li></ul><p>All infrastructure is provisioned using <strong>Infrastructure as Code (IaC)</strong> principles to ensure reproducibility, auditability, and consistent enforcement of controls.</p><h3>1. Environments Overview</h3><h4>1.1 Staging Environment</h4><p><strong>Purpose</strong></p><ul><li>Pre-production validation environment</li><li>Mirrors production configuration where feasible</li><li>Server deployed here are Used for network segmentation test to prod and CDE</li></ul><p><strong>Characteristics</strong></p><ul><li>Independent Terraform state</li><li>CI/CD-driven deployments</li><li>Manual approval required before execution</li><li>Lower blast radius than CDE and Production</li></ul><h3>1.2 Cardholder Data Environment (CDE)</h3><p><strong>Purpose</strong></p><ul><li>Hosts PCI DSS–regulated workloads</li><li>Enforces strict network isolation and segmentation</li></ul><p><strong>Characteristics</strong></p><ul><li>Dedicated Terraform state</li><li>Strong isolation from non-CDE environments</li><li>Compliance-driven controls</li><li>Enhanced approval and audit requirements</li></ul><p><strong>Key Principle</strong></p><p><em>Any change to CDE infrastructure is considered </em><strong><em>high risk</em></strong><em> and must follow formal change-management and audit procedures.</em></p><h3>1.3 Production Environment</h3><p><strong>Purpose</strong></p><ul><li>Hosts live, customer-facing workloads</li><li>Business-critical infrastructure</li></ul><p><strong>Characteristics</strong></p><ul><li>Multi-region deployment (Ireland, Oregon)</li><li>Workload-based segmentation (Payment Services, Back-end/Fronted Applications for Lending services)</li><li>Highest level of change control</li></ul><p><em>Production changes directly impact live services and require the highest level of scrutiny.</em></p><h3>2. Repository Structure (Per Environment)</h3><p>Each environment has a dedicated repository with a similar structure:</p><ul><li>backend.tf – Remote state configuration (S3 + DynamoDB)</li><li>providers.tf / provider.tf – AWS provider configuration</li><li>main.tf / regional .tf files – Network segmentation resources</li><li>variables.tf – Input variable definitions</li><li>terraform.tfvars – Environment-specific values (no secrets)</li><li>draw.io.png – Network architecture diagram</li><li>README.md – Environment-specific documentation</li></ul><h3>3. Git Branching &amp; Change Management Strategy</h3><h4>3.1 Branching Model (Mandatory)</h4><p>To prevent accidental or unauthorized infrastructure changes, the following branching strategy <strong>must be strictly followed across all environments</strong>:</p><ul><li>development<strong> branch</strong></li><li>All infrastructure changes must be implemented here first</li><li>Used for development, validation, and review</li><li>master<strong> branch</strong></li><li>Represents deployable infrastructure state</li><li>Changes merged here trigger CI/CD pipelines</li></ul><h4>3.2 Mandatory Pull Request Workflow</h4><blockquote><strong><em>Direct commits to </em></strong><em>master</em><strong><em> are not allowed.</em></strong></blockquote><p>Before any infrastructure change is deployed:</p><ol><li>Make all changes on the development<strong> branch</strong></li><li>Validate Terraform syntax and logic</li><li>Raise a <strong>Pull Request (PR)</strong> from development → master</li><li>PR must be reviewed and approved</li><li>Merge to master triggers deployment via CI/CD</li></ol><p>This process applies to <strong>Staging, CDE, and Production</strong>.</p><h4>3.3 Segmentation Testing Requirement</h4><ul><li>Merging to master triggers <strong>network segmentation deployment and testing</strong></li><li>This ensures:</li><li>Segmentation rules are validated</li><li>Routing and isolation behave as expected</li><li>No unintended network paths are introduced</li></ul><h3>4. CI/CD Deployment Model</h3><p>All environments are deployed exclusively via <strong>AWS CodePipeline + AWS CodeBuild</strong>.</p><h4>4.1 Key Rules</h4><ul><li>No direct terraform apply or terraform destroy locally</li><li>Manual approval is required before Terraform execution</li><li>All actions are auditable</li></ul><h4>4.2 Pipeline Flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eK8zC2ZmzbhHZOYF_5VXJA.png" /><figcaption>IaC CI/CD Flow</figcaption></figure><p>Manual approval acts as a <strong>security and compliance gate</strong> before any infrastructure change is applied.</p><h3>5. Commit Message–Driven Terraform Actions</h3><p>Terraform actions are controlled by explicit commit messages to avoid accidental execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*9Zi614Cx1s9f52t6eJOasw.png" /></figure><h3>6. Manual Approval &amp; Notifications</h3><ul><li>Manual approvals are implemented using <strong>AWS CodePipeline Manual Approval Actions</strong></li><li>Approval notifications are sent via <strong>SNS directly to Slack</strong></li><li>No Lambda functions are used</li></ul><p>Approval notifications include:</p><ul><li>Pipeline name</li><li>Execution ID</li><li>Environment and region context</li><li>Requested Terraform action</li></ul><h3>7. State Management &amp; Safety Controls</h3><p>Across all environments:</p><ul><li>Remote state stored in encrypted S3 buckets</li><li>DynamoDB used for state locking</li><li>Separate state per environment (and per region in production)</li><li>Least-privilege IAM roles</li></ul><p>These controls prevent:</p><ul><li>Concurrent modifications</li><li>Cross-environment impact</li><li>Unauthorized changes</li></ul><h3>8. Compliance, Risk &amp; Audit Readiness</h3><ul><li>CDE and Production environments align with PCI DSS segmentation principles</li><li>All changes are traceable via Git history, PRs, and pipeline executions</li><li>Architecture diagrams must be updated alongside infrastructure changes</li></ul><h3>9. Ownership &amp; Governance</h3><p><strong>Maintained by:</strong></p><ul><li>DevOps / SRE</li><li>Security Engineering</li></ul><p>All changes are governed by internal security, compliance, and change-management policies.</p><h3>Summary</h3><p>This deployment demonstrates a production-grade, compliance-aware Infrastructure-as-Code workflow that:</p><ul><li>Provision Servers for strict network segmentation</li><li>Prevents unauthorized infrastructure changes</li><li>Aligns with PCI DSS scoping and audit expectations</li><li>Provides repeatable, auditable, and secure deployments across environments and regions</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70d0376aad11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimize a Client React App Deployment with S3 + CloudFront with ECS server.js Backend]]></title>
            <link>https://tobaoyetola.medium.com/optimize-a-client-react-app-deployment-with-s3-cloudfront-with-ecs-server-js-backend-461533347c0c?source=rss-7baf6cbfa021------2</link>
            <guid isPermaLink="false">https://medium.com/p/461533347c0c</guid>
            <dc:creator><![CDATA[Toba Oyetola]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 07:20:09 GMT</pubDate>
            <atom:updated>2025-10-29T01:50:00.186Z</atom:updated>
            <content:encoded><![CDATA[<p>How I re-architected and automated our frontend deployment to achieve faster load times, lower costs, and a cleaner CI/CD workflow.</p><h3>The Background</h3><p>I have a client-facing dashboard on a <strong>React-based single-page application</strong> (SPA) that connects directly to a <strong>Node.js (server.js)</strong> backend running on <strong>Amazon ECS (Fargate)</strong>.</p><p>Originally, both the static frontend and backend APIs were served from ECS. While this setup worked, it wasn’t ideal for performance, scalability, or cost.</p><h3>The Problem</h3><p>Serving static React files directly from ECS introduced several issues:</p><ul><li><strong>Slow load times (~2s): </strong>Every request hit ECS since there was no global caching layer.</li><li><strong>Higher costs: </strong>Containers consumed CPU/memory for static files instead of API traffic.</li><li><strong>Inefficient scaling: </strong>ECS had to scale to serve frontend traffic that could’ve been offloaded elsewhere.</li></ul><p>I needed a better architecture one that separated responsibilities, improved global performance, and reduced operational overhead.</p><h3>The Solution</h3><p>I restructured the deployment into a <strong>hybrid architecture</strong> using <strong>Amazon S3</strong> (for static frontend hosting), <strong>Amazon CloudFront</strong> (for global caching and content delivery), and <strong>Amazon ECS</strong> (for backend APIs only).</p><h3>Architecture Overview</h3><p><strong>Frontend (React App)</strong></p><ul><li>Hosted on <strong>Amazon S3</strong> (private bucket)</li><li>Served globally via <strong>Amazon CloudFront</strong></li><li>Routes SPA assets and fallback pages</li></ul><p><strong>Backend (Node.js / server.js)</strong></p><ul><li>Runs in <strong>ECS Fargate</strong></li><li>Handles /api/* and /config endpoints</li><li>Exposed as a <strong>custom origin</strong> behind CloudFront</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gV_kAHMy9HZPHrgveOlEjw.png" /><figcaption><strong>Architecture Overview</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*5y9WKw_JpBx5P08xE018HA.png" /></figure><h4>CloudFront Origin Configuration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*NdAQmtaUvAvI-nt3bvKdyA.png" /><figcaption>CloudFront Origin Configuration</figcaption></figure><h4>Behaviors</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*2Y9nLN6qkQhqnML3nqZBNA.png" /><figcaption>CloudFront Behavior Configuration</figcaption></figure><p><strong>Error Pages</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*QdIaCm24xjTrmikoshkAmw.png" /></figure><h4>Application Flow</h4><ol><li><strong>User visits</strong> <a href="https://corporate.getcarbon.co/">https://frontendapp.prod.co</a>m or staging equivalent.</li><li>CloudFront serves static files (index.html, JS, CSS) from the <strong>S3 origin</strong>.</li><li>Frontend requests to /api/* or /config are routed via CloudFront to the <strong>ECS backend</strong> origin.</li><li>ECS (running server.js) handles dynamic content and API requests.</li><li>Responses flow back through CloudFront → browser.</li></ol><h4>CI/CD Pipeline (AWS CodePipeline)</h4><p>I Implemented a pipeline that automates build and deployment of both the frontend and backend applications in a single streamlined process using AWS CodePipeline and CodeBuild.</p><h4>1. Frontend Deployment (S3 + CloudFront)</h4><ul><li>Installs dependencies and builds the React application (npm run build).</li><li>Uploads the optimized static files to the <strong>S3 bucket:</strong> <a href="https://us-west-2.console.aws.amazon.com/s3/buckets/carbon-business-client-staging.getcarbon.co?region=us-west-2&amp;tab=objects&amp;bucketType=general">staging</a> and dev respectively</li><li>Automatically invalidates CloudFront cache so that users always get the latest version of the app.</li><li>Static website is served globally via CloudFront at <em>frontendapp.prod.com</em> for customers</li></ul><h4>2. Backend Deployment (ECS)</h4><ul><li>Builds a Docker image for the Node.js backend service.</li><li>Scans it for vulnerabilities using <strong>Trivy</strong>.</li><li>Pushes the versioned image to <strong>Amazon ECR</strong>.</li><li>Updates the <strong>ECS service</strong> to use the latest image automatically.</li><li>The API or backend server is continuously deployed to ECS, fully containerized and scalable.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*0tzKjlfgfdsmcRh3gedRww.png" /></figure><h4>CodeBuild Environment Variables</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*6Y6RFiNwXvixj1cc3q6NSA.png" /></figure><h4>Benefits of This Architecture</h4><h4>Performance</h4><ul><li>React static assets cached globally via CloudFront → <strong>load time &lt;10 ms</strong></li><li>API requests optimized via persistent connections to ECS</li><li>ECS server.js “<em>backend-server-js.prod.com</em>” tasks no longer handle static file traffic → potential <strong>25–40% lower ECS utilization </strong>then<strong> </strong>downsized ECS service or handle more API traffic on same footprint</li></ul><h4>Cost Efficiency</h4><ul><li>ECS serves only backend requests, not static files</li></ul><h4>Scalability</h4><ul><li>CloudFront handles global caching &amp; traffic distribution</li><li>ECS autoscaling manages API load independently</li></ul><h4>Security</h4><ul><li>All traffic via HTTPS</li><li>OAI ensures private S3 bucket access</li><li>IAM least-privilege roles applied in CI/CD</li></ul><h4>Developer Experience</h4><ul><li>Unified build pipeline for frontend + backend</li><li>Local development mirrors production (npm run build &amp;&amp; node server.js)</li></ul><h3>🎯 Takeaway</h3><p>Moving static React assets from ECS to <strong>S3 + CloudFront</strong> was a simple but high-impact optimization.<br> It allowed us to:</p><ul><li>Deliver faster user experiences</li><li>Reduce infrastructure cost</li><li>Simplify CI/CD management</li><li>Strengthen security and scalability</li></ul><p>If you’re hosting a frontend + backend combo in ECS today, consider splitting the stack, your performance metrics (and your AWS bill) will thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=461533347c0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>