<?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 Furkan Özev on Medium]]></title>
        <description><![CDATA[Stories by Furkan Özev on Medium]]></description>
        <link>https://medium.com/@furkanozev?source=rss-b5245c5cbdc4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*efFpElzqhQi6W4QvVKn0NQ.jpeg</url>
            <title>Stories by Furkan Özev on Medium</title>
            <link>https://medium.com/@furkanozev?source=rss-b5245c5cbdc4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:28:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@furkanozev/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 Things We Trust]]></title>
            <link>https://furkanozev.medium.com/the-things-we-trust-6abd22f3d1b4?source=rss-b5245c5cbdc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6abd22f3d1b4</guid>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Furkan Özev]]></dc:creator>
            <pubDate>Tue, 06 Oct 2026 06:03:20 GMT</pubDate>
            <atom:updated>2026-10-06T06:03:20.448Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Security, AI, and why building faster shouldn’t mean thinking less</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8us_QiM1H474OzLIuz-xtQ.png" /></figure><p>Before we start, a small confession.</p><p>This article came out of a pile of cybersecurity and AI papers and articles I’d been reading lately. Some were technical. Others were about human behavior, privacy, resilience, or why companies can spend ridiculous amounts of money on security and still get breached in surprisingly ordinary ways.</p><p>While reading, I started collecting my own thoughts. And yes, I used AI.</p><p>I asked it questions when I didn’t understand something, used it to challenge my interpretation, connect topics I hadn’t connected, and eventually help me revise this article.</p><p>What I didn’t want to do was type:</p><blockquote><em>“Write me a Medium article about cybersecurity and AI.”</em></blockquote><p>…and publish whatever came back five seconds later.</p><p>We already live in a world where content is generated incredibly fast and consumed even faster. I didn’t really feel like adding one more perfectly structured, completely forgettable AI-generated article to the pile.</p><p>So this is me trying to make sense of what I’ve been reading and seeing while building software.</p><p>AI helped. It didn’t do the thinking for me.</p><p>Alright. Now to the fun part.</p><h3>We Trust a Lot More Than Our Own Code</h3><p>For a long time, many of us had a pretty comfortable relationship with security.</p><p>We built the software. Someone else secured it.</p><p>There was usually a security team somewhere with scanners, policies, penetration tests, dashboards and enough technical jargon to make the rest of us think:</p><blockquote><em>“Cool. Someone’s got this.”</em></blockquote><p>We wrote the feature, opened the PR, got it deployed, and moved on. If security found something later, we fixed it.</p><p>That model was never great, but it felt workable.</p><p>It doesn’t anymore.</p><p>The software we build today is too connected, too distributed, too automated, and too dependent on things we didn’t build ourselves.</p><p>A pretty normal application can rely on hundreds of open-source packages, cloud services, CI/CD pipelines, containers, identity providers, APIs, SaaS products and, increasingly, AI systems that can read our code, generate new code, or actually do things on our behalf.</p><blockquote><em>At some point, the attack surface stopped being just our code. It became everything we decided to trust.</em></blockquote><p>And let’s be honest, we trust a lot.</p><p>Most of us have never read every line of every dependency our applications use. We couldn’t, even if we wanted to.</p><p>We pull a container image, install a package, add an SDK, copy a GitHub Action, and get on with the actual task.</p><p>Usually, that works perfectly well.</p><p>Usually.</p><p>Security incidents seem to enjoy that word.</p><h3>Sometimes curiosity is a security control</h3><p>The xz Utils incident in 2024 is probably my favorite example.</p><p>Xz is a compression library buried deep inside Linux systems. Not exactly the sort of technology most developers wake up excited to discuss over coffee. Yet malicious code made its way into official releases in a way that could interfere with SSH authentication under certain conditions.</p><p>The part I love is how it unraveled.</p><p>Developer Andres Freund noticed that SSH logins were using a bit more CPU than he expected. He also saw some strange errors. Something felt off, so he kept digging.</p><p>Eventually, that investigation exposed the backdoor.</p><p>Think about that for a second.</p><p>A sophisticated supply-chain compromise with potentially huge impact, and somewhere one engineer basically went:</p><blockquote><em>“Hmm. Why is this thing slightly slower than it should be?”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*y99RlIRdq7M5j1WDhMYR-Q.gif" /></figure><p>No dramatic red screen. No hacker in a hoodie. Just curiosity.</p><p>The dangerous code wasn’t in the application anybody was actively developing. It was deeper in the stack, inside something thousands of systems had learned to trust.</p><p>So “Is our code secure?” is still a good question.</p><p>It’s just not enough anymore.</p><p>We also need to ask:</p><blockquote><em>“What are we trusting in order for our code to work?”</em></blockquote><p>A lot of security problems become surprisingly ordinary when you phrase them that way.</p><p>Too much access. A bad configuration. An API that was supposedly “internal.” A credential that was only supposed to be temporary. A service account that somehow became the key to half the kingdom.</p><p>Nothing particularly cinematic.</p><p>Just normal engineering decisions quietly becoming security decisions.</p><h3>And Then AI Handed Us a Superpower</h3><p>I don’t think avoiding AI is a serious strategy for developers.</p><p>Refusing to use it because it introduces new risks feels a little like refusing to use version control because merge conflicts exist.</p><p>AI is sometimes ridiculously useful.</p><p>Give it enough context and it can follow coding standards, create tests, write infrastructure definitions, explain unfamiliar components and implement surprisingly large chunks of work.</p><p>You give it a decent prompt, get back a clean implementation and, for a second, there’s definitely a:</p><blockquote><em>“You’re a wizard, Harry.”</em></blockquote><p>moment.</p><p>What worries me isn’t the superpower.</p><p>It’s the confidence that comes with it.</p><p>There’s this idea creeping into development that because we can implement almost anything quickly now, we must also be implementing it well.</p><p>Those are very different things.</p><p>AI can write beautiful code for the wrong problem.</p><p>If we haven’t properly understood the business requirement, the functional constraints, the existing architecture, the integration points, the security expectations and how surrounding services actually behave, the fact that the generated code fits our style doesn’t make it correct.</p><p>A perfectly written implementation of a poorly understood requirement is still a bad implementation.</p><p>Sounds obvious, right?</p><p>In practice, not so much.</p><p>Before AI, implementing something usually forced us to sit with the problem for a while.</p><p>Now we can go from an idea to several hundred lines of plausible code in minutes. Tests are green. Naming looks nice. Maybe it even wrote the docs.</p><p>Cool, cool, cool. Legendary.</p><p>Ship it?</p><p>Well… maybe.</p><p>Because producing code was never the hardest part of software engineering.</p><p>The harder part is figuring out what should actually be built, where it belongs, what assumptions we’re making, what can break, what else we might affect and what trade-offs we’re quietly accepting.</p><p>AI can help with that analysis too. I use it for exactly that.</p><p>But there’s a difference between having AI in the room and letting AI drive the meeting.</p><p>It’s the same trust question with a friendlier interface: we’re trusting the code because it looks right.</p><p>The responsibility is still ours.</p><h3>Fluent Is Not the Same as Correct</h3><p>One thing AI is incredibly good at is sounding confident.</p><p>Sometimes much more confident than the situation deserves.</p><p>Ask it to use a library and it may happily call a function that doesn’t exist: perfect syntax, sensible name, not a hint of doubt.</p><p>It reads like real documentation.</p><p>It just isn’t real.</p><p>That’s the trap.</p><p>Fluency and correctness aren’t the same thing, and a model’s tone tells us very little about how sure it should be. A confident answer is just one more thing we’re tempted to trust.</p><p>There’s even some theory behind this. A recent paper, <em>Hallucination as a Computational Boundary: A Hierarchy of Inevitability and the Oracle Escape</em>, argues that under a particular formal model, some hallucination comes from deeper computational limits, not just bad prompting or too little training.</p><p>We don’t need the math to take the engineering lesson.</p><p>I wouldn’t bet a critical system on the next model release suddenly becoming incapable of being confidently wrong.</p><p>A better bet is to assume uncertainty stays with us.</p><p>Important answer?</p><p>Check it against something we trust.</p><p>Important action?</p><p>Maybe don’t let the model fire it off completely on its own.</p><h3>Creation Has Become Cheap. Understanding Hasn’t.</h3><p>This is the part that worries me most, because we can already feel it in day-to-day work.</p><p>We can produce software faster than we can properly review and understand it.</p><p>Reviewing somebody else’s large change has always taken effort. You reconstruct their reasoning, understand the surrounding system and try to notice assumptions the author missed.</p><p>AI dramatically reduces the cost of producing the change.</p><p>It doesn’t reduce the cost of understanding it by the same amount.</p><p>Faros published an interesting analysis based on real usage data from thousands of developers and teams. As AI usage increased, developers completed more work, but the pressure didn’t disappear.</p><p>It moved.</p><p>PRs got larger. Review times increased. Bugs increased too.</p><p>I wouldn’t treat one dataset as the Ten Commandments of software engineering, but the shape of the problem feels very familiar.</p><blockquote><em>Creation has become cheap. Understanding hasn’t.</em></blockquote><p>And there’s a very tempting shortcut.</p><p>AI writes the code.</p><p>AI reviews the code.</p><p>AI fixes the AI reviewer’s comments.</p><p>Another AI summarizes the PR.</p><p>Then we click approve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*DDjVNsixCHkmMnZrd940KA.gif" /></figure><p>At some point, we’ve built a highly efficient conversation between machines and placed ourselves somewhere near the approval button.</p><p>That loop makes me uncomfortable.</p><p>Not because AI review is useless. It can be great.</p><p>But eventually somebody has to understand what we’re shipping.</p><p>That somebody is still us.</p><p>Maybe the bottleneck in software development was never how fast we could type code.</p><p>Maybe it was always how much complexity humans can safely understand.</p><p>AI changes the first limit much faster than the second.</p><p>And clicking approve on something we don’t understand is just another way of trusting it.</p><h3>Now Give the AI Production Access. What Could Go Wrong?</h3><p>Things get even more interesting when AI stops helping us write software and starts acting inside our systems.</p><p>Imagine an internal agent that can inspect repositories, read tickets, call internal services and interact with deployment tools.</p><p>Sounds great.</p><p>Connect GitHub. Connect Slack. Connect the database. Add another MCP server.</p><p>Maybe production too.</p><p>What could possibly go wrong?</p><p>Before long, we have something incredibly capable.</p><p>We may also have something incredibly privileged.</p><p>And every connection is one more thing we’ve decided to trust.</p><p>These systems produce very human-looking output. That doesn’t mean they understand our company the way another engineer does.</p><p>If an assistant only suggests text, a mistake might waste five minutes.</p><p>If it can merge code, send messages, modify infrastructure or query production data, the exact same mistake becomes an action.</p><p>So the more interesting question is no longer just:</p><blockquote><em>“Can this agent do the task?”</em></blockquote><p>It’s:</p><blockquote><em>“What can this agent do when it gets the task wrong?”</em></blockquote><p>That sounds like an AI problem.</p><p>It isn’t.</p><p>It’s one of the oldest security ideas around: least privilege.</p><p>An agent that needs to read a repository doesn’t automatically need permission to merge into main.</p><p>Reading production data and changing it are very different jobs.</p><p>And if all we wanted was help drafting an email, maybe we don’t need to give the model a big red SEND button.</p><p>Giving an agent access to thirty things when it needs three doesn’t make it smarter.</p><p>It just makes the eventual incident report more interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*djTGKO-CpYVblEH9GsUCYQ.png" /></figure><p>Connecting everything to everything because we can isn’t the same as connecting what’s necessary because we understand why.</p><h3>Assume Breach: What Happens Next?</h3><p>xz was a trusted dependency turning malicious.</p><p>CrowdStrike, in July 2024, was something even more uncomfortable.</p><p>A faulty security content update crashed Windows systems around the world, disrupting airlines, hospitals and plenty of other organizations.</p><p>There was no attacker cleverly sneaking through a firewall.</p><p>The software was trusted.</p><p>The update mechanism was trusted.</p><p>The security product itself was trusted.</p><p>That’s what makes the incident interesting.</p><p>Security isn’t only about keeping malicious people outside.</p><p>Sometimes the thing capable of hurting us is already inside: a dependency, an update, an admin account, an automation, an AI agent, or that “temporary” permission we were definitely going to clean up two sprints ago.</p><p>We’ve all seen one of those.</p><p>This is why I’ve started thinking of security less as a collection of products and more as the management of assumptions.</p><p>The frontend will validate this.</p><p>Only our app can call that API.</p><p>That service account belongs to one service.</p><p>The package came from the usual registry, so it’s probably fine.</p><p>Monitoring will catch it.</p><p>Someone will rotate the secret.</p><p>The AI probably understood what I meant.</p><p>None of those are absurd assumptions.</p><p>The problem is when the architecture quietly depends on every single one of them staying true forever.</p><p>That’s a pretty optimistic contract for production software.</p><p>We already design distributed systems around things going wrong.</p><p>The network goes missing for a second? Timeout.</p><p>A downstream service has a bad day? Circuit breaker.</p><p>A machine dies at 3 a.m.? Hopefully there’s another copy of whatever mattered on it.</p><p>Nobody calls that paranoia.</p><p>That’s just Tuesday.</p><blockquote><em>Security is mostly normal engineering with different failure modes.</em></blockquote><p>Maybe an account gets compromised.</p><p>Fine — does it now own the entire system?</p><p>Maybe one dependency turns malicious.</p><p>How many doors does that open?</p><p>Maybe an AI-generated change is wrong.</p><p>Can it quietly reach production without anybody understanding what changed?</p><p>Maybe someone gets in despite all our controls.</p><p>Okay.</p><p>Then what?</p><p>That’s the useful part of <strong>assume breach</strong>.</p><p>Not “give up, attackers always win.”</p><p>More like: prevention matters, but design the system knowing that one day something may get through.</p><p>Does monitoring notice before a customer does?</p><p>Can we cut off the affected service without taking down everything around it?</p><p>Does the system have a degraded mode, or does one broken component immediately turn into “all hands on deck”?</p><p>And if somebody compromises one part, how far can they actually travel before hitting a wall?</p><p>That last one is the blast radius.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*hswXgAhiSHeAKhR0vh0b7A.gif" /></figure><p>Think about buildings.</p><p>We don’t design one giant fireproof room and hope nothing ever catches fire. We have alarms, fire doors, separate sections and exits because one small fire shouldn’t get unlimited freedom to explore the building.</p><p>Software isn’t all that different.</p><p>A compromised service shouldn’t automatically get a backstage pass to everything else.</p><p>An edge device might lose remote connectivity and keep doing the important local stuff safely.</p><p>A suspicious account might suddenly find a few doors closed.</p><p>An AI agent can prepare the deployment, but maybe the final button still belongs to someone who drinks coffee and pays taxes.</p><p>That isn’t failure prevention.</p><p>It’s containment.</p><p>And containment is underrated.</p><h3>Security Doesn’t Have to Be Miserable</h3><p>None of this means we should slow down and become afraid of technology.</p><p>Quite the opposite.</p><p>Security gets miserable when it’s a giant list of horrible things that might happen, owned by a department whose only job is to tell developers “no.”</p><p>It gets much more interesting as another way of understanding systems.</p><p>Pretend a dependency starts lying.</p><p>Give a user a permission they shouldn’t have and see where they can go.</p><p>Imagine the AI misunderstood your request in the most confident possible way.</p><p>Then ask what the system does next.</p><p>That’s actually kind of fun.</p><p>Ignoring these problems can be even more entertaining, although usually for everybody except us.</p><h3>Do it before the architecture hardens</h3><p>“Cool, now let’s pentest it” is too late for a lot of decisions.</p><p>We’re never going to catch everything while developing. That’s not realistic.</p><p>But security discussions are much cheaper before the architecture has hardened into twenty services, four integrations, three “temporary” exceptions and one component nobody wants to touch anymore.</p><p>At design time, asking:</p><blockquote><em>“Does this service really need that permission?”</em></blockquote><p>takes five minutes.</p><p>Six months later, removing it might involve three teams, a migration plan and a meeting titled <em>Permission Cleanup — Part 4</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*3eZWRCm62YoXFxyB-VBh9A.gif" /></figure><p>Developers don’t need to become security experts.</p><p>But they need an instinct.</p><p>Enough to look at a design and think:</p><blockquote><em>“If this gets compromised, what does it have access to?”</em></blockquote><p>Or:</p><blockquote><em>“Would we even notice?”</em></blockquote><p>Or sometimes just:</p><blockquote><em>“Why is SSH using more CPU today?”</em></blockquote><p>Curiosity goes a surprisingly long way.</p><h3>Sometimes the best data protection is not having the data</h3><p>The same mindset applies to data.</p><p>For a long time, the obvious concern was whether somebody could steal it.</p><p>AI adds another question:</p><blockquote><em>What can somebody infer from it?</em></blockquote><p>A dataset can look harmless when we collect it, then say much more than we expected once it’s combined with another dataset and a capable enough model.</p><p>Behavioral data, location information, source code, search patterns, telemetry — information doesn’t always stay as innocent as it looked when we first stored it.</p><p>So the rule is almost annoyingly simple.</p><p>If we don’t need the data, maybe don’t collect it.</p><p>If a service doesn’t need a permission, don’t grant it.</p><p>If two systems don’t need a network path, they don’t need to be best friends.</p><p>We spend a lot of engineering effort protecting things we might never have needed to create in the first place.</p><p>Capability and necessity aren’t the same thing.</p><p>Security has an annoying habit of asking:</p><blockquote><em>“Yeah, but does it actually need that?”</em></blockquote><p>Not the most exciting question in the room.</p><p>Often a useful one.</p><h3>Our Thinking Has to Keep Up</h3><p>The old “I’ll take my task, implement it, close it, next” mindset is getting harder to defend, especially when AI makes the “implement it” part ridiculously fast.</p><p>We need enough context to know what we’re touching: where our piece sits, who depends on it, what it depends on, and what happens if we get it wrong.</p><p>AI can help with that.</p><p>I’ve used it to understand unfamiliar code, question design decisions and notice things I would have missed on the first pass.</p><p>Not replacing the thinking.</p><p>Giving us more ways to think.</p><p>So when we finish something, we still ask:</p><p>Does it work?</p><p>Do we understand why?</p><p>What are we trusting?</p><p>What assumptions are hiding underneath it?</p><p>And what happens when that trust is wrong?</p><p>Does the problem stop there…</p><p>or does it get the full guided tour of our system?</p><p>AI lets us build faster than we ever could before.</p><p>That’s exciting.</p><p>We should just make sure our thinking can keep up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6abd22f3d1b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IoT Architecture with AWS IoT Core: Step-by-Step Design]]></title>
            <link>https://furkanozev.medium.com/iot-architecture-with-aws-iot-core-step-by-step-design-4626c574b4aa?source=rss-b5245c5cbdc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4626c574b4aa</guid>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[aws-iot-core]]></category>
            <category><![CDATA[iot-communication]]></category>
            <dc:creator><![CDATA[Furkan Özev]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 14:24:24 GMT</pubDate>
            <atom:updated>2024-07-19T13:18:21.269Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi everyone👋, In this article, I will share an application example of AWS IoT Core. I aim to explain step by step how we can implement a use case or architecture for a specific need. First, let’s briefly look at what AWS IoT Core is.</p><h4>What is IoT Core ? 🤔</h4><p>AWS IoT Core is an IoT (Internet of Things) management service offered by Amazon Web Services (AWS). This service allows devices to securely connect to the cloud, collect and analyze data, and communicate with other devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*XOYT9seQpHFa9f3trSh1nQ.png" /></figure><p>IoT Core provides a communication infrastructure based on the MQTT protocol. The main reasons why the MQTT protocol is preferred in IoT devices are that it provides low bandwidth, low power consumption and can communicate effectively and efficiently between IoT devices thanks to the publish-subscribe model.</p><p>I will not go further into the details and usage areas of AWS IoT Core; This article is not the right place for that 😊. For more information, I recommend <a href="https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html">AWS documentation</a> or similar Medium articles.</p><p>As you can see from the diagram below, our main goal is to ensure bi-directional communication of IoT devices with AWS services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*kuTv7OsQ7BZCEQPbACmVJA.png" /></figure><p>If we look at our scenario from a broader perspective: The IoT Devices in our scenario have a system that runs many Kubernetes services and contains more than one pod in these services. We have a scenario to send metrics, reports, commands or any data from these services on the devices to our services in the cloud environment, or, conversely, to transfer some data from our services in the cloud to our devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*MB42ZRPxU8HD1232MnoK2Q.png" /></figure><h4>Technical Details of Architectural Design</h4><p>There are some technical details we need to consider when designing this architecture. We will discuss these details separately, discuss alternatives, and I will show how we can create the structure we need by proceeding through a design choice.</p><ul><li><strong>Authentication and Authorization</strong></li><li><strong>Message Format and Content</strong></li><li><strong>Publish Structure</strong></li><li><strong>Receiving Structure for Replica Services</strong></li><li><strong>IoT Core Rule Mechanism</strong></li></ul><h4>Authentication &amp; Authorization</h4><p>We can use a variety of authentication and authorization methods to enable our IoT devices to communicate securely with AWS IoT Core. One of these methods is certificate and key-based authentication, regardless of whether from the server or client. When the device or service is created, it is assigned a unique certificate and key, and these certificates are used in the IoT Core connection. However, due to some security measures, certificates may need to be renewed periodically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*Hm08yJNX-MMcJq9Ah5Bd6A.png" /></figure><p>Since a certificate-based connection structure requires managing certificates and extra functions on the device side, we prefer the “Custom Authentication &amp; Authorization” method, which is a different alternative.</p><h4><strong>Custom Authentication &amp; Authorization</strong></h4><p>The alternative solution we will prefer in this article is <strong>“Custom Authentication &amp; Authorization”</strong>. If there is an existing authentication structure in our system (for example, token or user-password), IoT Core can leave it up to us how this authentication mechanism should be done. In IoT Core, we can integrate our own authentication and authorization logic using AWS Lambda functions for authentication and authorization.</p><p><strong>How does it work?</strong></p><ol><li>The client sends the token or user-password information it will use during the connection and information indicating which Authorizer it will use.</li><li>With this information, the Authorizer Lambda function is automatically triggered.</li><li>Our logic in Lambda runs and if the verification is successful, a special policy is returned to this client and the connection is established successfully. Otherwise, the connection cannot be established.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*ouIkHZb9eSLI2XtvTfAunA.png" /></figure><p>In our scenario, the client service must pass four basic parameters during connection:</p><pre>clientId: &lt;deviceId&gt;/&lt;podId&gt; (clientId must be unique)<br>authKey: &lt;authorizer&gt; (name of Authorizer defined in IoT Core)<br>authValue: &lt;token&gt; (jwtToken to be received from the Auth service)<br>caCerts: &lt;rootCa.pem&gt; (AWS root certificate)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eyYYm2RnN6QtTKB_5NSCgw.png" /></figure><p>As can be seen from the diagram, each pod uses a similar connection structure with a unique clientId. After <strong><em>Authorizer </em></strong>Lambda verifies the token, it returns a special policy for the connection. This policy determines which resources the client can access on IoT Core. For example:</p><pre>{<br>  &quot;Action&quot;: &quot;iot:Connect&quot;,<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Resource&quot;: &quot;&lt;aws-arn&gt;:client/&lt;clientId&gt;&quot; // (for device123 and pod3 -&gt; clientId: device123/pod3)<br>}</pre><p>With this policy statement, we allow the client to connect to IoT Core.</p><h4>Flow Diagram of AuthLambda</h4><p>The simple flow diagram of the AuthLambda function shows how to authenticate and authorize the client during connection:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*67QZMJa0eZ9HQQVHeVGgrg.png" /></figure><p>As a result, with the Custom Authentication &amp; Authorization method, you can ensure that your IoT devices connect securely and flexibly with AWS IoT Core. This method simplifies integration and increases the security of your devices by using your existing authentication structure.</p><h4>Message Structure &amp; Publish Structure</h4><p>One of the main purposes of our scenario is to forward messages from services on our IoT devices to AWS IoT Core. There are several ways to retrieve these messages from services. It can establish a socket connection between the services and the client, set up an MQTT broker and listen to messages on certain topics, or the client contains a REST server and can receive messages via POST requests. In our scenario, our client service will establish a bidirectional socket connection with the other services. To briefly summarize, messages from the services will be directed to any client pod, and the pod receiving the message will forward it to IoT Core through its own connection.</p><h4>Message Structure</h4><p>First, let’s look at what message structure we should use. We will need to send and receive different types of messages bi-directionally through this channel we created with IoT Core. Basically we need two components: Type and Data.</p><p><strong>Data</strong>: The metric, data or command we want to send.<br><strong>Type</strong>: The type of data we want to send.<br>It may also be useful to include a <strong><em>requestId </em></strong>and <strong><em>timestamp </em></strong>in the message content to ensure traceability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*IVe0Dyf6SewlyU7EQDAIYQ.png" /></figure><h4>Publish Structure</h4><p>The client will send messages to IoT Core via its own topic. Let’s set the publish topic as follows: “<strong><em>mqtt/device/&lt;deviceId&gt;/send</em></strong><em>”</em>. We want each device to send messages on its own topic. This is important to ensure that messages are sent from specific topics. I will touch on this issue in the IoT Core Rule section.</p><p>To ensure that devices can only send messages to certain topics, we edit the policy as follows:</p><pre>{<br>  &quot;Action&quot;: &quot;iot:Publish&quot;,<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Resource&quot;: &quot;&lt;aws-arn&gt;:topic/mqtt/device/&lt;deviceId&gt;/send&quot;<br>}</pre><p>With this policy, we only allow devices to send messages to the specified topic. In this way, we control their access to resources on IoT Core.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0QEfHHhorg5yjIhTVXfWQ.png" /></figure><h4><strong>Receiving Structure for Replica Services</strong></h4><p>If the device will be considered as a group and only one of them needs to receive this message instead of the messages coming from the services going to all devices at the same time, we can use the <strong><em>shared subscription</em></strong> feature that comes with MQTT5. A message sent with a shared subscription is delivered to only one consumer. In this way, client-based load balancing is provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*Tb-pLCEb-KbQfHWv.gif" /><figcaption><em>Non-shared Subscriptions Flow</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*WVGrIdfljaKFRRRy.gif" /><figcaption>Shared Subscriptions Flow</figcaption></figure><p>In our scenario, we have a client service on our device that connects with IoT Core. This service has multiple replicas and all pods are connected to IoT Core. Messages coming to the device via IoT Core are expected to be consumed by only one client. The reason for this is to avoid executing the same command more than once or creating duplicate data if the incoming message is a command or data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*Dh1FvL87TFmHBq8Jqrw48A.png" /></figure><p>To elaborate for our scenario:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o5GVwVnPT6ZdSLUDEKnWrw.png" /></figure><p>Thanks to the share topic feature, any of the pods of our Client service <strong><em>(Round-Robin Algorithm)</em></strong> receives the message coming through IoT Core and transmits it to the relevant service via the socket connection.</p><p>We add the following statements to the policy so that the device can only listen to messages from a specific topic:</p><pre>{<br>  &quot;Action&quot;: &quot;iot:Receive&quot;,<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Resource&quot;: &quot;&lt;aws-arn&gt;:topic/mqtt/device/&lt;deviceId&gt;/receive&quot;<br>},<br>{<br>  &quot;Action&quot;: &quot;iot:Subscribe&quot;,<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Resource&quot;: &quot;&lt;aws-arn&gt;:topicfilter/mqtt/device/&lt;deviceId&gt;/receive&quot;<br>}</pre><h4>IoT Core Rule</h4><p>If you noticed, there is no information in the content of the message about which device it came from, there is no need for it. 🤨</p><p>With a rule we will write on the IoT Core side, we will add the deviceId to the content of the message after it reaches IoT Core. We can achieve this because IoT Core can distinguish which connection the message comes from. The main purpose of using it this way is that if the deviceId is included in the message, there is a risk of the message being manipulated. It will be more secure and integrity to detect who sent it directly from the connection. At this point, we jump into the IoT Core rule mechanism.</p><p>IoT Core Rule allows creating a set of rules and actions that process and route data from IoT devices. IoT Core Rule uses SQS queries, and operations such as filtering, transforming and forwarding messages can be performed with these queries. More comprehensive queries and rules can be written. Going back to our scenario, the messages coming from the topics will be directed to the relevant AWS service by making some manipulations. For messages coming from the topics where devices send messages, we will first add the deviceId to the content of the message at this stage and then define a rule to send it to the relevant service. Thus, we will be able to detect which device sent the message directly from the connection.</p><p><strong><em>SQL query for our scenario:</em></strong></p><pre>SELECT *, substring(clientId(), 0, indexof(clientId(), &quot;/&quot;)) as deviceId FROM &quot;mqtt/device/+/send</pre><pre>/*<br>  To elaborate the query;<br>  For messages coming from “mqtt/device/+/send” topics (such as mqtt/device/device123/send, mqtt/device/device456/send),<br>  it places the deviceId value from the clientId value into the message content.<br>*/<br><br>// In the scenario where ClientId: “device123/pod5”, the incoming message is:<br>{<br>  &quot;requestId&quot;: &quot;…&quot;,<br>  &quot;timestamp&quot;: &quot;…&quot;,<br>  &quot;type&quot;: &quot;…&quot;,<br>  &quot;data&quot;: &quot;…&quot;<br>}<br><br>// The final version of the message to be forwarded to the services:<br>{<br>  &quot;requestId&quot;: &quot;…&quot;,<br>  &quot;timestamp&quot;: &quot;…&quot;,<br>  &quot;type&quot;: &quot;…&quot;,<br>  &quot;data&quot;: &quot;…&quot;,<br>  &quot;deviceId&quot;: &quot;device123&quot;<br>}</pre><p>We have determined the SQL statement of our rule. As Action, it will be sufficient for us to send the incoming message to an SNS topic we have specified. More than one rule or more than one different type of action can be defined for different scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*ZBBdkiW8zmRFAEmbm9uw_Q.png" /></figure><p>Up to this stage, I have talked about the Authentication&amp;Authorization, Publish structure, Receive structure with the Shared Topic feature for replica pods, the Message content and IoT Core Rule structure. If we look at the general diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_K8vFrIR4jGHpjJpyndyg.png" /><figcaption><a href="https://github.com/furkanozev/IoTCoreMedium/blob/main/design.png">https://github.com/furkanozev/IoTCoreMedium/blob/main/design.png</a></figcaption></figure><p>We can direct messages coming from devices to IoT Core directly to an ECS, Lambda or other services of AWS. However, in our scenario, we want to filter incoming messages, we can use a structure like this:</p><ul><li>Let’s direct all incoming messages to the SNS topic.</li><li>Each service will subscribe to this SNS topic with its own queue and filter policy.</li><li>Thus, each service will access messages of its own specified type.</li></ul><p>With this article, I tried to share the architectural design of an IoT management scenario step by step. It was a long article🥱, I hope it was useful 🤓.</p><blockquote>You can review the sample client code written in Python and the sample policy in my repository:</blockquote><p><a href="https://github.com/furkanozev/IoTCoreMedium">GitHub - furkanozev/IoTCoreMedium: Basic sample client codes for IoT Core Medium Article</a></p><blockquote>SDKs for other languages: <a href="https://docs.aws.amazon.com/iot/latest/developerguide/iot-sdks.html">https://docs.aws.amazon.com/iot/latest/developerguide/iot-sdks.html</a></blockquote><blockquote>Custom authentication and authorization: <a href="https://docs.aws.amazon.com/iot/latest/developerguide/custom-authentication.html">https://docs.aws.amazon.com/iot/latest/developerguide/custom-authentication.html</a></blockquote><blockquote>Shared Subscription: <a href="https://aws.amazon.com/tr/blogs/iot/how-to-get-started-with-the-new-shared-subscriptions-in-aws-iot-core/">https://aws.amazon.com/tr/blogs/iot/how-to-get-started-with-the-new-shared-subscriptions-in-aws-iot-core/</a></blockquote><blockquote>IoT Core Rule: <a href="https://docs.aws.amazon.com/iot/latest/developerguide/iot-rules.html">https://docs.aws.amazon.com/iot/latest/developerguide/iot-rules.html</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*F1svsMEIsPU_hEjlJcbrLA.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4626c574b4aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>