<?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 Tolulope Orina (trexdevops) on Medium]]></title>
        <description><![CDATA[Stories by Tolulope Orina (trexdevops) on Medium]]></description>
        <link>https://medium.com/@toluorina?source=rss-c30a73ef2bb7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iuDr90QCK0aY8JhAhZc_FA.jpeg</url>
            <title>Stories by Tolulope Orina (trexdevops) on Medium</title>
            <link>https://medium.com/@toluorina?source=rss-c30a73ef2bb7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:27:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@toluorina/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[The model would have paid the invoice]]></title>
            <link>https://toluorina.medium.com/the-model-would-have-paid-the-invoice-6e6aeec92495?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e6aeec92495</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 18:05:31 GMT</pubDate>
            <atom:updated>2026-08-31T18:05:31.704Z</atom:updated>
            <content:encoded><![CDATA[<p>Nine production bugs from building AllTheWay on Google Cloud, none of which a typechecker could see</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UYK_j1LZB4U7NMnzg6ezkg.png" /><figcaption>AllTheWay Landing Page</figcaption></figure><h3>Inspiration</h3><p>I told a planning model to pay an outstanding invoice. A third of the time it wrote a clear, grammatical plan and never marked the step as something that would move money. My confirm gate reads that mark. If the mark is missing, nobody gets asked, and the turn proceeds.</p><p>I measured it. Real prompts for live Gemini: &quot;Pay the outstanding invoice&quot; and &quot;Delete the draft and send the final.&quot; The model labelled the irreversible step in 8 of 12 runs. Switching models did nothing. Two of them were identical on it.</p><p>CI was green. The container was healthy. Tests passed, hundreds of them. The dangerous part was a field a model sometimes declines to fill in.</p><p>I built AllTheWay for the All Things Agentic Hackathon: a companion you talk to, that watches and acts for you, and that learns how you work from your corrections. Nine Cloud Run services, one GCP project, A2A between agents, MCP out to tools. I kept a list of every failure that reached production or nearly did. Nine of them. None of them showed up as a type error, a lint, or a failing suite.</p><p><em>This piece was created for the purposes of entering the All Things Agentic Hackathon.</em></p><h3>Google answered the health check itself</h3><p>Every service had `/healthz`. The smoke test called it and got Google’s own 404 page.</p><p>The first guess is a wrong route. The request never reaches the container. Google’s frontend on `*.run.app` intercepts that exact path and answers it.</p><p>I proved it by absence. The probe’s request appeared in no log. `/api/sessions` from the same probe appeared immediately. A request that leaves no trace never arrived.</p><p>`/healthz/` (trailing slash) passes through.</p><p>Then the second trap. Express maps `/healthz/` onto `/healthz` because strict routing is off, so a Node service is fine. FastAPI answers `/healthz/` with a 307 back to `/healthz`, which is the intercepted path. The workaround that saves Node breaks Python.</p><p>Register both spellings on every service, so the next probe cannot pick the wrong one.</p><h3>A dev dependency stole `ws` and the container exited</h3><p>The gateway image built. Then it died:</p><pre>Error: Cannot find package &#39;ws&#39; imported from /repo/services/gateway/dist/voice/relay.js</pre><p>`ws` was in `dependencies`. The lockfile had it. It installed on my laptop.</p><p>`firebase-tools` is a dev dependency. It wants `ws@7`. npm hoisted that to the root `node_modules/ws`. The gateway needs `ws@8`, an incompatible major, so npm nested the real one at `services/gateway/node_modules/ws`.</p><p>`npm prune — omit=dev` deleted the root `ws@7` as a dev package. The Dockerfile copied `/repo/node_modules` and never copied `/repo/services/gateway/node_modules`.</p><p>Four packages were being dropped. `ws` was just the first import.</p><p>I reproduced it without Docker by rebuilding the module layout in a temp directory. Before the fix: `Cannot find package ‘ws’`. After: `resolved ws`. Same error, verbatim.</p><p>In a workspace monorepo, “which `node_modules` does this image actually contain” is not an obvious question.</p><h3>I rewrote a library and nothing rebuilt</h3><p>I changed a shared screening library, pushed, and no Cloud Build ran.</p><p>The triggers used `included_files = [“services/&lt;name&gt;/**”]`. The library lives in `libs/screening` and is copied into several images. A change there changes the image and fires nothing.</p><p>Terraform had also pointed those services at a real Model Armor template. Production was still running the old code, which raised `NotImplementedError` on that path, against a config that expected the new code. Fail closed turned it into an outage rather than a hole. Nothing announced it.</p><p>Path filters have to include the shared code an image bakes in. Any `libs/**` change now rebuilds every backend service. Rebuilding an image that did not need it costs minutes. Not rebuilding one that did means a service running code nobody shipped.</p><h3>Firebase Hosting cannot carry a WebSocket</h3><p>The browser opened the voice socket at the site’s own origin. Through Firebase Hosting:</p><pre>via Firebase Hosting: ERROR 401, no upgrade<br>direct to Cloud Run:  UPGRADED, relay replied {&quot;error&quot;:&quot;unauthenticated&quot;}, closed 4001</pre><p>The relay was live. Hosting cannot carry a WebSocket upgrade.</p><p>I already knew Hosting applies a 60-second timeout to rewrites that you cannot turn off. I had written a decision record about serving the stream from Cloud Run’s own hostname. The environment variable that switches it on was never set in CI, so the bundle fell back to the Hosting origin and the decision record did nothing.</p><p>A mitigation that nothing enables is a document.</p><h3>What they share</h3><p>Every one of these sits between two systems that each thought they were behaving correctly. Google’s frontend and my health check. npm’s hoisting and my Dockerfile. A path filter and a library copied into an image. `global` and a Live model that does not live there. Firebase Hosting and a WebSocket upgrade. A protobuf and the JSON a client actually GETs. `matchState` and `executionState`. A model’s `action` field and a gate that believed it. `:predictLongRunning` and my idea of a probe.</p><p>An agent calls models, tools, and other agents. The interesting failures are not inside a function I wrote.</p><p>The habit that caught them was dull. Make the call against the real project. Look at what came back. Not the docs (Google’s own Cloud blog gives a model id that 404s, while the dotted variant returns 200). Not a green suite that asserted a URL shape while the model was missing.</p><p>AllTheWay runs on Cloud Run, Vertex AI, Firestore and Firebase. Agents talk A2A. Tools sit behind MCP. Model Armor screens untrusted content. AgentCards are signed on the bytes the endpoint serves.</p><p>This piece was created for the purposes of entering the All Things Agentic Hackathon.</p><p><strong><em>#AllThingsAgenticHackathon</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e6aeec92495" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Skin, a dress, and the diary she already keeps]]></title>
            <link>https://toluorina.medium.com/skin-a-dress-and-the-diary-she-already-keeps-b87e7dc9f11f?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b87e7dc9f11f</guid>
            <category><![CDATA[youcam]]></category>
            <category><![CDATA[virtual-try-on-technology]]></category>
            <category><![CDATA[beauty]]></category>
            <category><![CDATA[fashion]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 15:22:40 GMT</pubDate>
            <atom:updated>2026-08-17T15:22:40.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7X4rjzV2BIbmqCMbfii6w.png" /><figcaption><em>GirlCode360 · YouCam API Skin AI &amp; Apparel VTO · August 2026</em></figcaption></figure><p>GirlCode360 is a signed-in wellness app. Five tabs on a phone: Home, Cycle, Mirror, Alena, Account. She logs periods, how she feels in the days before a bleed, pregnancy or trying-to-conceive if that is her season, and a Health Wallet she controls. Mirror is the beauty studio inside that same account. It is where Perfect Corp’s YouCam work lives.</p><p>I did not want a skin mini-app glued to a fashion mini-app. Beauty and fashion decisions rarely happen in isolation. How her skin looks this week and what she is willing to put on her body are part of the same self-image. They also sit next to a hormonal week; she has often already described it in a diary, in another product, that has never seen her face.</p><p>Mirror is the bet that those things can share a room.</p><h3>What she actually does</h3><p>After she agrees to Mirror photos (that consent is separate from creating an account), she can take a face still and see skin scores as bars. If she has been logging a cycle, the scan remembers the day and phase at capture. We put that next to the scores as context. We do not turn a texture bar into a diagnosis. We do not tell her the number “is” PMOS. Wellness copy is slower than a scary headline. It is the copy that belongs here.</p><p>She can switch, in the same studio, to apparel. That path wants a full-body still and a garment from tagged boutique stock, not a selfie stretched over a gown. She gets a try-on image back. Catalogue rows can carry maternity week and PMOS-fit tags. If she has not given us that context, the filters go empty on purpose. Nearby shopping, when we show it, is independent stock and local boutiques, not a single high-street shelf pretending to be the whole market.</p><p>Makeup, hair, wardrobe (clothes she owns), and accessories sit in the same Mirror workspace so the studio feels like a place, not a list of API demos. The center of the hackathon brief is still the pair: skin analysis and apparel try-on, used as one experience.</p><p>A timeline pulls real studio history from those rooms. Seeded demo scans are labeled &quot;Sample.&quot; We did not invent six months of progress arrows that the product cannot stand behind.</p><p>If YouCam is not taking new work, capture turns off. The cycle still loads. The wallet still loads. Declining Mirror does not turn off period tracking. Beauty is optional. The diary is not.</p><h3>Why this is one product, not two features</h3><p>A lot of skin tools give you a snapshot: here is your face today. A lot of virtual try-on tools give you a look: here is this dress on a body. The person using both is still one person. She already knows, in her own language, that a week of bloating and a week of clear skin can be the same month. She already knows a dress that worked in week eight of pregnancy may not be the one she wants in week thirty.</p><p>GirlCode360 already had the diary side of that. YouCam gave us a measured face and a generated outfit. The product work was refusing to keep those in separate tabs of a pitch deck.</p><p>That shows up in small, stubborn ways. Faces still stay on skin (and on makeup and hair, where a face is the right input). Apparel use stays off unless the tray still is full body. A garment photographed on a table is a wardrobe piece, not a body. One shared “Use” button on the wrong photo looks like the technology failed. It is usually the product being greedy with a single tray.</p><p>It also shows up in what we will not plot. A front still can speak to hair length. Density wants another pose. We label length as length. Jewelry without a product still does not get a made-up 3D try-on. Eyewear is only in our key catalog, so frames do not pretend to sit on her face. Empty states tell the truth.</p><p>Retail value, for us, is not “scan then buy our SKU.” It is: she can see a local piece on her body in an account that already knows whether she asked for maternity-aware browsing, and she can keep that history without pasting screenshots between apps.</p><h3>How YouCam is wired (without turning the app into a playground)</h3><p>Stills never call YouCam with a key in the browser. The PWA posts to our API. Our backend is the only thing that talks to Perfect Corp. Copy results into our storage. She sees our URLs, not a session she cannot keep.</p><p>Skin analysis and apparel try-on are jobs with pictures. Sometimes the job is finished when she asks. Often it is not. The screen is written for that. Her photo stays on stage. We ask for our own status until we have a result or a reason she can act on it: try another angle or try later. “Keep this screen open” is not elegant. People will wait if they can see what they are waiting on.</p><p>We try to keep two kinds of “no” apart. A face turned too far, or a crop that is not a body, is something she can fix. A busy service is not. If you mix those, she hunts for a better selfie while the real issue is that Try-on is not accepting work, or she assumes Mirror is flaky when she only needed to square up to the camera.</p><p>Photos in the tray can live on the device. They are not fed to Alena. Alena only sees what she has allowed. After we finish a YouCam file, we delete it on their side. UK-style privacy thinking treats these images as sensitive. That is why consent is a ledger, a live camera is a second grant, and wellness language stays wellness language.</p><p>None of this is a hello-world from the API Playground pasted into a landing page. It is the same Cognito account as cycle logs, with pending states, labelled samples, and fail-closed capture so a beauty outage does not take the rest of her record with it.</p><h3>How the YouCam API is actually called</h3><p>This is the same path in production. The phone never speaks Perfect Corp’s language. It speaks ours.</p><p>She is signed in with Cognito. A still leaves the PWA as `POST` to our API Gateway routes under Mirror (skin scan create, apparel try-on create, and the studio routes that share the same client). Lambda reads `youcam_api_key` from our packed app secret. Every upstream call is `Authorization: Bearer` against YouCam’s S2S host. The browser never sees that header.</p><p>Upload is the documented two-step. We `POST /s2s/v2.0/file/{capability}` with content type, file name, and size, get back a `file_id` and a short-lived `upload_url`, then `PUT` the bytes to that URL. We wait a little over a second before starting the task so the object is actually there. Skin uses capability `skin-analysis`. Apparel uses `cloth-v3`. Wardrobe try-on reuses `cloth-v3` with the garment as `ref_file_id` instead of a boutique SKU URL.</p><p>A skin job is `POST /s2s/v2.0/task/skin-analysis` with `src_file_id`, `format: json`, mask overlays on, and the official SD concern list: wrinkle, pore, texture, acne, oiliness, redness, radiance, dark_circle_v2, eye_bag, droopy upper and lower eyelid, age_spot, tear_trough, firmness, moisture, skin_type. We do not mix SD and HD in one call. Scores come back 0 to 100, plus skin type, masks, and an overall figure we either take from the payload or average from the numeric concerns. Cycle day and phase are written on <em>*our*</em> scan row at capture. YouCam never receives the diary.</p><p>An apparel job is `POST /s2s/v2.0/task/cloth-v3` with the full-body `src_file_id`, a `garment_category`, and either `ref_file_id` or `ref_file_url` for the garment. Optional prompt text is for fit language (maternity or comfort), not a secret we show in the UI. Swimwear and lingerie stay out of the catalogue because that is a training exclusion, not a style choice we overrode.</p><p>Create does not sit in Lambda spinning until the picture is done. API Gateway will cut a request at about 29 seconds. YouCam is often still `running`. So create stores our row as pending, returns that to the client, and she keeps looking at her photo. Each later `GET` on our scan or try-on resource does one `GET /s2s/v2.0/task/{capability}/{task_id}`. When `task_status` is success, we download the result URL (those links last about two hours), copy bytes into our S3 under KMS, and from then on the app serves our URLs. Webhooks (`POST /v1/webhooks/youcam`, HMAC-checked) can shorten the wait when they arrive. Polling our own resource is still the path we cannot skip. The PWA never polls YouCam directly. That would leak the key and burn a shared 250-request / 300-second budget from her phone.</p><p>Client mistakes (bad face angle, a photo the model rejects) stay client mistakes. They do not open the outage circuit. Five real upstream failures in a row do, for a minute, and capture turns off. Cycle and Alena do not care. We also pace ourselves in-process (headroom under that 250/300 window) so a burst of studio taps does not 429 the token for everyone on the same Lambda.</p><p>When we have our copy, we `DELETE` the YouCam `file_id`. Best effort, never a reason to fail her scan. Makeup VTO, look transfer, shade finder, hair length, hair colour try-on, nails, and jewellery 2D VTO go through the same `submitTask` / `pollTask` / copy helpers. Eyewear try-on is not on this key, so the UI stays catalogue-only instead of calling an endpoint that would 400.</p><p>That is the integration: one gateway, two required capabilities used for real, the rest of Mirror on the same pattern, and a consumer app that only ever stores what we can keep.</p><h3>Who this is for</h3><p>Women who already live in cycle, fertility, or pregnancy software and who still open a second app to ask about their face or a third to see a dress. UK, Nigeria, and Ghana are where we are starting. The English is shared. Currency follows the market.</p><p>The problem is specific. Isolated selfie scores do not know last week’s bleed. Isolated try-on does not know she is shopping for a changing body. Retail mirrors usually lock you to one brand’s catalogue. GirlCode360 is the connected picture: measured skin, generated outfit, diary she typed herself, and local stock if she wants to shop.</p><p>Judges and readers who want to poke the implementation will find a Vite PWA, Lambda talking to YouCam server-to-server; scans that store cycle day at capture; boutique SKUs kept apart from owned wardrobe rows; and a Mirror that still looks like one studio on a phone.</p><p>I think the interesting use of Skin AI and Apparel VTO is not that both APIs exist but that they can be integrated. It is that they can sit in a life that already has a story and still look like the same self.</p><p>#YouCam #Beauty #Fashion #FashionTech</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b87e7dc9f11f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wiring Vercel to AWS: A Practical Guide to Next.js + Serverless Backends]]></title>
            <link>https://toluorina.medium.com/wiring-vercel-to-aws-a-practical-guide-to-next-js-serverless-backends-6197bdb4f757?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6197bdb4f757</guid>
            <category><![CDATA[vercel-deployment]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[vercel]]></category>
            <category><![CDATA[vercel-ai-sdk]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Sun, 28 Jun 2026 22:33:54 GMT</pubDate>
            <atom:updated>2026-06-28T23:08:01.549Z</atom:updated>
            <content:encoded><![CDATA[<p><em>You picked Vercel for the frontend and AWS for the backend. Good combo. The hard part is making them talk to each other without drift, CORS surprises, or auth gaps.</em></p><h3>Why split the stack at all</h3><p>A lot of teams land here by accident. Next.js on Vercel is fast to ship: preview deploys, edge-friendly static assets, streaming API routes. AWS is where you put Cognito, Lambda, API Gateway, Aurora, S3, and Bedrock when you need IAM, regional data residency, or a proper secrets story.</p><p>Neither platform replaces the other. Vercel is not your database host. AWS is not your ideal Next.js deploy target unless you enjoy configuring CloudFront and build pipelines by hand.</p><p>The real work is the glue: env vars, CORS, JWT flow, and keeping two deploy pipelines pointed at the same reality.</p><h3>The big picture</h3><p>A typical setup looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bn3qnaZplb_DeQvMtDQhjw.png" /><figcaption>Vercel &amp; AWS: High-Level Design</figcaption></figure><p>Three traffic paths usually show up:</p><ol><li>Auth — browser ↔ Cognito directly. Vercel does not sit in the middle for login.</li><li>Business API — browser ↔ API Gateway with Cognito access tokens in the Authorization header.</li><li>AI (optional) — browser ↔ Vercel API route ↔ AI Gateway ↔ Bedrock, sometimes with tool calls back into API Gateway.</li></ol><p><em>Heavy inference that does not need streaming can skip Vercel entirely: browser → API Gateway → Lambda → Bedrock.</em></p><h3>The contract: environment variables</h3><p>Terraform outputs (or CDK/CloudFormation exports) and Vercel env vars are the handshake. After you deploy AWS, you copy outputs into the Vercel project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvz581d29-EAQx1D2uBGYQ.png" /><figcaption>Vercel: Typical AWS Environment Variables</figcaption></figure><p>On the AWS side, set your Vercel production URL as an allowed CORS origin on API Gateway and S3. Lambda env vars like FRONTEND_BASE_URL drive OAuth redirect targets and payment return URLs.</p><p>When either side drifts, failures are predictable:</p><ul><li>Wrong frontend URL → CORS errors in the browser console</li><li>Mismatched Cognito client ID → 401 from API Gateway</li><li>Stale NEXT_PUBLIC_API_URL → 403 or connection refused after infra recreation.</li></ul><h3>Step 1: Deploy AWS first</h3><p>Provision the backend before wiring Vercel. A minimal serverless stack:</p><ul><li>Cognito user pool + app client</li><li>API Gateway HTTP API with JWT authorizer (issuer = Cognito, audience = client ID)</li><li>Lambda functions behind route keys (GET /me, POST /items, etc.)</li><li>Database (Aurora, Aurora DSQL, DynamoDB, whatever fits)</li><li>S3 for file uploads (presigned URLs from Lambda)</li><li>Secrets Manager / SSM for API keys and per-user OAuth tokens</li></ul><p>Export the values Vercel needs:</p><pre>terraform output api_url<br>terraform output cognito_user_pool_id<br>terraform output cognito_client_id</pre><p>Set <em>frontend_base_url</em> to your Vercel domain and <em>api_base_url</em> to the Gateway URL before applying. Third-party OAuth callbacks (payments, banking, and social login) should hit the API Gateway or a dedicated Lambda and then redirect back to your Vercel app.</p><h3><strong>Step 2: Wire Vercel to those outputs</strong></h3><p>In Vercel → Settings → Environment Variables, paste the AWS values for Production. Add preview env vars too if you run staging deploys against a non-prod API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tMaHnZHaHki1UyXcYY7iSg.png" /></figure><p>NEXT_PUBLIC_* vars are baked in at build time. A small config helper keeps the base URL clean:</p><pre>export function getApiConfig() {<br>  const baseUrl = process.env.NEXT_PUBLIC_API_URL?.replace(/\/$/, &quot;&quot;)<br>  if (!baseUrl) return null<br>  return { baseUrl }<br>}</pre><p>Your API client attaches <em>Authorization: Bearer &lt;accessToken&gt;</em> and retries once after a token refresh on 401.</p><p>Redeploy Vercel after every backend apply that changes the API URL. Env var updates alone are not enough until a new build runs.</p><h3>Step 3: Authentication across both sides</h3><p>A pattern that works well: Cognito auth stays in the browser, API Gateway validates JWTs, and Vercel adds an HttpOnly cookie for route protection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qiD54dYa597gnuLIsL3s3A.png" /><figcaption>Authentication Pathway</figcaption></figure><p>Browser → Cognito: call <em>InitiateAuth</em> directly from the client. Store tokens in <em>localStorage</em> or <em>sessionStorage</em>.</p><p>Browser → Vercel: after login, POST the access token to <em>/api/auth/session.</em> Vercel verifies it against Cognito’s JWKS endpoint and sets an HttpOnly cookie.</p><p>Middleware: guard <em>/app/*</em> or <em>/dashboard/*</em> by checking that cookie. No cookie → redirect to<em> /signin</em>.</p><p>Browser → API Gateway: Every data call still sends <em>Authorization: Bearer &lt;accessToken&gt;</em>. API Gateway’s JWT authorizer is the real security boundary.</p><p>Yes, you validate twice. The Vercel check keeps unauthenticated users out of protected pages. The AWS check protects your data even if someone calls the API directly.</p><h3>Step 4: REST calls from browser to Lambda</h3><p>Most app logic is plain HTTPS from the Next.js client to API Gateway. Vercel renders UI; AWS does work.</p><pre>| Pattern | Vercel | AWS |<br>|---------|--------|-----|<br>| CRUD | List/detail forms | `GET/POST/PATCH /resources` → DB |<br>| File upload | Upload UI | Lambda returns presigned S3 URL; browser uploads direct to S3 |<br>| OAuth connect | Redirect handler page | `POST /oauth/connect` → provider → callback Lambda → token storage |<br>| Webhooks | (none) | Provider → API Gateway → Lambda (Stripe, etc.) |</pre><p>CORS on API Gateway must include your Vercel domain. S3 bucket CORS too if the browser uploads files directly.</p><p>Vercel does not proxy your API by default. The browser calls AWS directly. That keeps Lambda cold starts and payload limits off your Next.js server, but it means CORS and JWT must be correct on the Gateway side.</p><h3>Step 5: AI across both platforms</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvz581d29-EAQx1D2uBGYQ.png" /><figcaption>Typical Environment Variables in Vercel</figcaption></figure><p>If you add AI, you often end up with two paths:</p><h3>A. Streaming assistant (Vercel)</h3><ul><li>Route: app/api/assistant/route.ts</li><li>Model: via <a href="https://vercel.com/docs/ai-gateway">Vercel AI Gateway</a> (e.g., amazon/nova-2-lite)</li><li>Key: AI_GATEWAY_API_KEY on Vercel only. Never prefix with NEXT_PUBLIC_.</li><li>Auth: verify Cognito access token server-side before streaming</li><li>Tools: assistant calls API Gateway with the user’s bearer token to fetch live data</li></ul><p>The model streams from Vercel. The facts come from your database via Lambda.</p><h3>B. Batch / inline inference (AWS)</h3><ul><li>Route: POST /items/{id}/classify on API Gateway</li><li>Model: Bedrock inside Lambda with IAM permissions</li><li>Toggle: env flag on Lambda and matching NEXT_PUBLIC_* flag on Vercel for UI visibility</li></ul><p>No Gateway key on Lambda. Bedrock access stays inside AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gg_NTE_J_vfqy-vAqk7y6A.png" /><figcaption>AI pathways: in and out of Vercel</figcaption></figure><p>Gateway is good for keys and streaming on Vercel. Direct Bedrock from Lambda is good for anything that should never leave your AWS account boundary.</p><h3>Step 6: Two deploy pipelines</h3><pre>| Layer | Trigger | Target |<br>|-------|---------|--------|<br>| Frontend | Push to `main` | Vercel auto-deploy |<br>| Backend | Push to `infra/**` or manual | CodePipeline / GitHub Actions → Terraform apply |</pre><p>They rarely share one pipeline. A Lambda fix and a UI fix can ship independently. The tradeoff: When Terraform outputs change, someone has to update Vercel env vars and trigger a redeploy.</p><p>Frontend analytics (Vercel Analytics, etc.) and backend logs (CloudWatch) live in different places. Plan for that.</p><h3>Post-deploy checklist</h3><ol><li><em>terraform output </em>— copy <em>api_url</em>, Cognito IDs if anything rotated.</li><li>Vercel → Environment Variables → update → Redeploy.</li><li>Smoke test: sign in → hit a protected API route in the network tab → exercise one write path (create, upload, or connect).</li><li>OAuth broken? Check <em>frontend_base_url </em>/ CORS origins match your live Vercel domain.</li></ol><h3>Common mistakes</h3><p>CORS after a domain change. You add a custom domain on Vercel but forget to update API Gateway allowed origins. Browser shows generic network errors.</p><p>Stale <em>NEXT_PUBLIC_API_URL</em>. API Gateway URLs can change on stack recreate. Old URL in Vercel until every route 403s.</p><p>AI flags out of sync. Server has <em>AI_FEATURES_ENABLED=true</em> but client has <em>NEXT_PUBLIC_AI_FEATURES_ENABLED=false</em>. Code works; UI hides the feature.</p><p>Weak session secret in production. Dev middleware might accept a placeholder cookie. Production needs a real <em>AUTH_SESSION_SECRET</em>.</p><p>Putting secrets in <em>NEXT_PUBLIC_ </em>vars. Anything prefixed <em>NEXT_PUBLIC_</em> ships to the browser bundle. API keys, webhook secrets, and DB URLs stay server-side or in AWS.</p><h3>Further reading</h3><ul><li><a href="https://vercel.com/docs/ai-gateway">Vercel AI Gateway docs</a></li><li><a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html">API Gateway HTTP API JWT authorizers</a></li><li><a href="https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html">Cognito InitiateAuth API</a></li><li><a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/secure-string-parameter-kms-encryption.html">SSM SecureString parameters</a></li></ul><p>This blog was published during the H0: Hack the Zero Stack with Vercel v0 and AWS Databases hackathon</p><p><em>#H0Hackathon</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6197bdb4f757" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I built a tax app that lets AI sort your taxes but not file them]]></title>
            <link>https://toluorina.medium.com/i-built-a-tax-app-that-lets-ai-sort-your-taxes-but-not-file-them-82cde767ebd1?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/82cde767ebd1</guid>
            <category><![CDATA[vercel-deployment]]></category>
            <category><![CDATA[uk-tax-system]]></category>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[vercel-ai-sdk]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Sun, 28 Jun 2026 00:45:47 GMT</pubDate>
            <atom:updated>2026-06-28T23:08:52.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ffON1utqghSQozciavhvA.png" /><figcaption>PactTax in a nutshell</figcaption></figure><p>I spent the last few weeks building PactTax, a tax-filing app for UK sole traders and landlords. It uses AI. It also refuses to let the AI make a single decision that touches your HMRC submission. Those two facts are the whole point of this post, and getting them to coexist was harder than I expected.</p><p>Some quick context. From April 2026, the UK rolled out Making Tax Digital for income tax. If you are self-employed or you rent out property above a certain income threshold, you can no longer just file once a year. You have to keep digital records and send HMRC a quarterly update through approved software. Hundreds of thousands of people are in scope right now, and a lot of them have never used anything more sophisticated than a spreadsheet and a shoebox of receipts.</p><p>The existing software does not help. Xero, QuickBooks, and Sage. They are all built for businesses with staff and accountants. A plumber who wants to tell HMRC what came in and what went out does not need a balance sheet. He needs about ten minutes a quarter and a tool that does not make him feel stupid.</p><p>So I built one. I also entered it into the <a href="https://h01.devpost.com/">H0: Hack the Zero Stack</a> hackathon, which is where the architecture got interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*debfIfp_bbKkwDCejM4IMw.png" /><figcaption>Amazon Aurora DSQL provisioned via Vercel Storage Integration</figcaption></figure><h3>The boring part is the part AI is good at</h3><p>Here is the actual workflow. You connect your bank through open banking. Transactions sync in. You go through an inbox and mark each one as personal or business, and if it is business, you pick an HMRC category. Then you file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*jFKH7HueyhdRmo7Zq7DlQg.gif" /><figcaption>Connecting to HMRC</figcaption></figure><p>The classifying is the boring part. Nobody enjoys staring at “AMZN MKTP UK*Z8 4QR” trying to remember whether that was printer paper or a birthday present. This is exactly the kind of fuzzy pattern-matching a language model is good at. “Shell” is probably fuel. “Screwfix” is probably materials. A model can guess that in milliseconds.</p><p>So the temptation is obvious: let the AI read the transactions and classify them automatically. Sync your bank, come back later, everything is sorted.</p><p>I did not build that. I want to explain why, because it is the most important decision in the whole app.</p><h3>Why the AI never gets the final word</h3><p>If the model gets a category wrong and the app silently files it, the user has now sent HMRC incorrect figures without ever seeing them. That is not a UX bug. That is the kind of thing that gets people fined. And the person on the hook is the taxpayer, not me, and definitely not the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_1v2HMWDytvU8Kxasg90Q.jpeg" /><figcaption>PactTax Swipe to classify</figcaption></figure><p>So PactTax does suggestions only. The flow is layered, and it runs in a strict order.</p><p>First, deterministic rules. If you have a saved rule for a merchant, or the merchant name matches a known regex pattern, that wins. It is free, it is instant, and it is auditable. No model involved.</p><p>Second, and only if the rules find nothing, the AI. Amazon Nova 2 Lite reads a deliberately tiny slice of the transaction (merchant, description, amount, direction, your income type) and returns structured JSON: personal or business, a category, a confidence score from 0 to 1, and a short human-readable reason like “Looks like fuel for a work vehicle.”</p><p>Third, and this is the bit I refuse to remove, a human. The suggestion shows up as a strip in the inbox with a tick and a cross. You accept it or you reject it. Nothing gets written to your quarter until you tap the tick.</p><p>I put a confidence gate in too. If the model is below 0.75, it does not get to claim a category. It falls back to “uncertain” and you classify it yourself. I would rather show you nothing than show you a confident-looking wrong answer.</p><p>The server also validates every category the model returns against the categories that are actually legal for your income type. If Nova hallucinates a property-expense category for a sole trader, the server throws it out before it ever reaches the screen. The model is a guesser. The server is the bouncer.</p><h3>Step by step: how a transaction gets classified</h3><p>This is the path one bank line follows from sync to your quarterly totals.</p><ol><li>TrueLayer sync pulls the transaction into Aurora DSQL. It lands as unclassified in your inbox.</li><li>You open the inbox. The frontend may call POST /transactions/suggest/batch for the next few items in the queue.</li><li>Rules run first. Saved merchant rules and regex patterns are checked in Lambda. If “Shell” already maps to car and travel for you, the strip shows “Matched from your saved merchant rule,&quot; and Bedrock is never called.</li><li>If rules miss, Bedrock runs. Lambda sends merchant, description, amount, direction, and income type to eu.amazon.nova-2-lite-v1:0 in London. The response is parsed as JSON and validated server-side.</li><li>The suggestion strip appears. You see personal/business, a category if confidence is high enough, and a one-line reason. Tick to accept, cross to dismiss.</li><li>You tap the tick. The app sends PATCH /transactions/{id} with your choice. The audit log records whether you followed the AI, a rule, or classified manually.</li><li>Quarter totals update. Classified business income and expenses roll into the tax estimate and filing summary. Personal items stay out.</li></ol><p><strong><em>Nothing in steps 3 through 6 happens without you in the loop at step 5.</em></strong></p><h3><strong>The Solution architecture</strong></h3><p>PactTax is a Zero Stack layout: Next.js on Vercel for the frontend, AWS in eu-west-2 for everything that touches money and tax data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZehOGEeQsPfC27tgDzT-zg.png" /><figcaption>PactTax Architecture Design Diagram</figcaption></figure><p>A few things worth calling out:</p><ul><li>Auth is direct to Cognito from the browser. API Gateway validates the JWT on every protected route.</li><li>~30 Lambda functions handle users, banks, transactions, filing, billing, and AI suggestions. No monolith server.</li><li>Aurora DSQL is the single source of truth. Users, entities, transactions, submissions, AI usage counters, and audit rows all live there.</li><li>EventBridge triggers a daily bank sync so new transactions appear without a manual refresh.</li><li>Push to the main under infra-backend/** runs pytest, Terraform plan/apply, and SQL migrations through CodePipeline. The frontend auto-deploys on Vercel.</li></ul><h3>Step by step: the AI split</h3><p>PactTax has two AI features. They share Nova 2 Lite but run in different places on purpose.</p><h3>Help assistant (Vercel)</h3><ol><li>You tap the AI chat in the dashboard.</li><li>The browser sends chat messages to POST /api/assistant with your Cognito JWT.</li><li>Next.js verifies the token and streams a reply through the Vercel AI SDK and AI Gateway.</li><li>The system prompt scopes answers to product and MTD workflow only. No transaction data is ever in the prompt.</li><li>Daily usage is counted in DSQL via GET/POST /users/me/ai/usage (default limit: 50 messages/day).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*2naaRC1ulncuD4FblUKVdQ.png" /><figcaption>PactTax AI ChatBot</figcaption></figure><h3>Classification suggest (Lambda + Bedrock)</h3><ol><li>The inbox requests a suggestion for one transaction or a batch of up to 20.</li><li>Lambda checks merchant rules and regex. Match found? Return immediately; skip Bedrock.</li><li>No match? Call Bedrock with a minimal prompt. Parse JSON. Validate category against your income type.</li><li>Confidence below 0.75? Downgrade to “uncertain” with no category.</li><li>Persist the suggestion in the ai_suggestion JSONB column. Show the strip. Wait for you.</li><li>Daily classify quota defaults to 100 suggestions per user. You can turn inbox AI off in Settings.</li></ol><p><strong><em>Same model family. Two trust boundaries. Chat can sit on the edge. Classification stays next to the database.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*Nsjustkqk2gmJKP-gzm_1g.png" /><figcaption>AI in transactions classification</figcaption></figure><h3>Why Aurora DSQL</h3><p>The hackathon required one of three AWS databases. I picked Aurora DSQL, and not because it was the shiny new option.</p><p>My data is relational and it is not going to stop being relational. Users own entities. Entities own transactions. Transactions roll up into quarterly submissions. Submissions need an immutable audit history. That is a join-heavy, constraint-heavy world, and I wanted real PostgreSQL semantics for it rather than bending it into a key-value shape.</p><p>What DSQL gave me on top of that was managed, distributed SQL in the London region without me running a database server. For a solo build with a tax-compliance angle, UK data residency and not patching Postgres at 2am both mattered. I am storing maybe 500 transactions per user per year. The volume is small. The correctness requirements are not.</p><p>I will be honest about the rough edges. There is no ORM in the backend, so it is raw SQL all the way down, which I actually came to like. And enabling the Bedrock model in eu-west-2 is a console click that Terraform cannot do for you, which cost me an embarrassing half hour of &quot;Why is this returning access denied?&quot;</p><h3>Step by step: first filing (user view)</h3><p>If you want to try the full loop yourself:</p><p>Prerequisites:</p><p>Sandbox Credentials to be used today</p><ol><li>For HMRC, create a test user yourself (check google for this, and enter the details given)</li><li>For TrueLayer connection, use: Username: john, password: doe</li></ol><p><strong>Steps</strong></p><ol><li>Sign up at <a href="https://pacttax.vercel.app/">pacttax.vercel.app</a>.</li><li>Complete onboarding: income type, tax details (encrypted with KMS), HMRC OAuth, and TrueLayer bank connect.</li><li>Sync transactions from Settings → Banks.</li><li>Work through the inbox. Swipe or tap. Accept AI suggestions where they show up, or classify manually.</li><li>Check the dashboard for quarter progress and a running tax estimate.</li><li>Open Filing → validate the quarter → confirm → submit to HMRC sandbox (subscription required at submission).</li></ol><p>Sandbox only. No real filing yet. But the plumbing is production-shaped.</p><h3>What it actually looks like running</h3><p>The full loop is live. Stripe handles billing before HMRC submit. SES sends submission confirmations and deadline reminders. Receipt photos go to S3 through presigned URLs.</p><p>On the AI side, every suggestion is rate limited per user per day, the counters live in DSQL, and you can turn inbox suggestions off entirely in settings if you would rather just swipe. The audit log records whether your final classification matched what the AI suggested, which is the kind of thing that will matter a lot if this ever goes through HMRC’s production recognition process.</p><h3>What I would tell someone starting this</h3><p>Let the model do the guessing and let the human do the deciding. That split sounds like a compromise. For anything touching money or compliance, it is the actual feature. People do not trust magic. They trust a suggestion they got to approve.</p><p>And pick your database because of how your data is shaped, not because of which one sounds most impressive in a demo. I could have forced this into DynamoDB and talked about scale. It would have been the wrong answer for a pile of relational tax records, and a good engineer would have seen through it in about ten seconds.</p><h3>Try it and get in touch</h3><p>PactTax is at <a href="https://pacttax.vercel.app/">pacttax.vercel.app</a>.</p><p>If you are building something similar, hit a bug, or want to talk MTD for sole traders, use the contact form at <a href="https://pacttax.vercel.app/contact">pacttax.vercel.app/contact</a>. Name, email, and message, and we reply by email. You can also write to pacttax@conquerorfoundation.com directly.</p><p>Next on my list is opening it up to more accounting workflows for businesses and individuals who eventually outgrow swipe-to-classify, plus going for real HMRC production filing.</p><p>This blog was published during the H0: Hack the Zero Stack with Vercel v0 and AWS Databases hackathon</p><p><em>#H0Hackathon #AI #AWS #Vercel #V0</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82cde767ebd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agentic AI: Foundations of autonomous agents—Part 1]]></title>
            <link>https://toluorina.medium.com/agentic-ai-foundations-of-autonomous-agents-part-1-0f205fbf2c80?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f205fbf2c80</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[fundamentals]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 21:37:23 GMT</pubDate>
            <atom:updated>2026-01-07T21:37:23.633Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ZT-rLGxo9l9HLccloqkSvw.png" /><figcaption>Foundations of Autonomous Agents</figcaption></figure><h4>Overview</h4><p>The world is moving at the speed of light, and many businesses are moving at the same pace. Organizations will continue to look for ways to increase productivity and reduce cost. The need to automate repetitive tasks, whether simple or complex, will always be on the rise.</p><p>Traditional automation systems often involve understanding the business processes by seeking out subject matter experts, documenting the specialized procedures, and then defining these processes as functions within the systems. Building this kind of automation system typically takes a lot of time, from months to sometimes even years, including a separate period to refine these processes. This means that traditional automation takes a long time to reach actualization; the numerous processes involved could lead to unanticipated challenges and heuristics, which might never scale.</p><p>Now that it is obvious, there’s a gap. It is important to define a problem statement for the gap and a viable solution for mitigation. For proper automations, we need a system that is self-aware, a paradigm where AI (specialized Large Language Models, LLMs) is applied to understand context, can plan, correct itself, and adapt to a particular, defined use case or application. These LLMs are built with a transformer architecture that possesses a self-attention mechanism, which makes them understand unstructured data (like natural language text, images, audio, video, files, documents, etc.) and perform tasks using this corpus of data as context.<br>Whilst the transformer architecture is not new, LLMs take the transformer architecture to the next level, being as they are built by training massive models, GPTs (generative pretrained models), with billions of parameters, on a massive corpus of data (like the size of the web, social media, research articles, documents, code, etc.). This process typically helps these AI models evolve to understand common processes and functions, and they are now able to generate content based on patterns learned from their training.<br>Although LLMs can understand processes and automate them to improve efficiency and productivity in a reliable and consistent fashion, there needs to be a higher-level structure that can make them truly autonomous agents. This is where Agentic AI saves the day.</p><p>Agentic AI describes a system that is powered by AI/LLMs, which comprises one or more autonomous AI agents, systems that are able to plan. They possess certain defined capabilities, are reliable and consistent, and are able to adapt to various environments. An agentic system can also be described as one that is goal-oriented, proactive, resourceful, learns and adapts, understands limits, escalates, and remembers—all of which sum up to three core/important functions in agents:</p><p>Intelligence (by means of models and LLMs, which can reason), context (tools, data sources, APIs, and knowledge bases), and trust (ethical, reliable, and tested—identity, security, and guardrails).</p><h4><strong>Architecture of Agentic AI systems (AI agents)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ye5g8eZOYUj1epcJ6HIkgA.png" /></figure><p>The Agentic AI Architecture typically comprises a set of primitives, which includes the following:</p><ul><li><strong>Advanced LLMs</strong>: These are a type of LLM that support the use of tools and follow a ReAct paradigm (reason and act), and not just a chain of thought prompting. Such LLMs are able to interact with external environments within the agentic system.</li><li><strong>Tools: </strong>They are acting capabilities with specialized functions that LLMs can call and get a result or response from. They normally help with interactions with external systems and APIs, such as weather forecast, temperature, current time, math calculators, etc.</li><li><strong>Memory: </strong>serves as context for the agentic system, preserving information both within and/or across sessions. It also helps connect the AI agent to enterprise data sources and knowledge bases.</li><li><strong>State</strong>: similar to memory, it helps agents manage context within a particular session (user/agent) interaction.</li><li><strong>The Agentic Loop (reflection):</strong> probably the most important portion of an agentic AI system, typically orchestrated by LLMs themselves in order to output the best and most accurate/reliable results. It works by self-reflecting on both the answers gotten from the LLMs and the tools against the input query by acting as an evaluator.</li></ul><h4><strong>Use cases and applications of Agentic AI</strong></h4><ul><li><strong>Customer Service</strong>: This has gained the most traction when it comes to task automation and customer query resolution. AI agents can be used to handle common customer queries and FAQs without human intervention. The solution is usually a chatbot that sits on a web page with which customers can easily interact and get AI-generated responses. At a high level, the AI agent is usually connected to a data source that has sample FAQs and answers and sometimes to data sources within a company or customer-specific documents.</li><li><strong>Content Generation</strong>: many businesses work with content in the form of documents, spreadsheets, forms, technical documentation, and so on, which are typically repeatable and sometimes might need to follow the company’s structure and design.</li><li><strong>Healthcare</strong>: this is an industry with opportunities for applying Agentic AI to carry out common repetitive tasks, including appointment scheduling, medical coding, billing, etc.</li><li><strong>Fraud Detection</strong>: AI agents can help detect anomalous transactions and respond to such through triggering alarms, blocking transactions, or subjecting them to further verifications.</li><li><strong>Insurance Claim Processing</strong>: AI agents, like LLaVa—large language and vision assistants—can analyze insurance documents and submissions, compare them against claims and data policies, and help to determine claimable insurance.</li></ul><p>More use cases and applications of agentic AI exist across virtually every sector and industry. This opens up a world of possibilities in which almost all kinds of tasks can possibly be supported by agentic AI.</p><h4><strong>Hands-On: Agentic Retail OS—Smart Clerk Agent</strong></h4><p>In this section, we will be looking at a practical demonstration on how we can design, build, and implement a simple Agentic AI-based point-of-sale (POS) system using AWS Strands SDK, tools, and AWS as our cloud platform.<br>The architecture for this POC is shown in the diagram below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxUzPIwthir-hRGffOcvfw.png" /><figcaption>Simple Clerk agentic AI assistant for our POS System</figcaption></figure><p>We would be focusing on how to implement the clerk agent only.</p><p>Our Clerk agent should be able to autonomously automate the following tasks:</p><ol><li><strong>Inventory lookup and verification</strong>—check the inventory to confirm if a product is available via the product’s SKU, and return the product details.</li><li><strong>Discounts and transaction processing</strong>—process transactions of items bought, adding discounts and tax where applicable.</li><li><strong>Receipt generation</strong>—generate standardized receipts of items bought via the POS checkout.</li><li><strong>Basic transaction queries</strong>—respond to basic transaction questions from users such as retrieval of transaction history, filter and sum transactions across dates, and get a transaction detail.</li></ol><p>First, we want to import the necessary libraries.</p><pre>from strands import Agent, tool<br>from strands.models import BedrockModel</pre><p>Secondly, we use the tool decorator to transform a business logic (function code) into a tool, which our agent can use. Typically, the function code should be well documented to improve the agent’s accuracy.</p><pre>@tool<br>def inventory_lookup(sku: str) -&gt; dict:<br>    &quot;&quot;&quot;Look up product information and stock level by SKU.&quot;&quot;&quot;<br><br><br>    # Query DynamoDB for product<br>    product = dynamodb.get_item(TableName=&#39;Products&#39;, Key={&#39;sku&#39;: sku})<br>    return {<br>        &quot;sku&quot;: product[&#39;sku&#39;],<br>        &quot;name&quot;: product[&#39;name&#39;],<br>        &quot;price&quot;: product[&#39;price&#39;],<br>        &quot;stock_quantity&quot;: product[&#39;stock_quantity&#39;],<br>        &quot;available&quot;: product[&#39;stock_quantity&#39;] &gt; 0<br>    }</pre><p>Finally, we pass our tools, model, to our agent.</p><pre>clerk_agent = Agent(<br>    name=&quot;clerk_agent&quot;,<br>    model=model,<br>    tools=[inventory_lookup, transaction_processing,<br>     receipt_generation, transaction_queries]<br>)</pre><p>And voila, our clerk agent is ready to carry out all the expected functions. To get the complete code, visit this GitHub link: <a href="https://github.com/Tolu-Orina/Agentic-POS">https://github.com/Tolu-Orina/Agentic-POS</a>.</p><h4><strong>References</strong></h4><ul><li><a href="https://www.promptingguide.ai/techniques/reflexion">https://www.promptingguide.ai/techniques/reflexion</a></li><li><a href="https://llava-vl.github.io/">https://llava-vl.github.io/</a></li><li><a href="https://www.moveworks.com/us/en/resources/blog/agentic-ai-examples-use-cases">https://www.moveworks.com/us/en/resources/blog/agentic-ai-examples-use-cases</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f205fbf2c80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL ON AWS: PART 5 (LOADING DATA INTO AN AMAZON REDSHIFT CLUSTER AND RUNNING QUERIES WITH REDSHIFT…]]></title>
            <link>https://toluorina.medium.com/etl-on-aws-part-5-loading-data-into-an-amazon-redshift-cluster-and-running-queries-with-redshift-6ad64e451bfe?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ad64e451bfe</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[query]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[etl-pipeline]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 07:11:31 GMT</pubDate>
            <atom:updated>2023-01-20T07:11:31.066Z</atom:updated>
            <content:encoded><![CDATA[<h3>ETL ON AWS: PART 5 (LOADING DATA INTO AN AMAZON REDSHIFT CLUSTER AND RUNNING QUERIES WITH REDSHIFT SPECTRUM)</h3><figure><img alt="USING REDSHIFT SPECTRUM" src="https://cdn-images-1.medium.com/max/720/1*A--UiMBef8-A0RRraygHtg.jpeg" /></figure><h3>APPROACH</h3><ul><li>Create Redshift Cluster</li><li>Set up Redshift Spectrum: to query external tables on S3</li><li>Load subset of read data into a local table in Redshift</li><li>Run complex queries</li></ul><p>A Data Lake serves as a single source of truth across multiple lines of business i.e. from different domains including, finance, healthcare, advertisement, marketing, IoT, It usually includes different variety of data ranging from structured, semi-structured and unstructured data. As a Data Engineer you may need to load data into an external data store(data warehouses or marts) to enable a specific set or subset of data of interest to a particular group of users.</p><p>Two primary purposes for Data warehouses are:</p><ol><li>Provide a database with a subset of the data in the data lake, optimized for specific types of queries (such as for a specific business function)</li><li>High performant, low-latency query engine often used to power BI applications</li></ol><p><strong>AMAZON REDSHIFT</strong></p><p>Amazon Redshift is a super-fast cloud-native data warehousing solution that provides high-performance, low-latency access to data stored in the data warehouse. The Redshift architecture uses the leader and compute nodes distributed model where each compute nodes contains a certain amount of compute power (CPU and memory), as well as certain amount of local storage. Redshift stores data in a columnar data format, which is optimized for analytics, and uses compression algoriths to reduce disk lookup tine when a query is run.</p><p>The Data and Use Case is for a Travel Agency. Agents need to ensure that they can find the best deal for accommodation in New York City and New Jersey City that is close to specific popular tourist attractions, such as the Freedom Tower and the Empire State Building</p><p><strong>Dataset:</strong></p><p>Gotten from Inside Airbnb</p><ul><li>New York Data: ny-listings.csv</li><li>New Jersey Data: nj-listings.csv</li></ul><p>Copying the files to s3:</p><pre>aws s3 cp ny-listings.csv s3://etl-trex-landing zone/listings/city=new_york_city/ny-listings.csv</pre><pre>aws s3 cp nj-listings.csv s3://etl-trex-landing-zone/listings/city=new_jersey_city/nj-listings.csv</pre><p>Quick S3 select query from the uploaded dataset to view first 5 rows</p><figure><img alt="S3 select query results" src="https://cdn-images-1.medium.com/max/959/1*-S5_xdvd9xbO3Umm3Z9__w.png" /><figcaption>S3 select query result</figcaption></figure><p>Next, we go to Redshift and create a Cluster</p><p>A Redshift cluster runs an Amazon Redshift engine and contains one or more databases. It consists of nodes. Each cluster has a leader node and one or more compute nodes. The <em>leader node</em> receives queries from client applications, parses the queries, and develops query execution plans. The leader node then coordinates the parallel execution of these plans with the compute nodes and aggregates the intermediate results from these nodes. It then finally returns the results back to the client applications. <em>Compute nodes</em> run the query execution plans and transmit data among themselves to serve these queries. The intermediate results are sent to the leader node for aggregation before being sent back to the client applications.</p><p>Follow the steps below to create a redshift cluster;</p><ul><li>Login to the AWS Management Console, search for redshift and click it</li><li>Click on create cluster once on the redshift console page</li><li>Select Free trial (for this hands-on)</li><li>Leave the username as it is and provide an Admin password</li><li>Click create cluster</li><li>Wait until its available, then click on the newly created cluster</li></ul><p>Sample Query on test database in Redshift</p><figure><img alt="Redshift sample query" src="https://cdn-images-1.medium.com/max/1024/1*ee8hd0r_bpXRkmlppJ_axA.png" /></figure><p>Since we want to test Redshift Spectrum to query data present in S3, we have to define an external schema and specify that we want to create a new database in Glue Catalog, after which we define an external table that will be registered in our Glue Data Catalog</p><h4>Create External Schema and New Database in Glue Catalog</h4><pre>CREATE EXTERNAL SCHEMA spectrum_schema<br>FROM data catalog<br>database &#39;accomodation&#39;<br>iam_role &#39;&lt;my-redshift-role&gt;&#39;<br>CREATE EXTERNAL DATABASE IF NOT EXISTS;</pre><h4>Define an external table</h4><pre>CREATE EXTERNAL TABLE spectrum_schema.listings(<br> listing_id INTEGER,<br> name VARCHAR(100),<br> host_id INT,<br> host_name VARCHAR(100),<br> neighbourhood_group VARCHAR(100),<br> neighbourhood VARCHAR(100),<br> latitude Decimal(8,6),<br> longitudes Decimal(9,6),<br> room_type VARCHAR(100),<br> price SMALLINT,<br> minimum_nights SMALLINT,<br> number_of_reviews SMALLINT,<br> last_review DATE,<br> reviews_per_month NUMERIC(8,2),<br> calculated_host_listings_count SMALLINT,<br> availability_365 SMALLINT)<br>partitioned by(city varchar(100))<br>row format delimited<br>fields terminated by &#39;,&#39;<br>stored as textfile<br>location &#39;s3://etl-trex-landing-zone/listings/&#39;; </pre><h4>Add Partitions</h4><pre>alter table spectrum_schema.listings add<br>partition(city=&#39;jersey_city&#39;) <br>location &#39;s3://etl-trex-landing-zone/listings/<br>city=jersey_city/&#39; <br><br>alter table spectrum_schema.listings add<br>partition(city=&#39;new_jersey_city&#39;) <br>location &#39;s3://etl-trex-landing-zone/listings/<br>city=new_jersey_city/&#39;<br><br>alter table spectrum_schema.listings add<br>partition(city=&#39;new_york_city&#39;) <br>location &#39;s3://etl-trex-landing-zone/listings/<br>city=new_york_city/&#39;</pre><h4>Finally we can run a query using Redshift Spectrum</h4><pre>select * from spectrum_schema.listings limit 100;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ad64e451bfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL ON AWS: PART 4 (INGESTING STREAMING DATA WITH AMAZON KINESIS (similar to Apache Kafka))]]></title>
            <link>https://toluorina.medium.com/etl-on-aws-part-4-ingesting-streaming-data-with-amazon-kinesis-similar-to-apache-kafka-485171148abc?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/485171148abc</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[real-time-streaming-data]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[etl-pipeline]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 18:35:17 GMT</pubDate>
            <atom:updated>2023-01-17T18:35:17.009Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="STREAMING DATA WITH AMAZON KINESIS VISUALS" src="https://cdn-images-1.medium.com/max/671/1*4R1aOHsnppGWwCdUu6KKJQ.png" /></figure><p>In this Era of Big Data where there is an explosion of different types of data in vast volumes and variety from several sources, there arises the need to tame some of such data in real time, popularly called streaming data analytics.</p><p>Streaming data is data that is generated continuously by thousands of data sources, which typically send in the data records simultaneously, and in small sizes (order of Kilobytes). Streaming data includes a wide variety of data such as log files generated by customers using your mobile or web applications, ecommerce purchases, in-game player activity, information from social networks, financial trading floors, or geospatial services, and telemetry from connected devices or instrumentation in data centers.</p><p>This data needs to be processed sequentially and incrementally on a record-by-record basis or over sliding time windows, and used for a wide variety of analytics including correlations, aggregations, filtering, and sampling. Information derived from such analysis gives companies visibility into many aspects of their business and customer activity such as –service usage (for metering/billing), server activity, website clicks, and geo-location of devices, people, and physical goods –and enables them to respond promptly to emerging situations. For example, businesses can track changes in public sentiment on their brands and products by continuously analyzing social media streams, and respond in a timely fashion as the necessity arises.</p><h3>Some Examples of streaming data</h3><ul><li>Sensors in transportation vehicles, industrial equipment, and farm machinery send data to a streaming application. The application monitors performance, detects any potential defects in advance, and places a spare part order automatically preventing equipment down time.</li><li>A financial institution tracks changes in the stock market in real time, computes value-at-risk, and automatically rebalances portfolios based on stock price movements.</li><li>A real-estate website tracks a subset of data from consumers’ mobile devices and makes real-time property recommendations of properties to visit based on their geo-location.</li></ul><p>In the hands-on for this article, we use Amazon Kinesis to demonstrate how to handle streaming data</p><p><strong>BACKGROUND</strong></p><p>Amazon Kinesis makes it easy to collect, process, and analyze real-time, streaming data so you can get timely insights and react quickly to new information. Amazon Kinesis offers key capabilities to cost-effectively process streaming data at any scale, along with the flexibility to choose the tools that best suit the requirements of your application. With Amazon Kinesis, you can ingest real-time data such as video, audio, application logs, website clickstreams, and IoT telemetry data for machine learning, analytics, and other applications. Amazon Kinesis enables you to process and analyze data as it arrives and respond instantly instead of having to wait until all your data is collected before the processing can begin.</p><p>Amazon Kinesis service has four (4) major components:</p><ul><li>Kinesis Video Streams: for streaming video from connected devices for analytics, ML, etc</li><li>Kinesis Data Streams: A scalable real-time data streaming service that can continuously capture lots of data from different sources in gigabytes per second</li><li>Kinesis Data Firehose: for loading and transforming data streams into AWS data stores for near real-time analytics</li><li>Kinesis Data Analytics: for processing data streams in real time using the popular SQL language or Apache Flink</li></ul><p>We will be using Kinesis Data Firehose in this session</p><p>Benefits of Kinesis Data Firehose Load real-time data. Load streaming data into data lakes, data stores, and analytics tools for:</p><ul><li>Log and event analytics</li><li>IoT data analytics</li><li>Clickstream analytics</li><li>Security monitoring</li></ul><p><strong>PROCEDURE:</strong></p><ul><li>Amazon Kinesis Data Firehose to ingest streaming data, and write the data out to Amazon S3</li><li>Amazon Kinesis Data Generator (KDG) to generate source of streaming data</li></ul><p><strong>DELIVERY STREAM</strong></p><ul><li>s3 bucket prefix: streaming/!{timestamp:yyyy/MM/}</li><li>s3 bucket error prefix: !{firehose:error-output-type}/!{timestamp:yyyy/MM/}</li><li>For this Use case we set buffer size to 1 MB and buffer interval to 60 seconds</li></ul><p><strong>STREAMING</strong></p><p>The Sakila Database from the part 2 of this series, was for a company that produced classic movies. Now movies are available for rental through various streaming platforms. The company receives information about their classic movies being streamed from their distribution partners in real time, in a standard format. Using KDG, the streaming data information includes the following;</p><ul><li>Streaming timestamp</li><li>Whether the customer rented, purchased, or watched the trailer</li><li>film_id that matches the sakila film database</li><li>the distribution partner name</li><li>Straming platform</li><li>the state the movie was streamed in</li></ul><p>Amazon Kinesis Data Generator (KDG) is an open source tool that makes it easy to send data to Kinesis Data Streams and Kinesis Firehose</p><p>KDG Cloudformation template</p><p>The CloudFormation template will create the following resources in your AWS account:</p><ul><li>An IAM role that gives the Lambda function permission to create Cognito resources.</li><li>An IAM role that is assigned to authenticated Cognito users. This role has only enough permission to use the KDG.</li><li>An IAM role that is assigned to unauthenticated Cognito users. This role has only enough permission to create Cognito analytics events.</li><li>A Lambda function.</li></ul><p>The Lambda function will create the following resources in your AWS account:</p><ul><li>A Cognito User Pool.</li><li>A Cognito Federated Identity Pool.</li><li>A Cognito User, with the username and password specified by you when you created the CloudFormation stack.</li><li>The necessary relationships between the roles, users and pools.</li></ul><p>KDG URL: &lt;my-url&gt;</p><p>Region: us-east-1<br>Delivery Stream: etl3-delivery<br>Records per second: 10</p><p>Record template</p><pre>{<br> &quot;timestamp&quot;:&quot;{{date.now}}&quot;,<br> &quot;eventType&quot;:&quot;{{random.weightedArrayElement(<br> {<br> &quot;weights&quot;: [0.3, 0.1, 0.6],<br> &quot;data&quot;:[&quot;rent&quot;,&quot;buy&quot;,&quot;trailer&quot;]<br> }<br> )}}&quot;,<br> &quot;film_id&quot;:{{random.number(<br> {<br> &quot;min&quot;:1,<br> &quot;max&quot;:1000<br> } <br> )}},<br> &quot;distributor&quot;:&quot;{{random.arrayElement(<br> [&quot;amazon prime&quot;, &quot;google play&quot;, &quot;apple itunes&quot;, &quot;twitter&quot;,<br> &quot;microsoft&quot;, &quot;meta&quot;, &quot;youtube&quot;]<br> )}}&quot;,<br> &quot;platform&quot;: &quot;{{random.arrayElement(<br> [&quot;ios&quot;, &quot;android&quot;, &quot;xbox&quot;, &quot;social-media&quot;, &quot;tech&quot;, &quot;other&quot;]<br> )}}&quot;,<br> &quot;state&quot;:&quot;{{address.state}}&quot;<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=485171148abc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL ON AWS : PART 3 (INGESTING DATA FROM A MYSQL RDS DATABASE INTO S3-BASED DATA LAKE USING AWS…]]></title>
            <link>https://toluorina.medium.com/etl-on-aws-part-3-ingesting-data-from-a-mysql-rds-database-into-s3-based-data-lake-using-aws-52ab15a7623e?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/52ab15a7623e</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[cloud-engineering]]></category>
            <category><![CDATA[etl-pipeline]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 17:53:30 GMT</pubDate>
            <atom:updated>2023-01-17T17:53:30.325Z</atom:updated>
            <content:encoded><![CDATA[<h3>ETL ON AWS : PART 3 (INGESTING DATA FROM A MYSQL RDS DATABASE INTO S3-BASED DATA LAKE USING AWS DMS (Database Migration Service))</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*GL0pHt58azwnclb6XRbETw.png" /></figure><p>ETL as a process helps with data migration from legacy systems to a centralized data repository often referred to as a data lake.</p><p><strong>AWS Data Database Migration Service (AWS DMS)</strong><br>AWS Database Migration Service (AWS DMS) is a managed migration and replication service that helps move your database and analytics workloads to AWS quickly, securely, and with minimal downtime and zero data loss. It is is primarily intended for doing either a one-off ingestion of historical data from a database, or for replicating data from a relational database on an ongoing basis. <br>When using AWS DMS, the target is either a different database engine or an Amazon S3-based data lake.</p><p>DMS provisions one or more EC2 servers as replication instances. These replication instances connect to the source database, read data from the source, prepare the data for loading into the target, and then connect to the target and write the data.</p><p><strong>PROCEDURE:</strong></p><ul><li>Create a MySQL database instance using Amazon Relational Database Service (RDS): etl2db in order to host our test database (it’s used to mirror on-premise versions)</li><li>Load Demo Data (Sakila) using an ec2 instance into our RDS MySQL DB</li><li>Create IAM policy and role for DMS: The IAM policy and role will allow DMS to write to our target s3 bucket.</li><li>Create an S3 VPC gateway endpoint.</li><li>Create a DMS replication instance and other required DMS resources</li></ul><p><strong>User Data script to load demo data into the RDS database</strong></p><pre>#!/bin/bash<br>yum install -y mariadb<br>curl https://downloads.mysql.com/docs/sakila-db.zip -o sakila.zip<br>unzip sakila.zip<br>cd sakila-db<br>mysql --host=&lt;myrdsendpoint&gt; --user=admin --password=&lt;mypass&gt; -f &lt; sakila-schema.sql<br>mysql --host=&lt;myrdsendpoint&gt; --user=admin --password=&lt;mypass&gt; -f &lt; sakila-data.sql</pre><p><em>The Bash Script</em>:</p><ul><li>Installs MariaDB (which comes with a mysql client to connect to our MySQL server)</li><li>Downloads a demo database named sakila</li><li>Connects to the mysql server twice to inject schema and data</li></ul><p><strong>IAM Policy</strong>: ETLS3BucketPolicy (permissive can be more fine-grained)</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:*&quot;<br>                ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::etl-trex-landing-zone/*&quot;<br>                ]<br>        }<br>        ]<br>}</pre><p><strong>CONFIGURING THE Database Migration Task</strong></p><ul><li>DMS Replication Instance connects to the source endpoint,<br> retrieves data, and writes to the target endpoint.</li><li>Configure Source and Target Endpoints: Source(etl2-db), Target(etl2-etl-trex-csv).</li><li>Create Database Migration task (using the pre-provisioned configuration settings): etl2-mysql-s3</li></ul><p><strong>GET MIGRATED FILE</strong></p><pre>aws s3api get-object - bucket etl-trex-landing-zone - key etl2-db/sakila/actor/LOAD00000001.csv received.csv</pre><p><strong>VIDEO DEMONSTRATION</strong></p><p><a href="https://user-images.githubusercontent.com/78595009/205676950-e1887624-10e3-4f00-88dc-7218de152d29.mp4">https://user-images.githubusercontent.com/78595009/205676950-e1887624-10e3-4f00-88dc-7218de152d29.mp4</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52ab15a7623e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL ON AWS : PART 2 (SECURING YOUR DATA LAKE USING AWS LAKE FORMATION)]]></title>
            <link>https://toluorina.medium.com/etl-on-aws-part-2-securing-your-data-lake-using-aws-lake-formation-fefbd6ad4f26?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fefbd6ad4f26</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[security-services]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 16:12:55 GMT</pubDate>
            <atom:updated>2023-01-17T16:12:55.266Z</atom:updated>
            <content:encoded><![CDATA[<h3>ETL ON AWS : PART 2 SECURING YOUR DATA LAKE USING AWS LAKE FORMATION</h3><figure><img alt="Secure your Data Lake with AWS LakeFormation" src="https://cdn-images-1.medium.com/max/1024/1*fXTp7d_Pvv_8CxfrGtjweQ.png" /><figcaption>Secure your Data Lake with AWS LakeFormation</figcaption></figure><p><strong>AWS Lake Formation</strong> is a service that simplifies setting up and managing a data lake. And a big part of the Lake Formation service is the ability to manage access (authorization) to data lake databases and tables without having to manage fine-grained access through JSON-based policy documents in the IAM service.</p><p>With Lake Formation, data lake users do not need to be granted direct permissions on underlying S3 objects as the Lake Formation service can provide temporary credentials to compatible analytic services to access the S3 data.</p><p>Background on other services used:</p><ul><li><strong>Amazon S3</strong><br>Amazon S3 or Amazon Simple Storage Service is a service offered by Amazon Web Services that provides object storage through a web service interface. Amazon S3 uses the same scalable storage infrastructure that Amazon.com uses to run its e-commerce network.</li><li><strong>AWS Glue data catalog</strong><br>The AWS Glue Data Catalog is an index to the location, schema, and runtime metrics of your data. You use the information in the Data Catalog to create and monitor your ETL jobs. Information in the Data Catalog is stored as metadata tables, where each table specifies a single data store.</li><li><strong>AWS IAM</strong><br>AWS IAM is a service that provides both authentication and authorization for the AWS Console, command-line interface (CLI), and application programming interface (API) calls. Important identities under IAM include: IAM User, IAM User Groups, IAM roles</li></ul><p>For this project, we first create a new data lake user and configure permissions using just IAM permissions. Then we’ll update a glue database and table to use Lake Formation permissions and then grant Lake Formation permissions to our data lake user.</p><h3>Creating new data lake user with IAM permissions</h3><p>Here, we use IAM to grant the new data lake user some permissions including;</p><ul><li>Permission to access a specific database and table in Glue data catalog</li><li>Permission to use the Amazon Athena service to run SQL queries against the data lake</li></ul><p><strong>Steps Taken :</strong></p><ul><li>Create a new IAM policy that grants the required permissions for using Athena and Glue limited to the <strong><em>testdb</em></strong> database.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*TiPSQtwelNtbXfwW3815jQ.png" /><figcaption>IAM policy for testdb</figcaption></figure><p>It also adds permission for the S3 bucket….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1vFYINRQKHvIDFVW6k-hEg.png" /><figcaption>IAM policy to grant access to the S3 bucket</figcaption></figure><ul><li>Save Policy with a name like AthenaAccesstestdb</li><li>Create a new data lake user e.g datalaker1 and attach the IAM policy we just created.</li><li>Create new S3 bucket to capture results of Athena query<br>Bucket-name: aws-athena-query-results-&lt;your unique name&gt;</li></ul><p>Next, we want to verify that datalaker1 only has access to testdb and can<br>run athena queries on the table in this database;</p><ul><li>We sign in as datalaker1, go to Athena. Click on Settings.</li><li>Query result location: select aws-athena-query-results-trex<br>Click save.</li><li>In the New Query window, run the query: select * from testdb.csvparquet</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N3oUjBgIFEqpFi9yCTnTdw.png" /><figcaption>Athena query run by datalaker1 user</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPFfzzJKPmQFSky8i56JPQ.png" /><figcaption>Query Result</figcaption></figure><p>Haven set up permissions using IAM policies to manage fine-grained access control, We will now look at AWS Lake Formation a better and easier tool to manage fine-grained permissions.</p><h3>Using AWS Lake Formation</h3><ul><li>Log in to AWS Lake Formation using the <strong>Admin user</strong></li><li>Navigate through <strong>Databases</strong> &gt;&gt; <strong>testdb</strong></li><li>Click on <strong>Actions</strong> then <strong>View Permissions</strong></li></ul><p>Worth noting is the IAMAllowedPrincipals group, a pass-through permission in lake formation which ignores permissions at the Lake Formation Layer and instead permits security checks to be validated at the IAM level, but then passes through Lake formation without doing any additional permission checks.</p><ul><li>To enable Lake Formation permissions on this database, we can remove the IAMAllowedPrincipals permission from the database. To do this select the IAMAllowedPrincipals group, then click <strong>Revoke</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tgLxGlQFd_5bU0z8E6KFbg.png" /><figcaption>Revoke IAMAllowedPrincipals to activate Lake Formation permissions</figcaption></figure><ul><li>Click Revoke</li><li>We’ll do the same for the csvparquet table</li></ul><p>If we try to run the Athena query, we’ll get an error because Lake formation permissions are now in effect.</p><h3>Adding Specific Lake Formation permissions for our new data lake user, datalaker1, to access the testdb database and the csvparquet table</h3><ul><li>Navigate to testdb in lake formation via, Databases &gt;&gt; testdb</li><li>Click on csvparquet, click Actions &gt;&gt; Grant (under permissions)</li><li>select the datalaker1 user from IAM users and roles options</li><li>Allow only Select for Table Permissions</li><li>Exclude column Favorite num</li><li>Click Grant</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2lMN95EsjvPY1qUbVLqDJg.png" /><figcaption>Lake Formation controlled Data Lake access permissions</figcaption></figure><p><strong>AWS Lake Formation</strong> is a useful tool for easily managing authorization for datasets and your data lake in general.</p><p><strong>References and more</strong>:</p><ul><li><a href="https://aws.amazon.com/lake-formation/">https://aws.amazon.com/lake-formation/</a></li><li>Data Engineering with AWS by Gareth Eagar</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fefbd6ad4f26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ETL ON AWS : PART 1]]></title>
            <link>https://toluorina.medium.com/etl-on-aws-part-1-8b014615c8af?source=rss-c30a73ef2bb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b014615c8af</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[etl-pipeline]]></category>
            <dc:creator><![CDATA[Tolulope Orina (trexdevops)]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 16:00:50 GMT</pubDate>
            <atom:updated>2023-01-09T16:36:15.827Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automate File Format Conversion with AWS Lambda</h3><p>In this Project, we configure an s3 bucket to automatically trigger a lambda function whenever a new “.csv” file is written to it. This Lambda function converts the csv file to parquet format.</p><p>Apache Parquet is <strong>an open source, column-oriented data file format designed for efficient data storage and retrieval</strong>. It provides efficient data compression and encoding schemes with enhanced performance to handle complex data in bulk.</p><figure><img alt="Architecture Image" src="https://cdn-images-1.medium.com/max/852/1*66UOhg298WOsInIhz4cXQg.png" /><figcaption>ETL Architecture image</figcaption></figure><h3>Services Used</h3><ul><li>Amazon S3</li><li>AWS Lambda</li><li>AWS Data Wrangler</li><li>AWS Glue Data Catalog</li></ul><p>Amazon S3 is a reliable, highly available and scalable data lake storage solution. It is easy to use and integrates with many AWS services and third-party tools used for data curation, analysis, engineering and Machine Learning. In this project Amazon S3 is used as a data lake store for both staging and load phase of the ETL (Extract, Transform, Load) process.</p><p>AWS Lambda is an event-driven, serverless compute platform that lets you run light weight code without worrying about provisioning servers. Here AWS lambda serves as compute platform for data transformation and conversion to parquet format (an open source, column-oriented data file format designed for efficient data storage and retrieval).</p><p>AWS Data Wrangler, now AWS SDK for pandas, is an open source package for reading data in the AWS ecosystem. It was created by AWS Professional Services Team at Amazon and is built on top of pandas (python’s popular data wrangling tool). AWS Data Wrangler does the work of converting the csv file to parquet format.</p><p>AWS Glue Data Catalog is an index to the location, schema, and runtime metrics of your data. You use the information in the Data Catalog to create and monitor your ETL jobs. Information in the Data Catalog is stored as metadata tables, where each table specifies a single data store. Here It serves as the metadata reference for the destination bucket in this project.</p><p><strong><em>Code Snippet</em></strong></p><p># Read in the Data<br>input_df = wr.s3.read_csv([input_path])<br> <br>current_databases = wr.catalog.databases()<br>if db_name not in current_databases.values:<br> print(f”Creating Database {db_name} …..”)<br> wr.catalog.create_database(db_name)<br>else:<br> print(f’Database {db_name} already exists’)</p><p>print(f’Converting to {file_prefix}.parquet’)<br># Write to parquet in output s3 bucket<br>result = wr.s3.to_parquet(<br> df = input_df,<br> path=output_path,<br> dataset = True,<br> filename_prefix = file_prefix,<br> database = db_name,<br> table = table_name,<br> mode =”append”<br> )</p><p><a href="https://user-images.githubusercontent.com/78595009/202561890-6e0132bd-874a-4899-8cc5-31783b6b589f.mp4">https://user-images.githubusercontent.com/78595009/202561890-6e0132bd-874a-4899-8cc5-31783b6b589f.mp4</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b014615c8af" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>