<?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 Lee Harding on Medium]]></title>
        <description><![CDATA[Stories by Lee Harding on Medium]]></description>
        <link>https://medium.com/@lee.harding?source=rss-2a0f3dade5c0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VKepT5fMJyKwurBvbSTA4Q.jpeg</url>
            <title>Stories by Lee Harding on Medium</title>
            <link>https://medium.com/@lee.harding?source=rss-2a0f3dade5c0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 23:45:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lee.harding/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[If You Give a Dev a Server…]]></title>
            <link>https://medium.com/@lee.harding/if-you-give-a-dev-a-server-34eb8c754b45?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/34eb8c754b45</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Wed, 04 Mar 2026 17:22:46 GMT</pubDate>
            <atom:updated>2026-03-04T17:32:35.144Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A cautionary tale for cloud architects, in the tradition of Laura Numeroff</em></p><p>If you give a dev a server, they’re going to need somewhere to put it.</p><p>And if you’re putting it somewhere, you’ll need a <strong>VPC</strong>.</p><p>A VPC is simple enough. You pick a CIDR block, you carve up some address space, you convince yourself that /16 is probably overkill but you take it anyway because address space is cheap and hesitation is expensive.</p><p>Of course, once you have a VPC, you’ll need <strong>subnets</strong>.</p><p>And once you’re thinking about subnets, you’ll have to make a decision: <em>public, private, or both?</em></p><p>You’ll want both.</p><p>Public subnets for the things that need to be reachable. Private subnets for the things that definitely shouldn’t be — but definitely will be running software with a CVE discovered six months from now. You’ll need at least two of each for redundancy, and since you’re in us-east-1, why not use all six availability zones while you’re at it?</p><p>This is all fairly tedious. You’ll write some Terraform, argue briefly about whether the CIDR blocks should be /24 or /22, and settle it by asking someone more senior who will shrug and say &quot;just pick one.&quot; The good news is that VPCs and subnets are essentially <strong>free</strong>. This is the last time that word will appear in this story.</p><p>Once the network exists, the dev will ask for an <strong>Internet Gateway</strong>.</p><p>This is easy. One per VPC. You attach it, you update the route tables, done. The Internet Gateway itself costs nothing — you only pay for the data that flows through it, which feels fine for now.</p><p>You’ll also add some sensible security groups, because you’ve been burned before, and because the security team will ask.</p><p>When the dev asks for their instance to be able to make outbound calls — package updates, API requests, the occasional curl to a service that absolutely should have been mocked — you&#39;ll need a <strong>NAT Gateway</strong>.</p><p>A NAT Gateway sounds like a small thing. It is not a small thing.</p><p>A NAT Gateway costs <strong>$0.045 per hour</strong>, which is $32.40 a month before a single byte of traffic passes through it. Add data processing charges and you’ll find that your NAT Gateway costs more than your actual server. If you put one in each availability zone (and you will, because the alternative is a cross-AZ single point of failure, and you know how that story ends), multiply that number accordingly.</p><p>This is usually the moment someone opens a cost dashboard for the first time and makes a face.</p><p>When the dev asks for <strong>console access</strong> to the instance — and they will, because someone will need to debug something at 11pm that can only be diagnosed by being <em>on</em> the machine — you’ll reach for AWS Systems Manager Session Manager.</p><p>SSM is the right answer. No bastion host, no open port 22, no SSH key rotation headaches. Clean, auditable, lovely.</p><p>But SSM requires the instance to talk to AWS endpoints, and your instance is in a private subnet, so you’ll need <strong>VPC Endpoint Services</strong>. One for ssm. One for ssmmessages. One for ec2messages. Optionally one for ec2 itself.</p><p>Each interface endpoint costs $0.01 per hour per availability zone. It adds up quietly, the way all the best costs do.</p><p>Once the dev has access, they will use it.</p><p>They will look at the instance metrics and conclude that the server is <strong>too small</strong>. They’ll have numbers to back this up: p95 latency, memory pressure graphs, a particularly bad Tuesday where everything fell over. The instance type will be upgraded.</p><p>And while you’re in there, the storage will need to be bigger too. And faster. That gp2 volume was fine to get started, but honestly gp3 is both faster and cheaper per GB if you provision the IOPS right, so you&#39;ll do that while you&#39;re at it. This is actually a win. Enjoy it; they don&#39;t come often.</p><p>Someone in a planning meeting will say the word <strong>resilience</strong>.</p><p>This is how it starts.</p><p>Resilience means <strong>backups</strong>. You’ll enable automated EBS snapshots with a retention policy that someone will argue about for longer than it takes to implement. You’ll set up AWS Backup. You’ll document the recovery procedure that everyone agrees is important and no one will read until they need it, at which point they will discover it is subtly out of date.</p><p>You’ll also discuss RTO and RPO. You’ll set targets. You’ll feel good about this.</p><p>The resilience conversation leads naturally to the <strong>scale-out</strong> conversation.</p><p>A single instance, however large, is a liability. What happens when it needs patching? What happens during a traffic spike? What happens when you’re on vacation?</p><p>You’ll build an <strong>Auto Scaling Group</strong>.</p><p>An ASG requires a Launch Template, which requires an AMI strategy, which requires a discussion about golden images vs. user data scripts that will consume an entire afternoon. You’ll add a Load Balancer — Application, almost certainly — with its own target group, health checks, and listener rules.</p><p>And your ASG instances, being in private subnets, will need to reach SSM. Which means your three VPC endpoints need to be present in <em>every</em> availability zone you’re using now, not just one.</p><p>The endpoint costs, which were a rounding error before, become a line item.</p><p>Then someone will ask about <strong>Multicast</strong>.</p><p>Maybe it’s service discovery. Maybe it’s a real-time data distribution problem. Maybe it’s a legacy protocol from an on-premises system being lifted-and-shifted with too much fidelity. Whatever the reason, the ask is real: instances need to send packets to a multicast group.</p><p>EC2 does not do multicast natively. You’ll need a <strong>Transit Gateway</strong>.</p><p>A Transit Gateway costs $0.05 per hour for the gateway itself, plus $0.02 per GB of data processed. You’ll also need Transit Gateway attachments for your VPC, which cost $0.05 per hour each. And the multicast domain. And the group membership configuration.</p><p>At this point, if you add up what you’re spending — the instance, the storage, the NAT Gateways, the VPC endpoints across multiple AZs, the load balancer, the Transit Gateway — you are looking at roughly <strong>$300 per month</strong> for what began as “just a server.”</p><p><em>Deep breath.</em></p><p>Then someone will say: <em>“Our users in Europe are complaining about latency.”</em></p><p>This is the part where we talk about <strong>Global Accelerator</strong>.</p><p>Global Accelerator is a fine product. It routes traffic over AWS’s private backbone rather than the public internet, shaving meaningful milliseconds for users far from your primary region. It costs $0.025 per hour plus data transfer charges. You’ll add it.</p><p>But Global Accelerator just gets the packets to AWS faster. Once they arrive, they still need to go <em>somewhere</em>. For truly low global latency, you need <strong>compute in each region</strong>.</p><p>So you’ll repeat the process.</p><p>New region. New VPC. New subnets — public and private, multiple AZs. New Internet Gateway. New NAT Gateways (plural, for resilience). New VPC endpoints for SSM (three endpoints × three AZs). New Launch Template, new AMI in this region, new ASG. New load balancer. New Transit Gateway if you need multicast here too.</p><p>And then you’ll deal with <strong>inter-region data transfer</strong>. Data leaving one AWS region and entering another costs between $0.02 and $0.09 per GB depending on the regions involved, in both directions. If your instances are sharing state — a cache, a database, session data — those bytes are now crossing the planet repeatedly.</p><p>You’ll need to think about consistency. About latency-sensitive writes. About what happens when the us-east-1 region has an event (it will have an event) and traffic fails over to eu-west-1 and suddenly your replication lag matters very much.</p><p>You will add a global database.</p><p>This will not be cheap.</p><p>At some point — probably around the third or fourth region, or the second incident, or the first time someone tries to calculate the Total Cost of Ownership and sits quietly for a long moment afterward — someone will ask the question that should have been asked at the beginning:</p><p><em>Why are we doing this with servers?</em></p><p>The server made sense at the start. Familiar. Controllable. You could SSH in (or Session Manager in, after the endpoint setup). You knew what you had.</p><p>But what you have, now, is not a server. You have a <strong>distributed system</strong> spread across multiple regions, managed through a scaffolding of networking primitives, routing constructs, endpoint services, and replication agreements — each one reasonable in isolation, each one a dependency, each one a surface area for failure, each one a line on an invoice.</p><p>A server is not cheap. A server is an obligation.</p><p><em>Think carefully</em> before you give a dev a server.</p><p>Because if you give a dev a server, they’re going to need a VPC to go with it…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QlPAiU4ciY1CgIr3bQtC3g.png" /></figure><p><em>Dedicated to everyone who has ever said “we’ll just spin up a quick server.”</em></p><p><em>You know who you are.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34eb8c754b45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Year-Long Battery-Powered WiFi Temperature Sensor]]></title>
            <link>https://medium.com/@lee.harding/building-a-year-long-battery-powered-wifi-temperature-sensor-8b1d1f42542a?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b1d1f42542a</guid>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[sensors]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 02:38:33 GMT</pubDate>
            <atom:updated>2026-01-30T03:56:11.998Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>TL;DR:</em></strong><em> I built a battery-powered WiFi temperature sensor using ESP32-C3 that samples every 10 seconds, batches 30 readings, and transmits via UDP every 5 minutes. Aggressive power optimization (deep sleep, light sleep during sensor conversion, static IP caching) achieves ~139 mAh/month consumption. A 2500mAh 18650 battery should last well over a year. Code at </em><a href="https://github.com/mlhpdx/xiao-esp32c3-wifi-temp-sensor"><em>github.com/mlhpdx/xiao-esp32c3-wifi-temp-sensor</em></a><em>.</em></blockquote><p>I’ve been working on a side project that involves deploying temperature sensors at multiple sites where running power isn’t practical and where the only reliable connectivity is WiFi (no LoRa gateways, no Bluetooth hubs, just WiFi networks). As an unpaid project the constraints are tight: keep the hardware cheap and minimize maintenance (particularly onsite visits).</p><p>I’m not a professional when it comes to embedded systems work so I chose components with good documentation and a proven track record. The XIAO ESP32-C3 is power-efficient and WiFi-capable, the DS18B20 temperature sensor is ubiquitous and well-understood. The XIAO support LiPo charging, so a 18650 lithium battery would make sense. Not the cheapest combination, but one I felt confident I could make work.</p><h3>The Problem with Wifi</h3><p>WiFi is notoriously power-hungry. An ESP32-C3 draws around 180mA when actively transmitting versus 43µA in deep sleep. That’s 4,000 times more current. To wake up, connect to WiFi, authenticate, establish a TCP connection, send data, wait for acknowledgment, and disconnect every few minutes means a battery won’t last long.</p><p>The solution is theoretically obvious: minimize radio-on time as aggressively as possible. The implementation is all about the details.</p><p>Instead of sending each temperature reading individually I batch 30 samples (taken every 10 seconds over roughly 5 minutes) and send them as a single UDP packet. UDP was the right choice here since it allows a true “blind send” with no TCP handshake andno waiting for an acknowledgment. With UDP the device just transmits a single packet and immediately disconnects.</p><p>Another significant source of air time is DHCP. On the first send, the device uses DHCP and saves its IP configuration to RTC memory. On subsequent sends, it uses that cached configuration and connects in about 63ms instead of the 1–2 seconds DHCP requires. Combined with UDP’s fire-and-forget approach, the radio is only active for about 100ms every 5 minutes. This caching alone reduced WiFi power consumption by ~5x.</p><h3>Learning Sleep Modes</h3><p>Getting the sleep modes right reminded me of working with transactional memory in C++ two decades ago at Autodesk. The code needs to be carefully constructed to align with the rules about what state persists, what gets reset, and how to structure logic so the system can wake up and know where it left off (or reconstruct it).</p><p>The ESP32-C3 supports several sleep modes, but I use two: deep sleep and light sleep. Deep sleep consumes only 43µA but resets the chip completely on wake, including RAM. So all persistent state variables go into RTC memory, tagged with RTC_DATA_ATTR. I store the boot counter, network configuration, sensor address, and a buffer of 30 temperature samples there so they survice a deep sleep cycle.</p><p>Light sleep was a discovery that emerged from optimizing reading the sensor. The DS18B20 takes about 650ms to perform a temperature conversion with a blocking call. Then I found the sensor supports asynchronous mode where the conversion is started with a non-blocking call and the value can be retried later. So during that 650ms wait I put the ESP32 into light sleep at 800µA instead of keeping it fully active. That’s a 60x power reduction during the longest single operation in the wake cycle.</p><pre>// Start async temperature conversion<br>sensor.setWaitForConversion(false);<br>sensor.requestTemperatures();<br><br>// Light sleep during DS18B20&#39;s 650ms conversion<br>LIGHT_SLEEP(650 * 1000);<br><br>// Conversion complete, read the result<br>float temp = sensor.getTempCByIndex(0);</pre><p>But light sleep introduces its own complexity: GPIO states don’t persist by default. The DS18B20 needs continuous power during conversion, so I had to use GPIO hold (gpio_hold_en()) to lock the power pins in their states before sleeping. Without this, the sensor would lose power mid-conversion and return the error value of 85°C. This was one of those gotchas that only became clear through testing.</p><pre>// Power on sensor<br>digitalWrite(SENSOR_POWER_PIN, HIGH);<br>digitalWrite(SENSOR_GND_PIN, LOW);<br><br>// Hold GPIO states during light sleep<br>gpio_hold_en((gpio_num_t)SENSOR_GND_PIN);<br>gpio_hold_en((gpio_num_t)SENSOR_POWER_PIN);<br><br>// Now safe to light sleep - sensor stays powered<br>LIGHT_SLEEP(650 * 1000);<br><br>// Release holds after conversion complete<br>gpio_hold_dis((gpio_num_t)SENSOR_GND_PIN);<br>gpio_hold_dis((gpio_num_t)SENSOR_POWER_PIN);</pre><h3>Power Budgeting</h3><p>The power optimization plan evolved as I understood the system better, but eventually I needed to know if it would actually work and did the math. Here’s the breakdown for a typical temperature sampling cycle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*GJ96MKWq2vQ5KMr9CC3EgQ.png" /></figure><p>Every 30th cycle includes a WiFi transmission, adding this overhead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*9igzrRqN-MJZPbfFONBH8Q.png" /></figure><p>The WiFi cycle consumes about 2.5µAh total versus 0.5µAh for a regular cycle. Over a 30-sample batch (~5.3 minutes), that’s:</p><ul><li>29 regular cycles: 14.6 µAh</li><li>1 WiFi cycle: 2.5 µAh</li><li><strong>Total: 17.1 µAh per batch</strong></li></ul><p>Running continuously, that works out to roughly 139 mAh per month. A 3000 mAh 18650 battery should last about 21 months — well over the one-year target.</p><p>These are calculated numbers, though, not measured. The real-world results depend on actual current draws (which vary by chip and conditions), self-discharge rates, and temperature effects on battery capacity. But the math gives me confidence that the design is in the right ballpark.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*iJjksHkGtbFsUUI5A_Cypw.png" /></figure><p>Despite spending 93.6% of its time in deep sleep, the device consumes 43.7% of its power during brief active CPU periods. This is why minimizing wake and transmit time matters so much. Every millisecond the CPU is active costs ~1,000 times more than deep sleep.</p><h3>UDP is Efficient</h3><p>The packet structure is straightforward: 8 bytes for the DS18B20’s unique ID (so the backend can identify which sensor sent the data), 4 bytes for the sample count, and then 240 bytes of temperature data. The temperature data includes 30 pairs of floats, alternating between external (DS18B20) and internal (ESP32-C3) temperatures.</p><p>Total packet size: 252 bytes.</p><p>Binary encoding saves space and CPU time compared to JSON, and the backend can easily parse the fixed structure. I accept that some packets will be lost. Occasional packet loss for massive power savings is absolutely worth it.</p><h3>Gotchas</h3><p>The implementation has a few quirks worth noting. Since deep sleep resets the chip, there’s no traditional loop(). Everything happens in setup(), which reads temperatures, updates the sample buffer, increments the boot counter, and either goes back to sleep (boots 1-29) or transmits data (boot 30).</p><p>For debugging, I needed a way to observe the wake-sleep cycle without actually sleeping and losing the serial connection. That can be done using a UART adapter, but I decide to get clever. My approach is a DEBUG_MODE flag that conditionally compiles different versions of the sleep macros. In debug mode, DEEP_SLEEP() becomes delay() followed by goto RESTART, jumping back to the top of setup(). It&#39;s a bit of a hack, to be sure, but it lets me see the complete cycle in the serial monitor without the hardware actually sleeping.</p><p>I was suprised that in RTC memory arrays, the volatile keyword is required. Without it, compiler optimizations can corrupt array access across sleep cycles so reads and writes don&#39;t happen in the expected order. This caused data corruption until I tracked it down. Declaring the temperature sample buffer as RTC_DATA_ATTR volatile fixed it.</p><pre>// Wrong - compiler may optimize away array accesses<br>RTC_DATA_ATTR TemperatureSample temperatureSamples[SAMPLE_COUNT];<br><br>// Correct - volatile prevents optimization corruption<br>RTC_DATA_ATTR volatile TemperatureSample temperatureSamples[SAMPLE_COUNT];</pre><p>Finally, to prevent current leakage when the sensor is off, all three GPIO pins (power, ground, data) are set to INPUT mode (high-impedance) after each reading. Leaving them in OUTPUT or INPUT_PULLUP modes created a path for current to leak through the powered-down sensor.</p><h3>Will It Get There?</h3><p>Some of these sensors are deployed and operational. Early monitoring suggests the power budget is realistic, but only time will tell whether they actually last 3 months, 6 months, or the full year-plus the calculations predict. Battery self-discharge, temperature effects, network conditions, and a dozen other real-world factors will influence the outcome.</p><p>But the math is solid, the optimizations are proven, and the code is stable. I’m cautiously optimistic.</p><p>The complete source code is available on <a href="https://github.com/mlhpdx/xiao-esp32c3-wifi-temp-sensor">GitHub</a>, including all the details I’ve glossed over here: GPIO hold timing, RTC memory layout, the binary protocol spec, and the debug mode implementation.</p><p>If you’re building something similar, I hope this helps you avoid at least some of the gotchas I encountered.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b1d1f42542a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Real-Time HN Display for $15]]></title>
            <link>https://medium.com/@lee.harding/building-a-real-time-hn-display-for-15-3ea1772051ff?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ea1772051ff</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[udp]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 00:44:11 GMT</pubDate>
            <atom:updated>2026-01-21T00:44:11.043Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>TL;DR</strong>: I built a desk gadget that streams Hacker News comments to a cheap ESP32 display using UDP instead of HTTP/TLS. It works great, costs almost nothing to run, and proves that sometimes simple is more fun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wI1WuGgFBfob5GId0_YTuQ.jpeg" /><figcaption>Hacker News on a CYD. Talking emacs and LISP, of course. I did not scroll that wall of text.</figcaption></figure><p>As a whole developers have been conditioned to think that HTTP/TLS is the only “proper” way to build networked applications. But what if I told you there’s a simpler, cheaper, and <em>more fun</em> alternative for certain use cases?</p><p>I recently built a real-time Hacker News comment viewer that runs on a $15 ESP32 display. Instead of wrestling with TLS certificates, JSON parsing libraries, and HTTP client overhead, I used UDP tunneled through WireGuard. The entire protocol fits in a handful of bytes, and the serverless backend costs nearly nothing to run.</p><h3><strong>It’s a Cheap Yellow Display</strong></h3><p>The ESP32-based “Cheap Yellow Display” (CYD) has become a favorite in the maker community. For about $15 on AliExpress, you get:</p><ul><li>ESP32 dual-core processor with WiFi</li><li>2.8&quot; color touchscreen (320x240)</li><li>Resistive touch controller</li><li>Ambient light sensor (LDR)</li><li>A few exposed general-purpose input/output (GPIO) pins</li></ul><p>It’s a perfect little toy for desk widgets, sensor displays, and IoT projects. The hardware is surprisingly capable and more than enough to render HN comments in real-time.</p><h3><strong>The Problem with HTTP on IoT Devices</strong></h3><p>Most IoT tutorials will tell you to use an HTTP client library to fetch data from APIs. For Hacker News, that means:</p><ol><li>Establish TCP connection (handshake overhead)</li><li>Perform TLS handshake (certificate validation, crypto negotiation)</li><li>Send HTTP request with headers</li><li>Parse HTTP response with headers</li><li>Extract JSON body</li><li>Parse JSON (allocate memory for nested structures)</li><li>Close connection (or manage connection pooling)</li></ol><p>For a simple “give me the next comment” request, this is a little over-the-top, so to speak. Kilobytes of code, certificate management, memory allocation for JSON parsing, and dealing with connection timeouts. And that doesn’t even get into the power consumption (a topic for a different day).</p><p>The ESP32 can handle all of the overhead of REST over TLS, but it’s a lot of moving parts for something so conceptually simple.</p><h3><strong>Enter UDP: Protocol Design Isn’t Always Hard</strong></h3><p>The “U” is for “User” not “Unreliable”. UDP gets a bad rap because it doesn’t guarantee delivery at the transport layer. And every message is important, right? Critical even? No.</p><p>The lack of a delivery guarantee doesn’t mean UDP-based protocols can’t be reliable, it just means reliability is a choice, not a mandate.</p><p>Consider this use case:</p><ul><li>I want the latest HN comment (one at a time)</li><li>The client tracks the last item ID it received</li><li>Each request includes that ID, so the server knows what to send next</li><li>If a packet is lost (request or response), the next poll picks up where we left off</li><li>No comments are skipped, no data is lost</li></ul><p>This is “eventually reliable” without any TCP overhead. The protocol achieves reliability through trivial state management, not through retransmission timers and congestion control.</p><h4><strong>The Protocol</strong></h4><p>My entire protocol specification is:</p><p><strong>Request</strong> (4 bytes):</p><pre>[last_item_id: uint32]</pre><p><strong>Response</strong> (~100–800 bytes):</p><pre>[item_id: uint32][author_len: uint8][author: string][0x00][text: string]</pre><p>That’s it. No headers, no JSON, no TLS. The entire exchange fits in a single MTU-sized packet in each direction. And, yes, the length and null byte are redundant.</p><h3><strong>But, but… PRIVACY!</strong></h3><p>This is where WireGuard enters the picture.</p><p>Instead of bolting TLS onto every application protocol (HTTP, MQTT, CoAP, etc.), what if we secure the <em>network layer</em> once and then use simple protocols on top?</p><p>WireGuard is:</p><ul><li><strong>Simple</strong> — Written in ~4,000 lines of code (OpenVPN is 100,000+)</li><li><strong>Fast</strong> — Single round-trip Handshakes, designed to be efficient in software</li><li><strong>Secure</strong> — Uses modern crypto (ChaCha20, Poly1305, Curve25519)</li><li><strong>Built-in</strong> — Kernel module on Linux, library for ESP32</li></ul><p>On the CYD, the ESP32 establishes a WireGuard tunnel on boot, and then all UDP traffic goes through it. The VPN handles:</p><ul><li>Encryption</li><li>Authentication</li><li>NAT traversal</li><li>Private IP addressing</li></ul><p>Now I can use dumb… eh, simple protocols with confidence. This use case is so simple I don’t need routing on the backend at all — unless a packet is heading to port 123 (NTP) I handle it as a “next comment” request.</p><h3><strong>The Serverless Backend</strong></h3><p>The backend for the display is an AWS Lambda function written in C# (.NET 10 with Native AoT compilation). It’s triggered by UDP packets via <a href="https://www.proxylity.com/">Proxylity UDP Gateway</a>, a service that lets Lambda functions handle UDP traffic.</p><p>Here’s the flow:</p><pre>ESP32 → WireGuard → Proxylity → Lambda → HN Firebase API</pre><p>The Lambda:</p><ol><li>Receives a UDP packet with the last item ID</li><li>Fetches the next item from https://hacker-news.firebaseio.com/v0/item/{id + 1}.json</li><li>Converts HTML to Markdown</li><li>Transliterates Unicode to ASCII (for display compatibility)</li><li>Packs it into a binary UDP response</li><li>Returns it through the same WireGuard tunnel</li></ol><p><strong>Cold start time</strong>: ~100ms</p><p><strong>Execution time</strong>: ~60ms</p><p><strong>Cost</strong>: Within AWS free tier, or less than $0.45 otherwise</p><p>Compare that to running an always-on HTTP server! Oh, yeah, one of those can be free on AWS, too.</p><h3><strong>Why this is Fun</strong></h3><p>This architecture brings me joy because it aligns with the use case:</p><ol><li><strong>Stateless is Sublime</strong></li></ol><p>There is no connection state here to manage. Each UDP packet is independent, so if the Lambda crashes the next packet just spawns a execution. No cleanup, no connection pools, no lingering state.</p><p><strong>2. No Drama Reliability</strong></p><p>The client always sends the last ID it received. Missed packets don’t cause data loss — the next poll picks up where it left off. This is reliability without overhead.</p><p><strong>3. Simple Parsing</strong></p><p>No JSON parsing on the ESP32 (not much in the way of parsing at all). No memory allocation for nested objects. Just read some bytes, display some strings. The protocol is so simple I could parse it in assembly (I say having never tried).</p><p><strong>4. Privacy without Pain</strong></p><p>By encrypting the tunnel (WireGuard), every protocol on top is automatically secure. I don’t need to implement TLS in the application layer. I don’t need to manage certificates. The VPN handles it.</p><p><strong>5. Cheap</strong></p><p>The backend scales to zero when not in use. Turning off the display puts the backend to sleep (zero cost), too. No servers to patch, no infrastructure to maintain.</p><h3><strong>The Developer Experience</strong></h3><p>Writing this was <strong>fun</strong>. The kind of fun that comes from removing complexity, not adding it, and moving fast.</p><p>The ESP32 code is ~500 lines of C++, and most of that is UI rendering with LVGL. The networking code? About a dozen lines:</p><pre>void send_udp() {<br>  Udp.beginPacket(remote_vpn_ip, remote_vpn_port);<br>  Udp.write((uint8_t*)&amp;last_item_id, sizeof(last_item_id));<br>  Udp.endPacket();<br>}<br><br>void receive_udp() {<br>  while ((c = Udp.parsePacket()) &gt; 0) {<br>    int l = Udp.read(buffer, min(c, 1024–1));<br>    uint32_t item_id = *(uint32_t*)buffer;<br>    char* author = buffer + 5;<br>    char* text = author + buffer[4];<br>    lv_label_set_text_fmt(text_label, &quot;*%s*\n%s&quot;, author, text);<br>  }<br>}</pre><p>No JSON libraries. No HTTP client abstractions. No certificate pinning. Just bytes out, bytes in, pixels on.</p><p>Backend deployment iterations? One line: sam build &amp;&amp; sam deploy.</p><p>Fine. It’s two lines and takes a few seconds. But that’s some pretty low impedance on a backend deploy.</p><p>You might be thinking: “But UDP doesn’t guarantee delivery! Won’t you lose comments?”</p><p>No. It just works. Here’s how:</p><p>The ESP32 keeps track of the last item ID it successfully received (using `0` when first booted). Every request includes this ID. So:</p><ul><li><strong>Lost request?</strong> The next poll (10 seconds later) sends the same ID again.</li><li><strong>Lost response?</strong> The next poll sends the same ID, server sends the same comment.</li><li><strong>Server crash?</strong> Next request spawns a new Lambda with no state loss.</li><li><strong>Duplicates?</strong> No problem, they end-up as no-ops.</li><li><strong>Reordered responses?</strong> Shh. Nothing to see here.</li></ul><p>No comments are ever skipped. The protocol is <strong>eventually reliable</strong> by design.</p><h4><strong>The Right Constraints</strong></h4><p><strong>MTU-Limited Message Size</strong>: UDP packets cap at ~1500 bytes. This aligns with the display’s capabilities, since it can only show ~800 characters anyway. The constraint matches the use case.</p><p><strong>No Ordering Guarantees</strong>: Each packet is self-contained with an item ID. Out-of-order delivery very unlikely in this sequential polling model, but even if it happens the result is just repeating an older message and then catching up again.</p><p><strong>Single Point of Failure</strong>: The device is indeed singular. Everything else is or can be made multi-homed since it’s stateless and serverless. If I had a fleet of these displays, that’s what I’d do.</p><p>T<strong>hese aren’t limitations to work around — they’re constraints that simplify the design</strong>.</p><h3><strong>Should You Use UDP?</strong></h3><p>Yes. But I’m not suggesting UDP for everything. Maybe consider it when having a little fun or when:</p><ul><li><strong>State is unnecessary</strong> — Each request is independent</li><li><strong>Loss is acceptable</strong> — Missing data doesn’t break the experience</li><li><strong>Latency matters</strong> — Fresh data is better than all data</li><li><strong>Simplicity is valuable</strong> — Easier to implement and debug</li><li><strong>Resources are constrained</strong> — Embedded devices, IoT sensors, thin pipes</li></ul><p>Examples:</p><ul><li>Edge Sensor data streaming</li><li>Real-time feeds (weather, stock tickers, news)</li><li>Game state updates</li><li>Voice/video calls</li><li>Monitoring/logging</li><li>Long-range, unreliable communications</li></ul><h3><strong>Postscript</strong></h3><p>This project started on a whim: “What if I streamed HN over UDP?”</p><p>It ended up being an enjoyable build and throwback to a simpler kind of development that brought back the joy of tinkering. It’s not complex or impressive, but it’s simple and a good fit for the use case (and I do enjoy watching the opinions fly by).</p><p>For those who want to dig deeper, this project is open source:</p><ul><li><strong>GitHub</strong>: <a href="https://github.com/mlhpdx/hacker-news-cyd">github.com/mlhpdx/hacker-news-cyd</a></li></ul><p>What you’ll need:</p><ul><li>ESP32–2432S028R (or similar Cheap Yellow Display, ~$15-$20)</li><li>AWS account with Proxylity UDP Gateway subscription (Lambda free tier, Proxylity free tier)</li></ul><p>Total cost: <strong>**~$15-$20 to start, ~$0/month to run**</strong></p><p><strong>Software Stack</strong></p><p><strong>ESP32 Firmware</strong> (PlatformIO):</p><ul><li>Arduino framework</li><li>LVGL 9.3 for GUI</li><li>WireGuard-ESP32 library</li><li>TFT_eSPI display driver</li></ul><p><strong>Lambda Backend</strong> (.NET 10):</p><ul><li>Native AOT compilation (~10MB custom runtime binary)</li><li>Proxylity UDP Gateway SDK</li><li>PacketDotNet for UDP manipulation</li><li>Html2Markdown for content conversion</li><li>AWS SAM/CloudFormation</li></ul><p><strong>Performance Metrics</strong></p><ul><li><strong>Packet size</strong>: 4 bytes request, 100–800 bytes response</li><li><strong>Latency</strong>: ~300ms round trip (WiFi → WireGuard → Lambda → HN API → back)</li><li><strong>Polling interval</strong>: 10 seconds</li></ul><p><strong>Security Model</strong></p><ul><li><strong>Encryption</strong>: WireGuard (ChaCha20-Poly1305)</li><li><strong>Authentication</strong>: Pre-shared keys (Curve25519)</li><li><strong>Exposure</strong>: Device not reachable from internet, backend firewalled</li></ul><p><strong>Future Enhancements?</strong></p><ul><li>Interactivity. We needs buttons.</li><li>Battery mode? Save those electrons, they aren’t making new ones you know. Wait…</li></ul><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ea1772051ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fun with Code for Pricing Tiers]]></title>
            <link>https://medium.com/@lee.harding/fun-with-code-for-pricing-tiers-06aad6ff28c5?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/06aad6ff28c5</guid>
            <category><![CDATA[pricing]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[b2b]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 22:12:22 GMT</pubDate>
            <atom:updated>2024-11-22T16:10:15.891Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m thinking about pricing today, and focusing-in on usage-based tiered pricing. Let’s look at some code, since that’s my jam.</p><p>Tiered pricing just means that there are different prices to a service, so step one is to give them some numbers:</p><pre>var tiers = new[] {<br>  1.15,<br>  1.0,<br>  .85,<br>  .70,<br>  .55,<br>  .40<br> };</pre><p>I should explain that in usage-based pricing the price is generally understood to be the <em>unit price</em>. And, from past experience as a customer and vendor, the expectation is that the unit price decreases as usage amounts increase.</p><p>I’m also presuming “usage” to be based on some kind of measurable value. For this exercise let’s assume it’s a scalar (single) value and not a vector (which would be an interesting follow-up, perhaps).</p><p>So price will be a function of usage and tiers:</p><pre>double calculate_price(double[] tiers, int usage) {<br>  // use tiers and usage to calculate price somehow...<br>}</pre><p>Making usage an int means it has discrete values. That’s arbitrary, and perhaps a bad choice for gas stations, but it makes some sense in SaaS where users, bytes, API calls and time are generally treated as discrete values (time being partitioned to the month, day, or even millisecond).</p><p>The most basic algorithm for the price function is to lookup the unit price in the tiers and multiply:</p><pre>int tier = Math.Max(0, Math.Min(tiers.Length - 1, /* lookup function */));<br>var price = tiers[tier] * usage;</pre><p>Let’s look at some options for lookup functions.</p><h4>Constant Tier Size</h4><p>In this case we define a constant amount of usage in each tier and divide by that number in the mapping function:</p><pre>int tier_size = 10;<br>int tier = Math.Max(0, Math.Min(tiers.Length - 1, usage / tier_size));<br>var price = teirs[tier] * usage;</pre><p>As this is coded, the prices in tiers are understood to be the price “up to” the size of the tier. The first tier then puts the price at $1.15 for zero to tier_size units of usage, and the second covers from tier_size + 1 to tier_size * 2. The last tier price covers all usage above tier_size * (tiers.Length — 1).</p><h4>Variable Tier Size</h4><p>Here the sizes for each tier are set by defining the “top” of each tier alongside the tier prices, excluding the last to allow for unbounded usage (as it is in my world):</p><pre>var tier_tops = new[] {<br>  25,   //      0-25<br>  50,   //     26-50<br>  100,  //    51-100<br>  1000, //  101-1000<br>  5000  // 1001-5000<br>  // &gt; 5000, no entry for the last tier<br>};<br>var tier = 0;<br>while (tier &lt; tier_tops.Length &amp;&amp; usage &gt; tier_tops[tier]) tier++; <br>var price = tiers[tier] * usage;</pre><p>That’s certainly more flexible, but also more complicated and prone to human error (appropriateness of tier sizes, matching length of arrays).</p><h4>Exponential Tier Sizes</h4><p>Defining tiers as being a multiple of the tier below is fairly common, and has the benefit of providing “volume discounts” over a wide range of usage amounts. In this approach the “base” is needed to define the tier sizes and the “exponent” is implicitly the index of the tier:</p><pre>var tier_base = 10;<br>var tier_tops = Enumerable.Range(1, tiers.Length - 1)<br>  .Select(i =&gt; (int)Math.Pow(tier_base, i)).ToArray();<br>// ..same as above</pre><p>The values for tier_tops given the code above end-up being:</p><pre>10,<br>100,<br>1000,<br>10000,<br>100000</pre><h3>Problems at the Top</h3><p>So far the algorithm for calculating the price has been to pick a single unit price from the tiers and apply that to the entire usage. That’s simple to explain, simple to code and common in practice. Unfortunately it has an ugly flaw that shows up when usage crosses-over the top of a tier. We can demonstrate that:</p><pre>var just_below = calculate_price(tiers, 1000);<br>var just_above = calculate_price(tiers, 1001);<br>Console.Out.WriteLine($&quot;At 1000: {just_below}, at 1001: {just_above}&quot;);</pre><p>The output is:</p><pre>At 1000: 850, at 1001: 700.6999999999999</pre><p>So increasing usage by just one unit dropped the total price significantly. That’s not good, and might explain why some companies require buyers to commit to a certain tier.</p><h3>Cumulative Tiers</h3><p>One way to avoid the “top” problem above, is to partition usage into the tiers and calculate the total price from the products of the tier unit prices and the partition usage:</p><pre> double price = 0.0;<br> int remaining = usage;<br> int previous_top = 0;<br> for (int tier = 0; tier &lt; tier_tops.Length; ++tier) {<br>  var tier_size = tier_tops[tier] - previous_top;<br>  var usage_in_tier = Math.Max(0, Math.Min(remaining, tier_size));<br>  var price_of_tier = tiers[tier] * usage_in_tier;<br>  previous_top = tier_tops[tier];<br>  price += price_of_tier;<br>  remaining -= usage_in_tier;<br> }<br> price += remaining * tiers.Last();</pre><p>And now the output for the just above and below code is more sensible, with the price increasing slightly when one unit of usage is added:</p><pre>At 1000: 866.5, at 1001: 867.2</pre><p>For a visual, here are the curves for total price for the basic and cumulative methods with exponential tiers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*5j0N4m-pCb2WigAiLEbD7g.png" /><figcaption>The impact of simple lookup of unit price vs. using cumulative tiers in overall price.</figcaption></figure><p>Yeah, as a vendor I definitely like that cumulative curve better. The “drops” in price become increasingly impactful to revenue as the amount of customer usage increases. That kind of “surprise” is painful (I quote it because it shouldn’t be a surprise at all).</p><h3>My Take Away</h3><p>Cumulative tiers sound complicated, and do involve a bit more code, but are probably less so than the policy and contract shenanigans companies sometimes use instead.</p><p>So while I respect the perspective of people warning me away from them, I’m going to use cumulative tiers and bear the extra work of explaining why (starting with this article).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06aad6ff28c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Global Accelerator Quick Start]]></title>
            <link>https://medium.com/@lee.harding/aws-global-accelerator-quick-start-a8724bee34b7?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8724bee34b7</guid>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[global-accelerator]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Mon, 21 Oct 2024 15:37:41 GMT</pubDate>
            <atom:updated>2024-10-21T15:37:41.060Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS <a href="https://aws.amazon.com/global-accelerator/">Global Accelerator</a> (GX) brings to IP addresses the magic that latency-based DNS records used by CDNs bring to domains. Unfortunately, not many developers are familiar with GX and the non-trivial setup is a barrier to entry. This article provides a <a href="https://github.com/mlhpdx/cloudformation-examples">CloudFormation template</a> and background information as a quick way to start learning and experimenting with GX.</p><h4>Why use Global Accelerator?</h4><p>AWS provides descriptions of GX in the forms of <a href="https://aws.amazon.com/global-accelerator">marketing</a> and <a href="https://docs.aws.amazon.com/global-accelerator/">technical</a> documentation. I’m not going to repeat those here. Rather, this is my (hopefully practical) perspective.</p><p>Developers generally understand the concept of Content Delivery Networks (CDNs) like AWS CloudFront and Cloudflare, and use them routinely in projects. When asked why, they might say something like:</p><blockquote>“A CDN puts my content closer to the end-user to improve response times.”<br> — mainstream developers</blockquote><p>The case for GX is similarly simple, and I might describe it as:</p><blockquote>“GX puts IP address-based services closer to users and improves latency.” <br> — the author</blockquote><p>In both cases, there is more to the answers but each provides a solid start. And, each answer reflects the same goal: to provide better, faster, and more reliable client/customer experiences. The main different is at the client — does it know your domain name and use DNS, or does it only know an IP address?</p><p>Previously, I’ve demonstrated how simple it is to implement latency-based DNS lookups (like CDNs do) in my article about <a href="https://medium.com/@lee.harding/how-to-be-an-email-deadbeat-b3e4071ef600">setting-up email delivery in AWS SES</a>. But the reality is that many legacy services still don’t support DNS well enough to make use of that approach. And, to be clear it isn’t that such software <em>can’t</em> use domain names, it’s just that they <em>don’t</em>.</p><p>I’ll pick on FreeRADIUS since I have a lot of recent experience with it, but the same is true for other network service software. For a long time FreeRADIUS intentionally didn’t support DNS lookups for downstream connections at all, then it did but only when the configuration file was first loaded (and never again for as long as the service was running). To this day it still ignores the TTL of the records, using an arbitrary refresh interval. So if you give FreeRADIUS the domain name of a downstream server and hope it will notice when you do a blue-green deployment that swaps A records, you’ll be disappointed.</p><p>The solution is using GX, where I can give FreeRADIUS an IP address and have fine-grained control over how traffic to it is routed to my backends. I can do my blue-green deployments. I can provide responses from backends that are geographically close and have the lowest latency. I can failover to other backends when things go wrong in a region.</p><p>If you have legacy network software (or hardware) in your stack that requires IP addresses for downstream services, or that doesn’t support DNS as it should, looking into GX might just make sense.</p><h4>Setting-up Global Accelerator</h4><p>Any AWS service that includes “global” in the name comes with some complexity to manage — Global Accelerator is no exception. To help jump-start your experience with GX, I’ve <a href="https://github.com/mlhpdx/cloudformation-examples/tree/master/global-accelerator">provided an example</a> in GitHub that sets-up a triplet of functioning accelerators with backends across three regions. The three main concepts of GX are:</p><ul><li>Accelerators, which provide IP anycast IP addresses. These resources can be deployed in any region, but have region-agnostic ARNs (a somewhat similar pattern to IAM resources).</li><li>Listeners, which are the ports on which TCP and/or UDP traffic for the IPs on the associated Accelerator can be routed. Listeners are also global resources.</li><li>Endpoint Groups (EPGs) contain backends for Listeners and are similar to Target Groups for load balancers. These resources are global as well, but are intrinsically associated with a region — a bit odd in the AWS world. When deploying IaC, EPGs can be created in the same template as the Accelerator, but I prefer to separate them into a regional template where they can be managed alonside the backends (an EC2 in the sample).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YBW4-CG78Xq8y37zx3kp6A.png" /><figcaption>Accelerator and Listener resources are global in GX, but Endpoint Groups are best treated as “regional” along with the backends connected to them (EC2 instances here). This reflects how GX delivers value, but complicates deploying and updating them with IaC.</figcaption></figure><p>To make the example closer to the “real world” it creates three GX Accelerators, each supporting multiple listeners over different TCP and UDP ports. But to keep things simple (and inexpensive to experiment with), all of the listeners route traffic to a single EC2 instance in each region that does nothing more than echo the region in response to requests (how we’ll know which we reached).</p><p>The configuration of the example is controlled by JSON files imported into the templates mappings section with Fn::Include and expanded into resources using Fn::ForEach. This is a nice simplification overall since it makes maintenance an “edit once, change everywhere” activity, with just a little extra complexity in the templates.</p><p>Accelerators and Listeners can be added or removed by making changes to the configuration file, as can the DNS names assigned to them and which regions are enabled for each. See the repo for more details.</p><h4>Deploying the Example</h4><p>I’ve made it as easy as possible to deploy, but if you want details of the options available see the Readme.md file in the repo.</p><pre>./deploy.sh</pre><p>It will take a few minutes, but when it completes we have Accelerators to play with.</p><h4>Exploring the Global Accelerators</h4><p>The repo provides a script, test.sh, that sends some simple requests to confirm everything is working:</p><pre>&gt; ./test.sh<br>Testing GX A:<br>Testing port 80 on 13.248.140.198<br> - Command: ncat 13.248.140.198 80<br> - Result: us-west-2<br>Testing port 80 on 3.33.201.36<br> - Command: ncat 3.33.201.36 80<br> - Result: us-west-2<br>...snip...<br>Testing port 3799 on 35.71.147.54<br> - Command: ncat 35.71.147.54 3799<br> - Result: us-west-2<br>Testing port 2083 on 75.2.58.229<br> - Command: ncat 75.2.58.229 2083<br> - Result: us-west-2<br>Testing port 2083 on 35.71.147.54<br> - Command: ncat 35.71.147.54 2083<br> - Result: us-west-2</pre><p>The test above was run from a location in Oregon, and as expected reached the EC2 instance in us-west-2. When you run the test, you will have different IPs and may see any of the three regions depending on where you are in the world (just as you would hit a different “point of presence” when accessing CDN hosted website content).</p><p>If you have a VPN that supports exit locations you can test that traffic flows to the closest GX endpoint group (in this case an EC2 instance in the “closest” of the three regions) when making connections from around the world. Note that the third Accelerator (“C”) isn’t created in eu-west-1 per the RegionConditionals section of the global config. So if you test one of its IPs from a location in Europe you will still reach one of the US based instances.</p><p>If you don’t have a VPN, CloudShell in the AWS console can be used to test from different locations as well. First, open the AWS console and start CloudShell (it’s a link at the bottom-left of every service page):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*ETG2avN3PmPtU_TH5rifbQ.png" /><figcaption>Start CloudShell by clicking the link in the lower-left of the AWS console.</figcaption></figure><p>After a bit you should have a console window at the bottom of the page. This console is “resident” in the currently-selected AWS region, so by switching regions we can test from different “client” locations. To test, you’ll need nc or ncat, which can be installed as part of the nmap package:</p><pre>sudo yum -y install nmap</pre><p>Now just copy and paste the ncat commands with IP addresses and ports from the output of test.sh to CloudShell, then change regions and repeat (including installing nmap):</p><pre>$ ncat &lt;IP for GX C here&gt; 3799<br>eu-west-1</pre><h4>Cleaning-up</h4><p>Some of the resources in the example have time-based costs (EC2s, GXs). So, once you’ve finished exploring the example the stacks can be cleaned-up with:</p><pre>./cleanup.sh</pre><p>Note that the clean-up process is serial, and will take several minutes.</p><p>And that’s it. I hope this example is useful. Again, the repo with <a href="https://github.com/mlhpdx/cloudformation-examples/tree/master/global-accelerator">the example</a> can be found on GitHub.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8724bee34b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API Gateway Proxy to Lambda with Headers]]></title>
            <link>https://medium.com/@lee.harding/api-gateway-proxy-to-lambda-with-headers-5d8e73fa4dcb?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d8e73fa4dcb</guid>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Mon, 14 Oct 2024 19:07:10 GMT</pubDate>
            <atom:updated>2024-10-15T14:17:20.011Z</atom:updated>
            <content:encoded><![CDATA[<h3>API Gateway to Lambda with Headers</h3><p>The HTTP protocol has a rich set of headers but supporting anything more than the most common with API Gateway and Lambda requires a little extra effort when using the Serverless Application Model (SAM).</p><p>Here is what works (and a bit of what doesn’t).</p><h3>The Range Header, for Example</h3><p>One of my favorite HTTP headers is Range, which allows clients to request a subset of a resource. For example, having the server send just a few bytes of a large file rather than the entire contents.</p><p>I’ve written about how using Range with S3 can <a href="https://medium.com/circuitpeople/random-access-seekable-streams-for-amazon-s3-in-c-bd2414255dcd">increase performance by an order of magnitude</a>. For clarity, here is a fresh example of an HTTP request for only the first 256 bytes of a resource:</p><pre>GET /resource HTTP/1.1<br>Host: somedomain.tld<br>Range: bytes=0-255</pre><p>Similarly, I like to provide support for Range in my APIs to allow clients to optimize their network use. Exactly how that works is the subject of another article; here I’m going to focus just on how to get the “plumbing” setup.</p><h3>What Doesn’t Work</h3><p>A typical SAM template with an API Gateway and Lambda Function might be as simple as:</p><pre>{<br>  &quot;AWSTemplateFormatVersion&quot;: &quot;2010-09-09&quot;,<br>  &quot;Transform&quot;: &quot;AWS::Serverless-2016-10-31&quot;,<br>  &quot;Globals&quot;: {<br>    &quot;Function&quot;: {<br>      &quot;MemorySize&quot;: 1024,<br>      &quot;Runtime&quot;: &quot;dotnet6&quot;,<br>      &quot;Timeout&quot;: 10,<br>      &quot;Tracing&quot;: &quot;Active&quot;<br>    }<br>  },<br>  &quot;Resources&quot;: {<br>    &quot;Api&quot;: {<br>      &quot;Type&quot;: &quot;AWS::Serverless::Api&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;StageName&quot;: &quot;prod&quot;<br>      }<br>    },<br>    &quot;Handler&quot;: {<br>      &quot;Type&quot;: &quot;AWS::Serverless::Function&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;CodeUri&quot;: &quot;.&quot;,<br>        &quot;Handler&quot;: &quot;Handler::Handler.Function::FunctionHandler&quot;,<br>        &quot;Events&quot;: {<br>          &quot;Root&quot;: {<br>            &quot;Type&quot;: &quot;Api&quot;,<br>            &quot;Properties&quot;: {<br>              &quot;RestApiId&quot;: {<br>                &quot;Ref&quot;: &quot;Api&quot;<br>              },<br>              &quot;Path&quot;: &quot;/resource&quot;,<br>              &quot;Method&quot;: &quot;POST&quot;<br>            }<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>With that simple setup, the Lambda function receives a structured object representing the HTTP request. The request object contains the path, headers, body and other metadata and the implementation can make use of those values. In this case, we’re just going to echo the request object in the response:</p><pre>public class Function<br>{<br>  public async Task&lt;APIGatewayProxyResponse&gt; FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)<br>  {<br>    return new()<br>    {<br>      StatusCode = (int)HttpStatusCode.OK,<br>      IsBase64Encoded = false,<br>      Body = JsonSerializer.Serialize(request)<br>    };<br>  }<br>}</pre><p>Using curl we can now test to see what a request looks like to the Lambda:</p><pre>curl https://{api_id}.execute-api.{region}.amazonaws.com/prod/resource</pre><p>The response text contains the JSON representation of what the Lambda function received (snipped and redacted):</p><pre>{<br>  &quot;Resource&quot;: &quot;/resource&quot;,<br>  &quot;Path&quot;: &quot;/resource&quot;,<br>  &quot;HttpMethod&quot;: &quot;GET&quot;,<br>  &quot;Headers&quot;: {<br>    &quot;Accept&quot;: &quot;*/*&quot;,<br>    &quot;CloudFront-Forwarded-Proto&quot;: &quot;https&quot;,<br>    &quot;CloudFront-Is-Desktop-Viewer&quot;: &quot;true&quot;,<br>    &quot;CloudFront-Is-Mobile-Viewer&quot;: &quot;false&quot;,<br>    &quot;CloudFront-Is-SmartTV-Viewer&quot;: &quot;false&quot;,<br>    &quot;CloudFront-Is-Tablet-Viewer&quot;: &quot;false&quot;,<br>    &quot;CloudFront-Viewer-ASN&quot;: &quot;7xx2&quot;,<br>    &quot;CloudFront-Viewer-Country&quot;: &quot;US&quot;,<br>    &quot;Host&quot;: &quot;abc123.execute-api.us-north-3.amazonaws.com&quot;,<br>    &quot;User-Agent&quot;: &quot;curl/7.68.0&quot;,<br>    &quot;Via&quot;: &quot;2.0 abc123.cloudfront.net (CloudFront)&quot;,<br>    &quot;X-Amz-Cf-Id&quot;: &quot;aaaaaaa==&quot;,<br>    &quot;X-Amzn-Trace-Id&quot;: &quot;Root=1-abc123&quot;,<br>    &quot;X-Forwarded-For&quot;: &quot;1.2.3.4, 5.6.7.8&quot;,<br>    &quot;X-Forwarded-Port&quot;: &quot;443&quot;,<br>    &quot;X-Forwarded-Proto&quot;: &quot;https&quot;<br>  },<br>  ...<br>}</pre><p>We can see the User-Agent and Accept headers that curl sends by default are indeed received by the Lambda. That’s great — those are important headers. Now, let’s see what happens when we add Range to the curl command:</p><pre>curl &quot;https://{api_id}.execute-api.{region}.amazonaws.com/prod/resource&quot; \<br>  -H &quot;Range: bytes=0-255&quot; \<br>  --verbose</pre><p>We get exactly the same response as before. That is to say, the Range header wasn’t seen by the Lambda.</p><p>To figure out what’s going on, we can start by adding the --verbose option to the curl command to see what it is actually sending and confirm Range is there:</p><pre>...<br>&gt; GET /prod/resource HTTP/2<br>&gt; Host: jq2dpl12da.execute-api.us-west-2.amazonaws.com<br>&gt; user-agent: curl/7.68.0<br>&gt; accept: */*<br>&gt; range: bytes=0-255<br>...</pre><p>Okay, so curl is doing its part and somewhere on the AWS side it is getting lost. What happened? Why didn’t the Lambda receive it?</p><p>Well, to cut to the chase, it’s not an AWS bug but it is annoying.</p><h3>Why it Doesn’t Work</h3><p>By default API Gateway only <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html#mapping-request-parameters">passes a small set of headers</a> to the backend integration (i.e. the Lambda function in this case). Any other headers are ignored unless they are specifically configured to be passed along.</p><p>This is a security feature, and probably for the best, but the list of headers supported is so short it makes pain and we need to jump through hoops to get it working.</p><p>So let’s try again.</p><h3>Another False Start</h3><p>Reading the <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-api.html#sam-function-api-requestparameters">SAM documentation</a>, it would appear that simply adding the header as a request parameter to the Events node inside the function would be the solution. So, let’s try that — here is the updated section of the template for brevity:</p><pre>...<br>        &quot;Events&quot;: {<br>          &quot;Root&quot;: {<br>            &quot;Type&quot;: &quot;Api&quot;,<br>            &quot;Properties&quot;: {<br>              &quot;RestApiId&quot;: {<br>                &quot;Ref&quot;: &quot;Api&quot;<br>              },<br>              &quot;Path&quot;: &quot;/resource&quot;,<br>              &quot;Method&quot;: &quot;GET&quot;,<br>              &quot;RequestParameters&quot;: [<br>                &quot;method.request.header.Range&quot;<br>              ]<br>            }<br>          }<br>        }<br>...</pre><p>And testing again (same curl command as above) yields no joy. This is super frustrating — two hurdles (so far) in place and we still don’t have access to the header in the Lambda. What’s going on?</p><p>The (not very obvious) answer is that the SAM implementation of the request parameter only creates the “method” part, and not the “integration” part that maps the actual value to the payload sent to Lambda. This is clear looking at the configuration in the UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lFNv7_td7IBoa_jnxpgv6w.png" /><figcaption>The integration request doesn’t pass the Range header to the Lambda because SAM doesn’t create the needed configuration.</figcaption></figure><p>Perhaps instead of using the Events property to connect the Lambda with the API, we can instead use the DefinitionBody property of the API. We’ll need to define the endpoint in OpenAPI and use the AWS extensions to connect to the Lambda. With those changes the template ends-up looking like this:</p><pre>...    <br>    &quot;Api&quot;: {<br>      &quot;Type&quot;: &quot;AWS::Serverless::Api&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;StageName&quot;: &quot;prod&quot;,<br>        &quot;MergeDefinitions&quot;: true,<br>        &quot;DefinitionBody&quot;: {<br>          &quot;openapi&quot;: &quot;3.0.1&quot;,<br>          &quot;info&quot;: {<br>            &quot;title&quot;: &quot;my-api&quot;,<br>            &quot;version&quot;: &quot;1.0&quot;<br>          },<br>          &quot;paths&quot;: {<br>            &quot;/resource&quot;: {<br>              &quot;get&quot;: {<br>                &quot;parameters&quot;: [<br>                  {<br>                    &quot;name&quot;: &quot;Range&quot;,<br>                    &quot;in&quot;: &quot;header&quot;,<br>                    &quot;schema&quot;: {<br>                      &quot;type&quot;: &quot;string&quot;<br>                    }<br>                  }<br>                ],<br>                &quot;x-amazon-apigateway-integration&quot;: {<br>                  &quot;httpMethod&quot;: &quot;POST&quot;,<br>                  &quot;type&quot;: &quot;aws_proxy&quot;,<br>                  &quot;uri&quot;: {<br>                    &quot;Fn::Sub&quot;: &quot;arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Handler.Arn}/invocations&quot;<br>                  },<br>                  &quot;requestParameters&quot;: {<br>                    &quot;integration.request.header.Range&quot;: &quot;method.request.header.Range&quot;<br>                  }<br>                }<br>              }<br>            }<br>          }<br>        }<br>      }<br>    },<br>    &quot;Handler&quot;: {<br>      &quot;Type&quot;: &quot;AWS::Serverless::Function&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;CodeUri&quot;: &quot;../src/Handler&quot;,<br>        &quot;Handler&quot;: &quot;Handler::Handler.Function::FunctionHandler&quot;<br>      }<br>    }<br>...</pre><p>And… still no joy. Now we get a 500error when making the request with curl.</p><p>The error message is happily something with relevant Google hits, which explain the problem: when using Events SAM automatically adds a Lambda Function resource permission that allows API Gateway to invoke it, but when using the OpenAPI extensions that doesn’t happen. Why? I don’t know.</p><h3>Finally, What Does Work</h3><p>Adding an AWS::Lambda::Permission resource allows us to clear the final hurdle, with a template that ends-up looking like this:</p><pre>{<br>  &quot;AWSTemplateFormatVersion&quot;: &quot;2010-09-09&quot;,<br>  &quot;Transform&quot;: &quot;AWS::Serverless-2016-10-31&quot;,<br>  &quot;Globals&quot;: {<br>    &quot;Function&quot;: {<br>      &quot;MemorySize&quot;: 1024,<br>      &quot;Runtime&quot;: &quot;dotnet6&quot;,<br>      &quot;Timeout&quot;: 10,<br>      &quot;Tracing&quot;: &quot;Active&quot;<br>    }<br>  },<br>  &quot;Resources&quot;: {<br>    &quot;Api&quot;: {<br>      &quot;Type&quot;: &quot;AWS::Serverless::Api&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;StageName&quot;: &quot;prod&quot;,<br>        &quot;MergeDefinitions&quot;: true,<br>        &quot;DefinitionBody&quot;: {<br>          &quot;openapi&quot;: &quot;3.0.1&quot;,<br>          &quot;info&quot;: {<br>            &quot;title&quot;: &quot;my-api&quot;,<br>            &quot;version&quot;: &quot;1.0&quot;<br>          },<br>          &quot;paths&quot;: {<br>            &quot;/resource&quot;: {<br>              &quot;get&quot;: {<br>                &quot;parameters&quot;: [<br>                  {<br>                    &quot;name&quot;: &quot;Range&quot;,<br>                    &quot;in&quot;: &quot;header&quot;,<br>                    &quot;schema&quot;: {<br>                      &quot;type&quot;: &quot;string&quot;<br>                    }<br>                  }<br>                ],<br>                &quot;x-amazon-apigateway-integration&quot;: {<br>                  &quot;httpMethod&quot;: &quot;POST&quot;,<br>                  &quot;type&quot;: &quot;aws_proxy&quot;,<br>                  &quot;uri&quot;: {<br>                    &quot;Fn::Sub&quot;: &quot;arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Handler.Arn}/invocations&quot;<br>                  },<br>                  &quot;requestParameters&quot;: {<br>                    &quot;integration.request.header.Range&quot;: &quot;method.request.header.Range&quot;<br>                  }<br>                }<br>              }<br>            }<br>          }<br>        }<br>      }<br>    },<br>    &quot;Handler&quot;: {<br>      &quot;Type&quot;: &quot;AWS::Serverless::Function&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;CodeUri&quot;: &quot;../src/Handler&quot;,<br>        &quot;Handler&quot;: &quot;Handler::Handler.Function::FunctionHandler&quot;<br>      }<br>    },<br>    &quot;HandlerPermission&quot;: {<br>      &quot;Type&quot;: &quot;AWS::Lambda::Permission&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;FunctionName&quot;: {<br>          &quot;Fn::GetAtt&quot;: [<br>            &quot;Handler&quot;,<br>            &quot;Arn&quot;<br>          ]<br>        },<br>        &quot;Action&quot;: &quot;lambda:InvokeFunction&quot;,<br>        &quot;Principal&quot;: &quot;apigateway.amazonaws.com&quot;<br>      }<br>    }<br>  }<br>}</pre><p>A far cry from the simple template I started with. But, the curl command finally shows the Range header making it to the Lambda with this configuration (yay!).</p><h3>Summary</h3><p>This kind of experience is a significant source of developer frustration:</p><ol><li>A very common HTTP use case doesn’t work “out of the box”</li><li>The obvious path to resolve it while keeping with SAM template idioms also doesn’t work.</li><li>Stepping outside the SAM idioms works, but involves extra non-obvious complexity.</li></ol><p>I’m happy to document what works, but I wish there was clearer documentation from AWS of how to satisfy this simple and common use case. Even better, it’s be nice if SAM made it “just work” for us.</p><p>Interested in the details? See <a href="https://github.com/mlhpdx/cloudformation-examples/tree/master/apigw-to-lambda-any-header">the example</a> in GitHub.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d8e73fa4dcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step Functions HTTP Endpoint Node Considered Harmful]]></title>
            <link>https://medium.com/@lee.harding/step-functions-http-endpoint-node-considered-harmful-8ce40d3f0eb6?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ce40d3f0eb6</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[aws-step-functions]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Thu, 11 Apr 2024 16:13:15 GMT</pubDate>
            <atom:updated>2025-03-05T20:22:20.135Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i7Uf2C1BhqEM7aBQ-fakcw.png" /><figcaption>The HTTP Endpoint node is convenient, but not safe for APIs using Range and/or conditional requests.</figcaption></figure><blockquote><strong>UPDATE: </strong>It appears that the behavior of the HTTP Endpoint node throws an error if an If-* header is added to a request. That’s good, it means conditional updates won’t fail silently. You still can’t use If-* headers, but at least it is obvious. The node still silently overwrites the Range header, which is done in an attempt to require the API to only return a limited number of bytes (~260K). It’s a little silly since REST APIs in general don’t support Range and those that do generally do so for different purposes (like paging).</blockquote><p>There is a persistent factoid (a falsehood broadly accepted as fact) that one cannot call an external HTTP API from an AWS StepFunctions state machine. It’s been false since AWS introduced the SDK integration nodes, which allowed using apigateway::execute-api. I have pointed this out to many, many folks including some that should have known better than to repeat it, and yet the mistaken perception remains.</p><p>To add to the trouble, AWS released the “HTTP Endpoint” node type and made great hay about it. And I “meh’d”. I thought it would be nice to have direct support for calling HTTP APIs, and it would make it easier for folks light on experience to make more use of Step Functions (which I very much encourage). But then this happened:</p><p>&gt; Customer: “Your API sucks. I can’t use it from Step Function. Fix it.”</p><p>&gt; Me: “Huh? Can you show me what you mean?”</p><p>The customer then showed me how when they called my API, just as the documentation said to do, they weren’t getting the requested data. I looked at their state machine code, which was spot-on as far as I could tell. I recreated the call with CURL and it worked fine, and they did the same and it worked for them, too. It was just when the API was called from Step Functions. Some quick spelunking in my internal logs indicated that my API was getting the request but… oh, damn. AWS…</p><p>The request didn’t include the Range header the customer added. I’ve seen this before with different services and a feeling of dread rose — checked the documentations, and 100% “yep” — AWS removes a bunch of headers from outgoing requests and there is <strong>no workaround</strong>.</p><p>It gets worse. Among the headers they remove are If-* and Range — WTF?</p><p>My customer noticed that paging through long collection resources didn’t work, and the reason was that my APIs (and many others) depend on the Range header for paging. It’s basic HTTP protocol stuff.</p><p>The <strong>really, really harmful and damn-near nefarious problem</strong> AWS has created has to do with the If-* headers. If those headers are stripped from requests it breaks conditional requests for some very important APIs (like GitHub). That in turn exposes customers to the debilitating “lost update” problem. Worse, it does so <strong>silently and nearly undetectably</strong>.</p><p>Not including If-None-Match means that a PUT or DELETE that should fail, doesn’t. That will lead to serious data problems for customers. Guaranteed.</p><p>My recommendation, if you’re using a business critical API that supports conditional updates, you need to stop using the HTTP Endpoint node — It’s a trainwreck waiting to happen. If you’re 100% confident the API you target doesn’t use conditional requests or Range for paging, and never will, then perhaps you can ignore this advice.</p><p>Perhaps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ce40d3f0eb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securely Forwarding local UDP over TLS]]></title>
            <link>https://medium.com/@lee.harding/securely-forwarding-local-udp-over-tls-d1004352d037?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1004352d037</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[udp]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Wed, 28 Jun 2023 04:27:15 GMT</pubDate>
            <atom:updated>2023-06-28T04:27:15.355Z</atom:updated>
            <content:encoded><![CDATA[<p>I had a need to send UDP traffic generated on a local network to a remote service over the internet. The content of the UDP messages could be sensitive (unlikely, but possible) so it needed to be sent via some secure protocol. The applications generating the traffic didn’t support anything but this plain UDP option and weren’t available for modification. So, I started thinking of the code to write, as software developers are prone to do…</p><p>Fortunately, I remembered the /dev/udp node in Linux and it made me wonder if there was a better way. Of course, there is or I wouldn’t be writing this.</p><p>To flush-out the idea, I created the simplest possible TLS server just to have something to receive the proxied traffic. Step one was to create a self-signed certificate:</p><pre>openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes</pre><p>Step two was to start the server:</p><pre>openssl s_server -key key.pem -cert cert.pem -quiet</pre><p>That starts a TLS server listening on the local port 4433 (the default for s_server). Any traffic sent to port 4433 will be echoed in that terminal.</p><p>For step three, in a separate terminal, I used netcat (aka. nc) to listen for UDP traffic on port 999 and forward it to the service above using s_client:</p><pre>sudo nc -u -l -k 127.0.0.1 999 | openssl s_client -quiet</pre><p>Finally, to prove it works I started another terminal and used nc to send UDP to port 999:</p><pre>nc -u 127.0.0.1 999</pre><p>And viola! Anything typed in will be echoed in the terminal running s_server. So, no need for any coding here — the Linux tools have it covered. The last step for me was to take the commands from step three, add the -connect option with the IP and port of my internet service, and wrap the entire thing into a systemd service unit file to make it run with a little resilience (first I created the user and directory):</p><pre>[Unit]<br>Description=Proxy UDP to TLS with systemd<br>DefaultDependencies=no<br>Wants=network.target<br>After=network.target<br><br>[Service]<br>ExecStart=/bin/sh -c &#39;nc -u -l -k 127.0.0.1 999 | openssl s_client -quiet -connect w.x.y.z:1234&#39;<br>WorkingDirectory=/var/udp-to-tls<br>Restart=always<br>RestartSec=10<br>SyslogIdentifier=udp-to-tls<br>User=u2tuser<br>Group=u2tuser<br>PrivateTmp=true<br><br>[Install]<br>WantedBy = multi-user.target</pre><p>Keeping the easy things easy.</p><p>Why was this so easy? Well, a key thing is that the traffic is one-way (UDP into my local machine, proxied out to the TLS service). If return traffic was expected on the TLS connection I suspect this would fall short.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1004352d037" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Self-Hosted Email (Send and Receive) with AWS SES]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@lee.harding/how-to-be-an-email-deadbeat-b3e4071ef600?source=rss-2a0f3dade5c0------2"><img src="https://cdn-images-1.medium.com/max/1854/1*LoSbA6DVTwPZuQ5dq3T4XA.png" width="1854"></a></p><p class="medium-feed-snippet">The almost-free way to run email for your domains using SES, Step Functions and Lambda (and AI, of course!).</p><p class="medium-feed-link"><a href="https://medium.com/@lee.harding/how-to-be-an-email-deadbeat-b3e4071ef600?source=rss-2a0f3dade5c0------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@lee.harding/how-to-be-an-email-deadbeat-b3e4071ef600?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3e4071ef600</guid>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Wed, 22 Mar 2023 23:58:42 GMT</pubDate>
            <atom:updated>2023-03-22T23:58:42.547Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Stream-to-Stream S3 Uploads with AWS Lambda]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/circuitpeople/stream-to-stream-s3-uploads-with-aws-lambda-578fe710ac1e?source=rss-2a0f3dade5c0------2"><img src="https://cdn-images-1.medium.com/max/1043/1*aliBE9EjoOtwY01tpM-qHw.png" width="1043"></a></p><p class="medium-feed-snippet">Transforming the content of large S3 objects with Lambda seems daunting, but a simple stream adapter makes some amazing things possible&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/circuitpeople/stream-to-stream-s3-uploads-with-aws-lambda-578fe710ac1e?source=rss-2a0f3dade5c0------2">Continue reading on circuitpeople »</a></p></div>]]></description>
            <link>https://medium.com/circuitpeople/stream-to-stream-s3-uploads-with-aws-lambda-578fe710ac1e?source=rss-2a0f3dade5c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/578fe710ac1e</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[stream]]></category>
            <category><![CDATA[s3]]></category>
            <dc:creator><![CDATA[Lee Harding]]></dc:creator>
            <pubDate>Sun, 17 Jan 2021 05:13:30 GMT</pubDate>
            <atom:updated>2021-01-17T05:13:30.617Z</atom:updated>
        </item>
    </channel>
</rss>