<?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 Geethika Guruge on Medium]]></title>
        <description><![CDATA[Stories by Geethika Guruge on Medium]]></description>
        <link>https://medium.com/@geethika.guruge?source=rss-6ba87da8eeb7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GpMfZzOm-js1FYJ4EospGg.png</url>
            <title>Stories by Geethika Guruge on Medium</title>
            <link>https://medium.com/@geethika.guruge?source=rss-6ba87da8eeb7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 03:59:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@geethika.guruge/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 AWS Auckland Region Has Arrived. What’s Your Next Move?]]></title>
            <link>https://medium.com/@geethika.guruge/the-aws-auckland-region-has-arrived-whats-your-next-move-ea22db1320fa?source=rss-6ba87da8eeb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea22db1320fa</guid>
            <dc:creator><![CDATA[Geethika Guruge]]></dc:creator>
            <pubDate>Mon, 01 Sep 2025 21:59:48 GMT</pubDate>
            <atom:updated>2025-09-02T00:46:14.465Z</atom:updated>
            <content:encoded><![CDATA[<h3>The AWS New Zealand Region Has Arrived. What’s Your Next Move?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udEjpmthNGaOMybLerw6rg.png" /></figure><p>It’s the moment many of us in the Aotearoa tech scene have been waiting for: the AWS New Zealand Region is officially live! After much anticipation, the data centers are humming, the services are online, and the new region, ap-southeast-6, is ready for action.</p><p>This is fantastic news for Kiwi businesses, developers, and the entire digital economy. But once the initial excitement settles, the big question is: what now? How do you actually take advantage of this new digital real estate in our own backyard?</p><h3>What This Means for Kiwi Businesses</h3><p>The launch of a local AWS region is more than just a new option in a dropdown menu. It’s a game-changer for several key reasons:</p><p><strong>Lower Latency, Happier Users</strong>: This is the most immediate and tangible benefit. Hosting applications closer to your end-users in New Zealand means data doesn’t have to travel across the Tasman Sea or the Pacific Ocean. For everything from websites and mobile apps to online gaming and streaming services, this reduction in delay (latency) results in a faster, more responsive experience for your customers. Think snappier page loads and smoother interactions.</p><p><strong>Data Sovereignty Solved: </strong>For many organizations, especially in government, healthcare, and finance, the ability to keep data within New Zealand’s borders is a strict regulatory requirement. The ap-southeast-6 region solves this data residency puzzle. Previously, even if you could run primary workloads in Australian regions, some compliance rules still required a backup copy of your data to be stored physically in New Zealand. This often forced organizations into complex and costly solutions, like shipping backups to local third-party data centers. Now, this compliance can be achieved easily and natively within AWS. You can simply use native AWS services to automatically store a secure copy of your data in the Auckland region, ticking the box for in-country backups without the operational headache.</p><p><strong>Boosting Local Innovation:</strong> Having world-class infrastructure on our doorstep empowers local startups and established companies alike. It lowers the barrier to entry for building sophisticated, high-performance applications and services that can compete on a global scale, all while being developed and managed right here at home.</p><h3>A Greener Cloud: Sustainability in the NZ Region</h3><p>Beyond performance and compliance, choosing the Auckland region has another powerful benefit: sustainability. For Kiwi businesses committed to their environmental goals and the principle of kaitiakitanga (guardianship), this is a significant advantage.</p><p>AWS is committed to powering its operations with 100% renewable energy by 2025 and reaching net-zero carbon across its business by 2040. By launching in New Zealand, they plug directly into one of the greenest energy grids in the world, with over 80% of our electricity generated from renewable sources like hydro, geothermal, and wind power.</p><p>Running your workloads on AWS is also inherently more efficient. Due to their scale, custom-built hardware, and operational excellence, AWS data centers can be up to five times more energy-efficient than a typical European enterprise data center. This means you can significantly reduce your application’s carbon footprint compared to running it in an on-premises facility.</p><p>To help you measure this impact, you can use the AWS Customer Carbon Footprint Tool in the billing console to track the emissions associated with your usage and support your own sustainability reporting.</p><h3>Quick Latency Comparison: NZ vs. Sydney</h3><p>Talk is cheap, so let’s look at the numbers. How much faster is it really?</p><p>I ran a quick test from my local laptop here in New Zealand, making a simple web request to two identical NGINX servers: one running on an EC2 instance in the new <strong>Auckland region</strong> (ap-southeast-6), and another in the <strong>Sydney region</strong> (ap-southeast-2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g35UFc6wRdA5Ryj0ITbIIQ.png" /></figure><p>The results speak for themselves.</p><ul><li><strong>Connecting to the Auckland :</strong> The total time was <strong>~22.5 milliseconds.</strong></li><li><strong>Connecting to the Sydney :</strong> The total time was <strong>~75.3 milliseconds.</strong></li></ul><p>It’s worth noting this test was performed over a standard WiFi connection to better represent a typical user’s experience. While the exact milliseconds will vary depending on your own connection, the key takeaway is the relative difference: <strong>accessing the local region is roughly three times faster. </strong>This is a performance boost that your customers will absolutely feel.</p><p>For applications that require real-time communication or fast data retrieval, this reduction is not just a nice-to-have; it’s a fundamental improvement that directly enhances the user experience.</p><h3>Getting Started: Practical First Steps</h3><p>Ready to dive in? Moving into a new AWS region isn’t a single click, but it doesn’t have to be a headache. Here’s a practical checklist to get you started.</p><p><strong>1. Check Service Availability</strong><br>Not all AWS services are available in every region on day one. Before you make any plans, check the AWS Regional Services List to confirm that the services you rely on — like certain EC2 instance types, specific database engines on RDS, or advanced AI/ML services — are available in ap-southeast-6.</p><p><strong>2. Update Your Infrastructure as Code (IaC)</strong><br>If you’re using tools like Terraform or the AWS CDK, leveraging the new region is straightforward. This is a great time to review your code and templatize the region setting if you haven’t already.</p><p><strong>Terraform</strong><br>For example, in Terraform, your provider block would be updated to:</p><pre>provider &quot;aws&quot; {<br>  region = &quot;ap-southeast-6&quot;<br>}<br><br># ... your resource definitions follow<br>resource &quot;aws_instance&quot; &quot;web_server&quot; {<br>  ami           = &quot;ami-0123456789abcdef0&quot; # Use a valid AMI for ap-southeast-6<br>  instance_type = &quot;t3.micro&quot;<br><br>  tags = {<br>    Name = &quot;MyWebServer-NZ&quot;<br>  }<br>}</pre><h4>AWS CDK (Cloud Development Kit)</h4><p>For those using the <strong>AWS CDK</strong>, before you can deploy your stacks, you first need to <strong>bootstrap</strong> the new region. Bootstrapping creates the necessary resources (like an S3 bucket for your packaged code and assets) that the CDK needs to operate.</p><p>Run the following command in your terminal, replacing ACCOUNT-ID with your actual AWS Account ID:</p><pre>cdk bootstrap aws://ACCOUNT-ID/ap-southeast-6</pre><p>Once bootstrapping is complete, you can deploy your CDK stacks to the New Zealand region by specifying it in your CDK app or via the command line.</p><p><strong>3. Plan Your Migration or Deployment Strategy</strong></p><p>You have a few options for how to use the new region:</p><ul><li><strong>New Deployments:</strong> The easiest approach. All new projects and environments can be deployed directly into ap-southeast-6 from the get-go.</li><li><strong>Lift and Shift:</strong> For existing applications, you can create snapshots of your EC2 instances and RDS databases, copy them to the new region, and relaunch them. This is a straightforward path for simpler workloads.</li><li><strong>Hybrid Approach:</strong> You might choose to keep some services running in another region (like Sydney) while moving latency-sensitive components to the New Zealand region.</li><li><strong>Disaster Recovery (DR):</strong> The NZ region is a perfect candidate for a DR site. You can now replicate your data and infrastructure from another region (e.g., ap-southeast-2 in Sydney) to ap-southeast-6 for enhanced resilience.</li></ul><h3>Beyond the Hype: Strategic Considerations</h3><p>The real power of the local region isn’t just in moving existing workloads — it’s in enabling <strong>new possibilities</strong>. This is a great opportunity to ask some strategic questions:</p><ul><li>Could we now build that real-time application we always wanted to?</li><li>How can we use the local region to improve our disaster recovery posture and business continuity?</li><li>Can we architect a multi-region setup that gives our users in both Australia and New Zealand the best possible performance?</li></ul><p>The launch of the AWS ap-southeast-6 region marks a new chapter for technology in New Zealand. It’s time to move past the announcement and start building. So, log into your console, select the new region, and start creating the future. The tools are right here on our shores.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea22db1320fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AI Pit Crew: Building a Production App in a Single Stop]]></title>
            <link>https://medium.com/@geethika.guruge/my-ai-pit-crew-building-a-production-app-in-a-single-stop-68e3f435c5cc?source=rss-6ba87da8eeb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/68e3f435c5cc</guid>
            <category><![CDATA[amazon-kiro]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[agentic-workflow]]></category>
            <dc:creator><![CDATA[Geethika Guruge]]></dc:creator>
            <pubDate>Sat, 02 Aug 2025 23:12:35 GMT</pubDate>
            <atom:updated>2025-08-02T23:12:35.054Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>By Geethika Guruge<br></strong><em>Principal Consultant @ Mantel Group | AWS Ambassador | AWS Community Builder</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rpi2kh652qVH4mHDBQg3Xg.jpeg" /></figure><p>Ever have an idea for a web app but get bogged down by the setup before you even write a single line of application code? I’ve been there. This time, while catching up on the F1 highlights from last weekend’s race, I decided to try something different. I built a single-page web application that queries a GraphQL API, and I did it almost entirely within the <strong>Amazon Kiro IDE</strong>, leaning heavily on a concept called <strong>spec-driven development</strong>. This is the story of how I went from a simple idea to a solid architectural plan in minutes.</p><h3>From a Simple Chat to a Solid Plan</h3><p>My journey started with a chat. Not with a colleague, but with Kiro. True to its friendly ghost icon, the AI felt like an invisible helper ready to assist. I had a clear goal in mind:</p><ul><li><strong>Frontend: Build a Single-Page Application (SPA) hosted on AWS S3 and served via CloudFront.</strong></li><li><strong>Backend: Create a serverless AWS Lambda function, exposed via an API Gateway endpoint.</strong></li><li><strong>Data Source: The Lambda function will query an external GraphQL API to fetch data.</strong></li><li><strong>Integration: The SPA will call the API Gateway endpoint to retrieve and display the data from the backend.</strong></li></ul><p>As a firm believer in Infrastructure as Code (IaC), I knew I wanted to define my entire setup in code from day one. I instructed Kiro that my infrastructure should be written using the <strong>AWS Cloud Development Kit (CDK) in Python</strong>.</p><p>To ensure Kiro had the right context and followed best practices, I configured a few MCP (Model Context Protocol) servers, most importantly aws-documentation and aws-cdk ones . This gave the AI the background knowledge it needed to generate high-quality, relevant code and architectural suggestions.</p><h3>Locking in the Spec</h3><p>The most amazing part was the speed. After about <strong>15 minutes of interactive chat</strong>, refining my requirements and explaining the base architecture, Kiro helped me lock in an initial specification for my project. The back-and-forth felt less like programming and more like a focused brainstorming session with a very knowledgeable partner.</p><p>This process is at the heart of what Kiro calls<a href="https://kiro.dev/docs/specs/concepts/"> spec-driven development</a>. Instead of jumping straight into writing boilerplate code, I focused on defining <em>what</em> I wanted to build. The initial spec, born from our conversation, became the blueprint for the entire project. It laid out the core components, the cloud infrastructure, and the relationship between them, all before I wrote a single line of CDK or front end code myself.</p><p>The result of this step was a concrete requirements file that Kiro would use to generate the project structure. My requirements looked something like this</p><pre>### Requirement 1<br><br>**User Story:** As a developer, I want to create AWS infrastructure using CDK in Python, so that I can deploy a static website with proper cloud distribution.<br><br>#### Acceptance Criteria<br><br>1. WHEN the CDK stack is synthesized THEN the system SHALL generate CloudFormation templates for S3 and CloudFront resources<br>2. WHEN the CDK stack is deployed THEN the system SHALL create an S3 bucket configured for static website hosting<br>3. WHEN the CDK stack is deployed THEN the system SHALL create a CloudFront distribution pointing to the S3 bucket<br>4. WHEN deploying the infrastructure THEN the system SHALL use the sandpit-1-admin AWS profile from ~/.aws/config</pre><p>My full requirements.md file at this stage can be found <a href="https://github.com/geethika-guruge/meetup-dashboard/blob/5e3237134b8e1d806183c8bab36a4b809f8bbc32/.kiro/specs/spa-cloudfront-s3/requirements.md">here</a></p><h3>Steering the Agent: Defining the Guardrails</h3><p>With my initial requirements locked in, the next logical step was to provide Kiro with more specific instructions to guide the next steps. This is where I took some time to define the <strong>agent steering files</strong>. Think of these as guardrails that ensure the AI produces consistent, high-quality output that aligns perfectly with my technical standards.</p><p>I used these files to set some firm ground rules. First, all <strong>Infrastructure as Code (IaC)</strong> had to be written with the <strong>AWS CDK</strong>. Second, as a core security measure, every <strong>IAM Role</strong> needed to follow the <strong>principle of least privilege</strong>. But looking back, I see a critical gap in my instructions: I never specified <em>how</em> to handle secrets. There was no mention of using a service like <strong>AWS Secrets Manager</strong>. This omission, as you’ll see, became relevant later in the process.</p><p>This is a snippet of my initial structure.md</p><pre>### Lambda Functions<br>- Each Lambda function has its own Python file<br>- Logging configured at module level<br>- Error handling with proper HTTP status codes<br><br>### Frontend Structure<br>- Single-page application with vanilla JavaScript<br>- No external frameworks or libraries<br>- API calls use modern fetch API with async/await<br><br>### Infrastructure as Code<br>- Single CDK stack in `meetup_dashboard_stack.py`<br>- Outputs for important resource identifiers<br>- Proper IAM permissions with least privilege<br>- Resource tagging for management</pre><p>I also created a tech.md file to specify my technology stack and preferences in more detail. In it, I defined:</p><ul><li>The IaC language would be <strong>Python</strong>.</li><li>The preferred versions for key libraries and runtimes.</li><li>My preference for using Python <strong>virtual environments (venv)</strong> to manage dependencies cleanly.</li></ul><p>This is a snippet of my initial tech.md</p><pre>## Dependencies<br><br>### Python (requirements.txt)<br>- `aws-cdk-lib&gt;=2.100.0`: AWS CDK framework<br>- `boto3&gt;=1.26.0`: AWS SDK for Python<br>- `pytest&gt;=7.0.0`: Testing framework<br>- `responses&gt;=0.23.0`: HTTP request mocking for tests<br><br>## Common Commands<br><br>### Development Setup<br>```bash<br># Create and activate virtual environment<br>python -m venv .venv<br>source .venv/bin/activate </pre><p>Taking the time to define these steering instructions upfront is a critical step. It ensures that as Kiro starts generating the artifacts, the output will be predictable, secure, and tailored exactly to my project’s needs.</p><h3>Designing the Blueprint</h3><p>With the initial requirements spec’d out and the steering files acting as my guardrails, it was time for the exciting part: generating the architectural design.</p><p>I prompted Kiro to create the design based on my spec. The first pass was impressive, translating my abstract requirements into a tangible structure. Of course, no automated design is perfect on the first try, so I needed to iterate on it a bit to refine the details and get it exactly how I wanted.</p><p>This is where the power of the steering files truly shone. Because I had already defined my core technical standards in tech.md, I didn’t have to repeat myself during the design iterations. There was no need to constantly re-state “use Python for CDK” or “remember least privilege for IAM roles.”</p><p>It was like Kiro already knew my preferences. The entire design process became a high-level conversation focused purely on the architecture, not on re-explaining foundational choices. Every subsequent output was already catered to my standards, which saved a massive amount of time and mental energy.</p><h3>The Action Plan: From Design to Tasks</h3><p>With the design locked in, I moved to the last step before letting the agent loose on the code: generating a list of tasks. This would serve as the final, granular action plan for building the application.</p><p>At this stage, the process was incredibly smooth. I pretty much accepted all the tasks that Kiro generated without much back-and-forth. The earlier work defining the requirements and steering the design meant the proposed tasks were already aligned with my vision.</p><p>However, there was one feature here that I have to call out — something the Business Analysts among my readers will absolutely love. Each task Kiro generated included a direct reference back to the specific requirement it was meant to fulfill. This created complete traceability, drawing a clear line from the initial business need all the way down to the individual code generation prompts.</p><p>This isn’t just a “nice-to-have”; it’s a powerful tool for project governance. It ensures that every single task has a purpose and that the project scope is tightly controlled. There’s no ambiguity about why a certain piece of infrastructure is being built or a specific function is being written.</p><p>The implementation plan (task.md) looked something like this at this stage</p><pre># Implementation Plan<br><br>- [x] 1. Initialize CDK project structure and dependencies<br>  - Create CDK Python project with proper directory structure<br>  - Install required CDK libraries (aws-cdk-lib, aws-cdk.aws-s3, aws-cdk.aws-cloudfront)<br>  - Set up cdk.json configuration file with app entry point<br>  - Create requirements.txt with CDK dependencies<br>  - _Requirements: 1.1, 1.2, 3.1, 3.2_</pre><p>My full task.md file at this stage can be found <a href="https://github.com/geethika-guruge/meetup-dashboard/blob/5e3237134b8e1d806183c8bab36a4b809f8bbc32/.kiro/specs/spa-cloudfront-s3/tasks.md">here</a></p><h3>Lights Out and Away We Go: The Agent Takes Over</h3><p>With that detailed and fully traceable action plan in hand, I was finally ready. The planning was done. It was time to write some code — or rather, to let the agent write the code.</p><p>My role shifted dramatically at this point. My involvement was mostly limited to kicking off the tasks one by one and occasionally granting permission for Kiro to execute shell commands when prompted.</p><p>Speaking of permissions, a fantastic enhancement I’ve seen in the latest version of Kiro is the ability to “trust” a command at three different levels. I could trust:</p><ol><li><strong>The specific command</strong> exactly as written, including all arguments.</li><li><strong>Part of the command</strong>, like a subcommand.</li><li><strong>The entire base command</strong> (e.g., cdk or git).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j3FdwTD4Q1c9d28G" /></figure><p>This meant I could progressively give the agent more freedom. By trusting a base command, the next time Kiro wanted to run it, it would proceed without prompting me. This trust level is also configurable in the settings, allowing for a highly efficient and customized workflow.</p><p>So, while Kiro was busy generating code, running unit tests, deploying the initial stacks to AWS, and testing functionality, my evening here in Auckland looked a bit different. I was catching up on the highlights of the Belgian Grand Prix, keeping one eye on my laptop screen just to approve a command or two. It was a perfect demonstration of asynchronous work, with the heavy lifting of development happening almost entirely on its own.</p><h3>Iteration Two: Adding the Backend and Hitting a Wall</h3><p>Once the initial single-page application with its dummy page was successfully deployed, I started on my next iteration. The plan was to add a backend Lambda function to fetch data using the GraphQL API from Meetup.com. The purpose of this application is to display statistics of all meetups under a single Meetup.com Pro subscription, providing a true “single pane of glass.”</p><p>I’ll write a different blog post soon about the actual use case behind this and why I decided to spend my evening on such a project. For the moment, let’s move back to Kiro… or can we? Just as I was getting into the flow of the new feature, that’s when I started hitting the dreaded throttling.</p><p>To be honest, I felt like the throttling situation had improved drastically from the week before, and I was pragmatic enough to understand the context. This is a free offering, and everybody who could get their hands on the public beta was now hammering the underlying Sonnet model as hard as they could. When you’re working with cutting-edge tech in a public beta, you have to expect a few bumps in the road.</p><h3>The Workaround: Vibe Coding in VS Code</h3><p>Refusing to let throttling stop my progress, I pivoted. I moved back to my trusty VS Code setup and started what I’d call a “poor man’s agentic workflow” with Amazon Q Developer. It was time for some good old-fashioned vibe coding.</p><p>This is where I truly realized the value of spec-driven development. Without the carefully crafted system prompts and properly configured Q developer, I found that while powerful, it could easily get distracted and sometimes go around in circles. The guardrails were gone, and I was back to manually guiding every step.</p><p>By this time, my main battle wasn’t with the AI, but with the intricacies of GraphQL. The poor API documentation from Meetup.com, which was hidden behind an authentication wall, certainly didn’t help either.</p><p>Looking back, I see a missed opportunity. I would have been better off spending my time writing an MCP server to get through the authentication and read the API documentation, or even creating an agent to read it directly from my authenticated browser. It’s a powerful lesson in leveraging the right tool for the job.</p><h3>A Stitch in Time: The Secrets Manager Realization</h3><p>Remember earlier when I mentioned I hadn’t specified how to handle secrets? This is the moment that omission came back to bite me. As Kiro was generating the list of tasks, I reviewed the ones for authenticating with the Meetup.com API and noticed the plan was to store the sensitive API keys directly in Lambda environment variables. So I intervened and explicitly instructed Kiro to use AWS Secrets Manager instead. Sure enough, like a good assistant, it quickly corrected the affected tasks to incorporate the more secure approach.</p><p>But that’s when it clicked. This manual correction was only necessary because of my own oversight. I should have specified the use of Secrets Manager in my agent steering files from the very beginning. It was a perfect, real-world lesson in the value of being thorough in your initial spec and design, proving that the more upfront thinking you do, the smoother the automated process becomes, software engineering 101, really.</p><p>Anyway, with a little bit of persistence and some focused vibe coding late into the evening here in Auckland, I finally got there.</p><h3>Conclusion: From Idea to MVP in a Few Hours</h3><p>So, after all that, what did I actually have to show for my evening?</p><p>What I built was a genuine, production-quality MVP. And I’m not talking about a fragile script. Thanks to the IaC-first approach and the agent’s adherence to my steering files, this application came with proper security practices, automated tests, and a fully deployed serverless architecture right from the get-go.</p><p>But the most incredible part was the sheer speed and efficiency of it all. This was achieved in just a few hours, and for at least half of that time, my main focus was on the F1 highlights. The combination of Kiro’s spec-driven development and a focused agentic workflow handled the heavy lifting.</p><p>This journey really proved to me what’s possible with these new tools. Going from a simple idea to a secure, working application in a single evening is a total game-changer.</p><p>You can find the full source code for this project on my GitHub <a href="https://github.com/geethika-guruge/meetup-dashboard">repository</a> and stay tuned for my next post where I’ll dive into the “<em>why</em>” behind this application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68e3f435c5cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Kubernetes: Building a Self-Service Platform with AWS Native Services]]></title>
            <link>https://medium.com/@geethika.guruge/beyond-kubernetes-building-a-self-service-platform-with-aws-native-services-398a112cca7c?source=rss-6ba87da8eeb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/398a112cca7c</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Geethika Guruge]]></dc:creator>
            <pubDate>Fri, 18 Jul 2025 05:57:20 GMT</pubDate>
            <atom:updated>2025-07-18T06:10:50.241Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>By Geethika Guruge<br></strong><em>Principal Consultant @ Mantel Group | AWS Ambassador | AWS Community Builder</em></p><p>Platform engineering has emerged as the backbone of modern software delivery, fundamentally transforming how organizations approach developer productivity. At its core, platform engineering aims to empower developers to ship code faster, safer, and with greater confidence through golden paths, robust automation, and intelligent guardrails.</p><p>Yet in discussions about platform engineering, one technology dominates the conversation: <em>Kubernetes</em>. While Kubernetes has become synonymous with modern platform architecture, this raises a critical question that many organizations fail to ask:</p><blockquote>Is <strong>Kubernetes</strong> truly indispensable for every platform?</blockquote><p>The unequivocal answer is: <strong>not necessarily</strong></p><p>For many organizations, Kubernetes introduces more complexity than it solves, creating operational overhead that diverts engineering resources from their primary mission — delivering value to users. This post explores how to build a production-grade internal developer platform (IDP) using AWS-native services, bypassing Kubernetes entirely while delivering superior developer experience and operational simplicity.</p><h3><strong>The Kubernetes Complexity Trap</strong></h3><p>Before diving into alternatives, let’s address the elephant in the room: <strong>platform engineering is a discipline, not a technology stack</strong>.</p><p>The core mission of platform engineering centers on:</p><ul><li><strong>Accelerating developer velocity</strong> through reduced friction</li><li><strong>Fostering innovation</strong> by removing operational barriers</li><li><strong>Minimizing cognitive load</strong> so developers focus on business logic</li><li><strong>Ensuring governance, security, and scalability</strong> without compromising speed</li></ul><p>While Kubernetes can be a powerful tool for complex, containerized workloads, it’s not the only path to platform excellence. If your team spends more time managing clusters than enabling developers, it’s time to reconsider your approach.</p><p><strong><em>The goal of platform engineering is to accelerate product delivery, not to become Kubernetes experts.</em></strong></p><h3>Core Principles of Effective Platform Engineering</h3><p>Any modern platform — regardless of underlying technology — should embody these fundamental principles:</p><p><strong>Self-Service Capabilities</strong>: Developers deploy and manage applications independently through intuitive interfaces and well-defined processes.</p><p><strong>Golden Paths</strong>: Opinionated templates and curated toolchains ensure secure, efficient, and compliant deployments by default.</p><p><strong>Embedded Security</strong>: Guardrails that enforce standards seamlessly without blocking delivery velocity.</p><p><strong>Comprehensive Observability</strong>: Full visibility into application health, performance, and usage for rapid issue resolution.</p><p><strong>Effortless Scalability</strong>: Both platform and workloads scale automatically with demand, requiring minimal manual intervention.</p><p>AWS provides a comprehensive suite of native services that fulfill all these principles — crucially, without the operational complexity of managing Kubernetes clusters.</p><h3>Building Your AWS-Native Platform: The Complete Toolkit</h3><p>Let’s explore how to architect a production-grade internal developer platform using AWS-native services:</p><h4><strong>Compute Abstractions: Managed Simplicity for Any Workload</strong></h4><p><strong>AWS App Runner</strong>: Deploy web applications and APIs directly from GitHub or container registries. App Runner automatically handles autoscaling, HTTPS termination, load balancing, and observability — all without infrastructure management. While it may lack the fine-grained controls needed for complex applications with specific networking, security, or deployment requirements, App Runner has a clear place in the AWS ecosystem for teams wanting to focus on code rather than infrastructure, making it ideal for straightforward web applications, APIs, and microservices that benefit from rapid deployment and minimal operational overhead.</p><p><strong>AWS Lambda</strong>: Perfect for event-driven architectures, background processing, and microservices. Scales to zero when idle and can instantly scale to handle thousands of concurrent executions, integrating natively with over 200 AWS services to eliminate integration complexity. Lambda excels at building loosely-coupled microservices that can be developed, deployed, and scaled independently, making it ideal for decomposing monolithic applications into manageable, function-based services. Lambda shines when you need rapid development cycles, automatic scaling that can handle massive traffic spikes without pre-provisioning, and pay-per-execution pricing for unpredictable or bursty workloads.</p><p><strong>AWS Fargate</strong>: Run containers serverlessly through ECS or EKS without managing clusters or EC2 instances. Ideal for long-running tasks, batch processing, and sidecar patterns, with IAM-based task-level security that provides granular access control. Fargate bridges the gap between Lambda’s execution limits and full container orchestration, offering the flexibility of containerized applications with serverless operational simplicity. Perfect for teams wanting container portability and custom runtime environments while eliminating infrastructure management overhead.</p><p><strong>CI/CD &amp; Developer Automation: Streamlining Software Delivery</strong></p><p><strong>AWS CodePipeline and CodeBuild</strong>: Create automated build, test, and deployment pipelines that integrate seamlessly with Lambda, App Runner, or Fargate for end-to-end delivery.</p><p><strong>Amazon Q Developer</strong>: A generative AI assistant that helps developers write and refactor code, generate infrastructure as code, and troubleshoot builds. It’s integrated into AWS services like Lambda console and available in various development environments.</p><p><strong>GitHub Actions + OIDC</strong>: Implement secure CI/CD pipelines using federated identity. GitHub can assume IAM roles without managing AWS credentials, enabling scalable, secure GitOps workflows.</p><p><strong>Governance &amp; Infrastructure as Code: Consistency and Control at Scale</strong></p><p><strong>AWS Proton</strong>: Define, version, and distribute infrastructure and application templates. Developers self-serve standardized environments while platform teams ensure compliance and consistency.</p><p><strong>AWS Service Catalog</strong>: Expose curated golden paths to developers, enforcing usage of approved configurations, budgets, and security controls.</p><p><strong>AWS Control Tower</strong>: Manage multi-account environments with automated policy enforcement, account provisioning, and security guardrails.</p><p><strong>CloudFormation / CDK</strong>: Define infrastructure as code using YAML/JSON (CloudFormation) or modern programming languages like TypeScript and Python (CDK), supporting version control and automation.</p><p><strong>Observability: Deep Insights Built-In</strong></p><p><strong>Amazon CloudWatch &amp; AWS X-Ray</strong>: Centralized logging, metrics, dashboards, alarms, and distributed tracing across all AWS services with no additional infrastructure.</p><p><strong>AWS CloudTrail</strong>: Immutable audit logs of all AWS API activity, essential for security investigations and compliance requirements.</p><p><strong>Integrated Telemetry</strong>: App Runner and Lambda provide built-in OpenTelemetry support for seamless instrumentation and vendor-agnostic observability.</p><p><strong>Security &amp; Access: Embedded, Granular Control</strong></p><p><strong>IAM Identity Center (formerly AWS SSO)</strong>: Unified identity management with fine-grained, role-based access control across AWS accounts and services.</p><p><strong>Service Control Policies (SCPs)</strong>: Prevent unsafe operations across teams by enforcing policies at the account or organizational unit level.</p><p><strong>AWS Config + Security Hub</strong>: Continuously monitor configurations, detect drift, and aggregate security findings for automated remediation.</p><h3>A Day in the Life: Seamless Developer Experience</h3><p>Here’s how a typical developer workflow looks with an AWS-native platform:</p><p><strong>Morning: Project Setup</strong> A developer selects a “Node.js App with DynamoDB” template from AWS Proton. The template includes pre-configured infrastructure, security policies, and monitoring — all version-controlled and governed.</p><p><strong>Development: Code and Deploy</strong> Code is pushed to GitHub. GitHub Actions authenticates using OIDC and triggers CodePipeline. CodeBuild handles testing and packaging, automatically deploying to App Runner with zero infrastructure concerns.</p><p><strong>Monitoring: Real-time Insights</strong> Logs stream to CloudWatch, traces appear in X-Ray, and the developer accesses pre-configured dashboards to monitor application behavior and receive intelligent alerts.</p><p><strong>Security: Built-in Protection</strong> IAM roles and AWS Secrets Manager handle runtime permissions and automatic secret rotation. Service Control Policies ensure no unauthorized actions can be taken.</p><p><strong>Scaling: Automatic and Transparent</strong> App Runner scales in and out with traffic automatically. Lambda functions respond to demand spikes without manual intervention or cluster management.</p><p>This isn’t theoretical — this is a production-grade developer platform that eliminates the operational burden of Kubernetes while delivering superior developer experience.</p><h3>When You Don’t Need Kubernetes</h3><p>You likely don’t need Kubernetes if:</p><ul><li>Your workloads are primarily APIs, batch jobs, or background tasks</li><li>You prefer managed services over building and maintaining control planes</li><li>Your team is small or lacks extensive Kubernetes operational experience</li><li>Your primary focus is developer velocity rather than infrastructure abstraction</li><li>You value operational simplicity over configurability</li></ul><p>Kubernetes can unlock powerful patterns, but often its complexity outweighs its benefits — especially when AWS-native alternatives already solve your core problems more elegantly.</p><h3>When Kubernetes Still Makes Sense</h3><p>To be fair, Kubernetes remains valuable in specific scenarios:</p><ul><li><strong>Highly customized networking or scheduling requirements</strong> that managed services can’t accommodate</li><li><strong>Complex sidecar patterns or service mesh needs</strong> requiring fine-grained control</li><li><strong>Hybrid or multi-cloud portability</strong> requirements where vendor lock-in is a concern</li><li><strong>Large-scale container orchestration</strong> with thousands of services requiring shared runtimes</li></ul><p>For these use cases, AWS offers Amazon EKS, EKS Blueprints, and EKS Auto Mode to reduce Kubernetes operational overhead while maintaining flexibility.</p><h3>Conclusion: Platform Engineering Without the Complexity</h3><p>Platform engineering is fundamentally about enabling developers, not managing infrastructure. The most successful platforms are those that become invisible to their users — providing powerful capabilities without operational burden.</p><p>AWS provides a rich ecosystem for building robust, scalable, and governed internal platforms without provisioning a single node or managing a single cluster. By leveraging services like App Runner, Proton, Lambda, and CodePipeline, you can accelerate innovation, reduce complexity, and focus on what matters most: delivering value to end users.</p><p>It’s time to look beyond Kubernetes and embrace the simplicity of AWS-native platform engineering. Your developers — and your delivery velocity — will thank you.</p><blockquote>The future of platform engineering isn’t about managing more infrastructure — it’s about managing less while delivering more.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=398a112cca7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Battle Scars: Scaling Without Surprises]]></title>
            <link>https://medium.com/@geethika.guruge/serverless-battle-scars-scaling-without-surprises-c654801444f4?source=rss-6ba87da8eeb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c654801444f4</guid>
            <category><![CDATA[antipattern]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Geethika Guruge]]></dc:creator>
            <pubDate>Tue, 08 Jul 2025 23:19:43 GMT</pubDate>
            <atom:updated>2025-07-08T23:22:45.777Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>By Geethika Guruge<br></strong> <em>Principal Consultant @ Mantel Group | AWS Ambassador | AWS Community Builder</em></p><blockquote>“Experience is simply the name we give our mistakes.” — Oscar Wilde</blockquote><p>Serverless promises scalability, cost efficiency, and developer velocity — but it’s not without its traps. At the Sydney AWS Summit 2025, I shared some real-world “battle scars” from production incidents over the years, that have taught us valuable lessons on designing resilient, cost-effective, and scalable serverless systems.</p><p>In this post, I’ll walk you through three of those stories — from an unexpected recursive Lambda loop to an API Gateway latency spiral, and finally a credentials rotation gone wrong. Let’s get into it.</p><h3>The Recursive Lambda Cost Explosion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IJeZjtKviVtLYNwP" /></figure><p>The architectural journey began with a straightforward event-driven design using AWS EventBridge.</p><p><strong>Core Components:</strong> The system utilized two distinct AWS Lambda functions: loadFilesFunction and extractDataFunction .</p><p><strong>Initial Vision:</strong></p><ul><li>loadFilesFunction was intended to be triggered first, handling data ingestion and file loading.</li><li>Upon successful completion, loadFilesFunction would emit an event.</li><li>This event would then trigger extractDataFunction, which was responsible for processing and extracting insights.</li><li>This sequential, event-driven flow aimed for a decoupled and scalable data processing pipeline.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*essch4XW7zcLWypb" /></figure><p>However, a critical misconfiguration occurred during the “wiring” phase (connecting services within AWS). The oversight was that loadFilesFunction was inadvertently configured as the target of an event <em>it emitted itself</em>. Instead of directing its output event to trigger extractDataFunction as intended, the event listener for loadFilesFunction was mistakenly pointed back to its own invocation source. The result was a recursive loop, where one invocation triggered the next, and so on — until the AWS bill exploded.</p><pre>// Create the LoadFiles Lambda function<br>const loadFilesFunction = new lambda.Function(this, &#39;LoadFilesFunction&#39;, { ... });<br><br>// Create the ExtractData Lambda function<br>const extractDataFunction = new lambda.Function(this, &#39;ExtractDataFunction&#39;, { ... });<br><br>// EventBridge Rule setup<br>const rule = new events.Rule(this, &#39;DataProcessingRule&#39;, { eventPattern: { ... } });<br><br>// Wrong Lambda target added<br>rule.addTarget(new targets.LambdaFunction(loadFilesFunction));</pre><h4>What We Could’ve done</h4><p>In our specific scenario, the recursive loop could have been averted, had the Lambda been designed to validate both the incoming event and its originating source This would have interrupted the self-perpetuating cycle of invocations before it could escalate. This dual-pronged validation — checking the integrity and expected format of the event data, as well as verifying that the source of the invocation was legitimate and expected — would have served as an essential circuit breaker, preventing the system from falling into an unintended and resource-consuming recursive pattern.</p><p>Also while the account-level lambda concurrency was at the default 1000, setting the Lambda-level concurrency to a lower value — for instance, 5, given it was a development environment — would have served as an invaluable safeguard. Such a limit would have effectively throttled the runaway execution, mitigating the blast radius of the recursive loop and allowing for earlier detection and intervention</p><h3>The API Gateway Latency Spiral</h3><p>What was once a snappy 200ms response time ballooned to 15 seconds under peak load. Why?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pbodCEBJfwI4NMF7" /></figure><p>We chained multiple Lambda functions synchronously. Cold start delays stacked up, and each Lambda waited for the next in a waterfall pattern. Our architecture, though functional, was not built for scale.</p><h4>Root Cause</h4><p>The existing architecture faced significant performance bottlenecks, particularly evident during peak traffic periods. Response times, which ideally should have remained consistently low, dramatically increased from an efficient 200 milliseconds to a staggering 15 seconds. This severe degradation in performance directly impacted user experience and system reliability.</p><p>A primary contributor to this performance decline was the extensive use of Lambda chaining. While beneficial for modularity, this architectural pattern introduced multiple cold start penalties. Each invocation of a new Lambda function in the chain, especially after periods of inactivity, incurred a delay as the execution environment spun up, cumulatively adding significant latency to the overall transaction.</p><p>Furthermore, the sequential nature of query execution, structured in a waterfall sequence, exacerbated the response delays. Instead of parallelizing or optimizing query operations, the system awaited the completion of one query before initiating the next. This linear processing flow, coupled with the aforementioned cold start issues, created a bottleneck that ultimately led to the unacceptable 15-second response times observed during high-demand scenarios. Addressing these core architectural limitations is crucial for improving system scalability and user satisfaction.</p><h4>What We Could’ve done</h4><p>Our initial implementation heavily relied on synchronous Lambda chaining, where one Lambda function directly invokes another and waits for its completion. While seemingly straightforward for simple workflows, this pattern quickly revealed several critical drawbacks:</p><ul><li><strong>Increased Latency:</strong> Each synchronous call added to the overall execution time, creating a cascading effect that significantly increased end-to-end latency for complex operations.</li><li><strong>Reduced Throughput:</strong> Synchronous invocations tie up Lambda concurrency, limiting the number of parallel requests the system could handle and hindering overall throughput.</li><li><strong>Higher Costs:</strong> Longer execution times and increased concurrency directly translated to higher AWS Lambda costs</li></ul><p><strong>The Solution: Embracing Asynchronous, Event-Driven Architectures</strong></p><p>Instead, we should have embraced asynchronous processing with event-driven flows. This involves:</p><ul><li><strong>Decoupling Functions:</strong> Lambda functions should publish events to a message broker (e.g., Amazon SQS, Amazon SNS, or EventBridge) rather than directly invoking other functions.</li><li><strong>Asynchronous Invocation:</strong> Downstream Lambda functions subscribe to these events and are invoked asynchronously when new events are published.</li></ul><p>Our second major misstep was failing to design our DynamoDB schemas with explicit consideration for our application’s access patterns. DynamoDB is a NoSQL database optimized for fast, predictable performance at any scale, but this performance is contingent on a schema design that aligns with how data is accessed.</p><p><strong>The Consequences of Suboptimal Schema Design:</strong></p><ul><li><strong>Forced Queries into Waterfalls:</strong> Without careful schema design, we often found ourselves having to perform multiple, sequential queries to retrieve related data. This created “waterfalls” of queries, where the result of one query was needed to inform the next, leading to:</li><li><strong>Increased Latency:</strong> Each subsequent query added to the overall response time, degrading user experience.</li><li><strong>Higher Throughput Costs:</strong> More queries meant more read capacity units consumed, increasing operational costs.</li></ul><p><strong>The Solution: Access Pattern-Driven Schema Design</strong></p><p>The core principle for effective DynamoDB schema design is to <em>“design for access patterns.”</em></p><p>This means:</p><ul><li><strong>Identify All Access Patterns Upfront:</strong> Before designing the schema, meticulously list every way the application will read and write data.</li><li><strong>Denormalization and Duplication:</strong> Embrace denormalization and data duplication strategically. Unlike relational databases, duplicating data is often necessary in DynamoDB to optimize for specific access patterns and avoid expensive joins or multiple queries.</li><li><strong>Leverage Primary Keys Effectively:</strong> The primary key (partition key and sort key) is crucial. It determines how data is distributed and how efficiently it can be retrieved. Design primary keys to directly support your most frequent access patterns.</li><li><strong>Optimize for Single-Table Design (where appropriate):</strong> For many use cases, a single-table design, where different entity types are stored in the same table, can be highly effective when combined with careful use of primary keys and secondary indexes. This can simplify data management and optimize certain access patterns.</li></ul><p>By rectifying these architectural missteps, we can significantly enhance our system’s performance, scalability, resilience, and cost-efficiency.</p><h3>The Secrets Manager Disaster</h3><p>In what seemed like a routine secrets rotation, AWS Secrets Manager generated new credentials and stored them. But the Lambda function that was supposed to update the database with those new credentials failed.</p><p>Secrets Manager still marked the new (and now broken) password as AWSCURRENT. The app couldn’t connect anymore.This critical misconfiguration immediately rendered the application unable to establish a connection to the database.</p><p>The fallout was swift and severe. With each failed login attempt, our monitoring systems registered an alarming increase in connection errors. These persistent failures, interpreted by our security protocols as anomalous activity, triggered a cascade of automated alarms. The security team, alerted to a possible brute-force attack or unauthorized access attempt, immediately initiated an investigation. The incident quickly escalated, transforming what should have been a routine password update into a full-blown crisis requiring immediate and intense incident response.</p><h4>How We Fixed it</h4><p><strong>Immediate Action: Break-Glass Access and Database Rollback</strong></p><p>In response to the critical authentication outage, our on-call engineers swiftly leveraged a pre-provisioned “break-glass” role. This elevated access allowed them to manually restore the old, known-good secret, immediately mitigating the incident and restoring service for affected users.</p><p><strong>Automated Security: Full Secrets Manager Rotation Workflow</strong></p><p>As for our long-term security strategy a fully automated Secrets Manager rotation workflow was implemented. The workflow orchestrated a four-phase cycle:</p><ul><li><strong>create_secret</strong>: A new, secret version is generated within Secrets Manager with AWSPENDING tag.</li><li><strong>set_secret</strong>: Update the database with the new credentials</li><li><strong>test_secret</strong>: Test the AWSPENDING version of the secret by using it to access the database.</li><li><strong>finish_secret</strong>: Move the label AWSCURRENT from the previous secret version to the new version</li></ul><p><strong>Robustness Enhancements: Retries, Rate Limits, and Circuit Breakers</strong></p><p><strong>Retries and Rate Limits:</strong> We introduced retry mechanisms for the authentication flows, allowing for transient issues or temporary service unavailability without immediate failure.</p><p>Complementing this, rate limits were put in place to prevent authentication overload, safeguarding the systems from malicious brute-force attacks or unintentional client-side loops. This ensured that while legitimate traffic was processed efficiently, excessive requests were gracefully throttled.</p><h3>Final Takeaways from the Edge of Chaos</h3><ul><li>Mistakes happen. Accept it. Plan for it.</li><li>Guardrails like quotas, timeouts, and retries are non-negotiable.</li><li>Serverless requires you to <strong>rethink your architecture</strong>, not just your code.</li><li>Prefer asynchronous, loosely coupled systems.</li><li>Invest in <strong>observability from day one</strong>.</li><li>Use HTTP 202 responses and embrace eventual consistency.</li><li>It’s often the <strong>smallest issues</strong> that cause the <strong>biggest outages</strong>.</li></ul><h3>Wrapping Up</h3><p>Scaling serverless systems isn’t just about choosing the right services — it’s about understanding the nuances of distributed design and preparing for failure. These stories aren’t just war stories — they’re lessons to help you build systems that don’t just scale, but survive and thrive.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c654801444f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supercharge Your EKS Scaling with KEDA and Application Load Balancer (ALB) Metrics]]></title>
            <link>https://medium.com/@geethika.guruge/supercharge-your-eks-scaling-with-keda-and-application-load-balancer-alb-metrics-4e1edb267a23?source=rss-6ba87da8eeb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e1edb267a23</guid>
            <category><![CDATA[amazon-eks]]></category>
            <category><![CDATA[keda]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Geethika Guruge]]></dc:creator>
            <pubDate>Thu, 12 Sep 2024 21:58:31 GMT</pubDate>
            <atom:updated>2024-10-31T09:00:16.197Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://medium.com/@geethika.guruge/scale-to-zero-in-eks-with-keda-36eb700e7c08">part 1</a> of this blog series, we explored the basics of using <strong>Kubernetes Event-Driven Autoscaling</strong> (KEDA) with Amazon Elastic Kubernetes Service (EKS) to scale workloads down to zero based on demand. In this part, we’ll take it a step further by discussing how to leverage Application Load Balancer (ALB) metrics as triggers for KEDA to automatically scale workloads up or down.</p><h3>Why Scale with ALB Metrics?</h3><p>ALB provides key metrics such as RequestCount and TargetResponseTime, which can be used to gauge incoming traffic and application performance. By leveraging these metrics, you can scale based on demand without having to provision excessive resources. Scaling based on RequestCount is particularly useful for traffic-heavy applications, while TargetResponseTime is helpful for applications where latency is a critical factor. KEDA can consume these metrics via Amazon CloudWatch and use them as triggers to scale pods dynamically, making your workload more responsive and cost-efficient.</p><h3>Setting Up KEDA with ALB Metrics</h3><p>Let’s go through the configuration to enable autoscaling with KEDA using CloudWatch metrics from ALB.</p><h4>1. Install KEDA</h4><p>If you haven’t already installed KEDA on your Kubernetes cluster, you can do so with the following commands:</p><pre>helm repo add kedacore https://kedacore.github.io/charts<br>helm repo update<br>helm install keda kedacore/keda - namespace keda - create-namespace</pre><blockquote>You can find detailed installation steps for KEDA in <a href="https://medium.com/@geethika.guruge/scale-to-zero-in-eks-with-keda-36eb700e7c08">Part 1</a> of this blog.</blockquote><p>2. Create an AWS IAM Role for Accessing ALB Metrics</p><p>Your Kubernetes cluster needs permission to read CloudWatch metrics. You can create an AWS IAM role with the necessary permissions and associate it with your Kubernetes service account.</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: &quot;cloudwatch:GetMetricData&quot;,<br>      &quot;Resource&quot;: &quot;*&quot;<br>    }<br>  ]<br>}</pre><p>Attach this policy to the IAM role used by the KEDA operator:</p><h4>3. Set Up CloudWatch Metrics for ALB</h4><p>Make sure your ALB metrics are being sent to CloudWatch. By default, ALB sends several key metrics, such as RequestCount, TargetResponseTime, and HTTPCode_ELB_5XX_Count. For this example, we’ll use RequestCount.</p><h4>4. Define a KEDA ScaledObject</h4><p>A ScaledObject is a KEDA custom resource that defines the criteria for scaling. Here’s an example YAML file for scaling based on RequestCount</p><pre>apiVersion: keda.sh/v1alpha1<br>kind: ScaledObject<br>metadata:<br>  name: alb-scaledobject<br>  namespace: keda-demo<br>spec:<br>  scaleTargetRef:<br>    name: demo-deployment    #K8s deployement to target<br>  minReplicaCount: 0  # We don&#39;t want pods if the queue is empty nginx-deployment<br>  maxReplicaCount: 20  # We don&#39;t want to have more than 15 replicas<br>  pollingInterval: 30 # How frequently we should go for metrics (in seconds)<br>  cooldownPeriod:  10 # How many seconds should we wait for downscale  <br>  triggers:<br>  - type: aws-cloudwatch<br>    metadata:<br>      namespace: AWS/ApplicationELB<br>      expression: SELECT COUNT(RequestCountPerTarget) FROM SCHEMA(&quot;AWS/ApplicationELB&quot;, LoadBalancer,TargetGroup) WHERE LoadBalancer = &#39;&lt;loadbalancer_name&gt;&#39;<br>      metricName: RequestCountPerTarget<br>      targetMetricValue: &quot;300&quot;<br>      minMetricValue: &quot;0&quot;<br>      awsRegion: &quot;ap-southeast-2&quot;<br>      identityOwner: operator <br>      metricCollectionTime: &quot;60&quot; <br>      metricStat: &quot;Average&quot; <br>      metricStatPeriod: &quot;30&quot; <br>      metricUnit: &quot;Count&quot;</pre><p>In this configuration:</p><ul><li>targetValue The number of requests per 5-minute window that triggers scaling.</li><li>metricCollectionTime How long in the past (seconds) should the scaler check AWS Cloudwatch.</li><li>cooldownPeriod The time KEDA waits before evaluating scaling changes again.</li><li>identityOwner Receive permissions for CloudWatch via Pod Identity or from the KEDA operator itself.</li></ul><p>If you’re using <strong>Pod Identity</strong> to grant access to AWS services, you’ll need to define a TriggerAuthentication resource for KEDA as follows:</p><pre>apiVersion: keda.sh/v1alpha1<br>kind: TriggerAuthentication<br>metadata:<br>  name: keda-auth<br>  namespace: default<br>spec:<br>  podIdentity:<br>    provider: aws-iam</pre><p>This configuration allows KEDA to authenticate with AWS using the assigned IAM role for service account (IRSA) associated with the pod. Ensure the IAM role attached has the necessary permissions to access CloudWatch metrics, as previously specified.</p><h3>Applying and Testing the Configuration</h3><p>Apply the ScaledObject and TriggerAuthentication</p><pre>kubectl apply -f alb-scaledobject.yaml<br>kubectl apply -f keda-auth.yaml</pre><ol><li>Monitor the scaling behaviour. As traffic increases, the number of pods should scale up, and as traffic decreases, it should scale down based on the thresholds specified.</li><li>You can adjust targetValue and queryWindow parameters based on your traffic patterns for optimised scaling.</li></ol><h3>Best Practices</h3><ul><li><strong>Experiment with Target Values</strong>: Depending on your application’s traffic, you might need to tune the targetValue to find the ideal threshold.</li><li><strong>Monitor Costs</strong>: Since CloudWatch metrics can incur costs, consider limiting the query frequency or time range as appropriate.</li><li><strong>Set Max Replicas Carefully</strong>: Set maxReplicaCount based on the maximum capacity your cluster can handle.</li><li><strong>Combine with Other Metrics</strong>: You can configure multiple triggers in a single ScaledObject, allowing you to scale based on a combination of metrics (e.g RequestCount and TargetResponseTime).</li></ul><h3>Conclusion</h3><p>Integrating KEDA with ALB metrics unlocks a dynamic, event-driven scaling solution that keeps your applications consistently performing at their best, regardless of fluctuating demands. This approach goes beyond traditional static or CPU-based autoscaling by adapting to real-time traffic directly from your ALB metrics, allowing you to optimize resource usage precisely when and where it’s needed most. With this setup, you’ll be able to handle peak loads effortlessly while scaling back during quiet periods, leading to substantial cost savings and a far more efficient infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e1edb267a23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scale to Zero in EKS with KEDA]]></title>
            <link>https://medium.com/@geethika.guruge/scale-to-zero-in-eks-with-keda-36eb700e7c08?source=rss-6ba87da8eeb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/36eb700e7c08</guid>
            <category><![CDATA[keda]]></category>
            <category><![CDATA[amazon-eks]]></category>
            <dc:creator><![CDATA[Geethika Guruge]]></dc:creator>
            <pubDate>Thu, 12 Sep 2024 21:58:31 GMT</pubDate>
            <atom:updated>2024-11-18T22:59:51.554Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you’re running a multi-tenant, production-grade kubernetes clusters on Amazon EKS, relying on the Horizontal Pod Autoscaler (HPA) for autoscaling the workloads. While HPA will serve you well in gerneral, you will encounter some limitations as we grew and face with increasing demands on your clusters. This series of blogs will take a look at providing alternate autoscaling options for such situations</p><p>In this blog, we’ll explore the limitations of HPA, and how we can address these challenges by adopting <strong>KEDA</strong> (Kubernetes Event-Driven Autoscaling).</p><h3>Limitations of Horizontal Pod Autoscaler (HPA)</h3><p>Kubernetes provides HPA to adjust the number of pod replicas based on CPU and memory utilization. While this is sufficient for many use cases, HPA comes with several limitations:</p><ol><li><strong>No Scaling to Zero</strong>: HPA cannot scale workloads to zero as it uses metrics such as CPU and memory utilization which cannot reach zero. This is inefficient for intermittent workloads where scaling to zero would optimize costs.</li><li><strong>Limited to Metrics</strong>: HPA can only scale based on metrics like CPU and memory. It cannot scale based on custom events or HTTP traffic.</li><li><strong>Dependence on Metrics Aggregators</strong>: HPA requires integration with external metrics providers, such as the Kubernetes Metrics Server, Prometheus Adapter, or the deprecated k8s-cloudwatch-adapter, which adds operational complexity.</li><li><strong>Inaccuracy in Scaling Decisions</strong>: HPA’s scaling decisions may not align precisely with actual target metrics, as the scaling algorithm often lags behind the real-time metrics of the system.</li></ol><h3>Kubernetes External Metrics API Limitation</h3><p>As your clusters grow, the variety of workloads you manage increases, demanding more sophisticated autoscaling strategies. This often results in the need to scale workloads not only based on internal metrics but also on external metrics from services like Amazon Managed Prometheus, AWS CloudWatch, or Kafka. Kubernetes’ External Metrics API allows autoscaling based on these metrics, but there’s a key limitation: <strong>only one metrics server can serve external metrics ( </strong><strong>external.metrics.k8s.io</strong> <strong>) per cluster</strong>.</p><p>This would limit you to choose one external metrics server (e.g., CloudWatch Adapter or KEDA) for providing the external metrics. This limitation is particularly problematic when you need to scale on multiple event sources simultaneously.</p><h3>Transitioning from k8s-cloudwatch-adapter to KEDA</h3><p>The <strong>k8s-cloudwatch-adapter</strong> has been the go-to solution for many, to perform scaling based on metrics from AWS CloudWatch. This has been particularly useful for autoscaling based on SQS Queue length. However, since Kubernetes v1.22, this adapter has been deprecated, and AWS has stopped maintaining it. Instead, AWS now recommends using <strong>KEDA</strong> for event-driven autoscaling.</p><h3>Enter KEDA: Kubernetes Event-Driven Autoscaling</h3><p><strong>KEDA</strong> (Kubernetes Event-driven Autoscaler) is a lightweight, open-source component that allows Kubernetes workloads to autoscale based on external event-driven metrics. It works alongside HPA, extending its capabilities without duplicating its functionality. KEDA is flexible, enabling scaling for different Kubernetes workloads (e.g., Deployments, StatefulSets, Jobs) based on event sources outside the cluster.</p><p>Some of KEDA’s key features include:</p><ul><li>Scaling workloads based on external events such as AWS SQS, Kafka, Prometheus metrics, or custom event sources.</li><li>Support for scaling to and from zero, addressing one of the primary limitations of HPA.</li><li>Extensibility, allowing users to create custom scalers if needed.</li><li>Ability to scale different types of Kubernetes workloads such as Deployments, StatefulSets, and Jobs based on different type of events.</li><li>Ability to scale custom resources as long as the target Custom Resource defines a /scale subresource.</li></ul><p>Furthermore, KEDA is part of CNCF and is widely used for event scaling in Kubernetes, and has a big community backing.</p><p><strong>How KEDA Works</strong></p><p>The below diagram illustrates how KEDA integrates with the Kubernetes Horizontal Pod Autoscaler (HPA), external event sources, and the Kubernetes etcd data store:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1YQpeHTJbh8YJhe2.png" /><figcaption>source : <a href="https://keda.sh/docs/2.15/concepts/#architecture">https://keda.sh/docs/2.15/concepts/#architecture</a></figcaption></figure><p>KEDA has two components which performs two key roles within Kubernetes:</p><ul><li><strong>Agent</strong>: The KEDA operator acts as an agent, activating and deactivating Kubernetes workloads to scale them up or down (including scaling to and from zero). It manages HPA for applications and ensures that the desired number of replicas matches the current load.</li><li><strong>Metrics</strong>: KEDA also acts as a Kubernetes metrics server, exposing event-driven metrics (like queue length or stream lag) to HPA. These metrics inform HPA when to scale up or down based on external event sources.</li></ul><p>There is an optional 3rd component to KEDA as well</p><p><em>*we will not be configuring any admission webhooks in this blog to avoid complexity</em></p><h3>KEDA Installation on Amazon EKS</h3><p>KEDA is installed in the cluster as two key components:</p><ul><li><strong>keda-operator</strong>: Manages the scaling logic and maintains the application’s HPA.</li><li><strong>keda-operator-metrics-apiserver</strong>: Acts as the metrics server, exposing external metrics to Kubernetes.</li></ul><p>In order to streamline the deployment of KEDA into your EKS cluster, you can use Helm and Terraform as follows</p><h4>1. Create an AWS IAM Role for KEDA</h4><p>First, an IAM role that allows KEDA to communicate with AWS services like CloudWatch or SQS:</p><pre>resource &quot;aws_iam_role&quot; &quot;keda-operator&quot; {<br>  name               = &quot;keda-operator&quot;<br>  assume_role_policy = module.keda-operator-trust-policy.json<br>}<br><br>data &quot;aws_iam_policy_document&quot; &quot;keda-operator-trust-policy&quot; {<br>  statement {<br>    actions = [<br>      &quot;sts:AssumeRoleWithWebIdentity&quot;<br>    ]<br>    principals {<br>      type = &quot;Federated&quot;<br>      identifiers = [&quot;arn:aws:iam::111122223333:oidc-provider/oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE&quot;]<br>    }<br>    condition {<br>      test     = &quot;StringEquals&quot;<br>      variable = &quot;oidc.eks.region-code.amazonaws.com/id/EXAMPLED539D4633E53DE1B71EXAMPLE:sub&quot;<br>      values   = [&quot;system:serviceaccount:keda:keda-operator&quot;]<br>    }<br>  }<br>}<br><br>output &quot;keda_operator_role_arn&quot; {<br>  value = aws_iam_role.keda-operator.arn<br>}</pre><h4>2. Install KEDA via Helm</h4><p>With the IAM role created, KEDA can now be deployed using Helm. Below is a sample terraform snippet of how to install KEDA using a Helm release</p><pre>resource &quot;helm_release&quot; &quot;keda&quot; {<br>  name             = &quot;keda&quot;<br>  repository       = &quot;https://kedacore.github.io/charts&quot;<br>  chart            = &quot;keda&quot;<br>  version          = &quot;2.8.2&quot;<br>  namespace        = &quot;keda&quot;<br>  create_namespace = true<br>  values = [<br>    templatefile(&quot;${path.module}/values/keda.yaml&quot;, {<br>      keda_operator_role_arn = &quot;arn:aws:iam::111122223333:role/keda-operator&quot;<br>    }),<br>  ]<br>}</pre><p>Once installed, we can verify the health of KEDA’s components by running:</p><p>kubeclt get pods -n keda</p><p>You should see output similar to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*YVZmtP1xCk2Dz6SHpePN0w.png" /></figure><h3>KEDA in Action</h3><p>In order to demonstrate scaling a workload based on an external metric, let’s take a look at the below architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*j7R9WnmEn_k8yNcE" /></figure><p>We have deployed a demo application which will polls a SQS queue, and writes a record to a DynamoDB table upon receiving a message.</p><p>Sample deployment file</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br> name: sqs-app<br> namespace: keda-test<br>spec:<br> replicas: 1<br> selector:<br>   matchLabels:<br>     app: sqs-reader<br> template:<br>   metadata:<br>     labels:<br>       app: sqs-reader<br>   spec:<br>     serviceAccountName: keda-service-account<br>     containers:<br>     - name: sqs-pull-app<br>       image: khanasif1/sqs-reader:v0.12<br>       imagePullPolicy: Always<br>       env:<br>       - name: SQS_QUEUE_URL<br>         value: https://sqs.ap-southeast-2.amazonaws.com/111122222/keda-demo-queue.fifo<br>       - name: DYNAMODB_TABLE<br>         value: payments<br>       - name: AWS_REGION<br>         value: ap-southeast-2<br>       resources:<br>         requests:<br>           memory: &quot;64Mi&quot;<br>           cpu: &quot;250m&quot;<br>         limits:<br>           memory: &quot;128Mi&quot;<br>           cpu: &quot;500m&quot;</pre><p><strong>Keda ScaledObject</strong></p><p>This is a key component of the whole orchestration, it defines the criteria for autoscaling the workload based on external metrics or event-driven triggers. It specifies the target deployment, the scaling behaviour, and the metrics or events (like queue length) that KEDA should monitor, allowing the workload to scale dynamically in response to real-time demand.</p><p>Below is a sample ScaledObject</p><pre>apiVersion: keda.sh/v1alpha1<br>kind: ScaledObject<br>metadata:<br> name: aws-sqs-queue-scaledobject<br> namespace: ${SQS_TARGET_NAMESPACE}<br>spec:<br> scaleTargetRef:<br>   name: ${SQS_TARGET_DEPLOYMENT}     #K8s deployement to target<br> minReplicaCount: 0  # We don&#39;t want pods if the queue is empty nginx-deployment<br> maxReplicaCount: 2000  # We don&#39;t want to have more than 15 replicas<br> pollingInterval: 30 # How frequently we should go for metrics (in seconds)<br> cooldownPeriod:  10 # How many seconds should we wait for downscale<br> triggers:<br> - type: aws-sqs-queue<br>   authenticationRef:<br>     name: keda-aws-credentials<br>   metadata:<br>     queueURL: ${SQS_QUEUE_URL}<br>     queueLength: &quot;2&quot;<br>     awsRegion: ${AWS_REGION}<br>     identityOwner: operator<br>---<br>apiVersion: keda.sh/v1alpha1<br>kind: TriggerAuthentication<br>metadata:<br> name: keda-aws-credentials<br> namespace: ${SQS_TARGET_NAMESPACE}</pre><p>In the below demonstration you can see this all in action as follows</p><p><strong>Terminal 1 <em>(top left hand corner)</em></strong></p><p>kubectl get pods -n keda-test -w<br><em>This keeps watching the pods in the keda-test workspace, note that there are no pods at the start, and it grows as the queue length increases (terminal 2)</em></p><p><strong>Terminal 2 <em>(bottom left hand corner)</em></strong></p><p><em>This is running a script to print the sqs queue length on the screen</em></p><p><strong>Terminal 3 <em>(top right hand corner)</em></strong></p><p><em>This is running a script to push messages to the sqs queue</em></p><p><strong>Terminal 4 <em>(bottom right hand corner)</em></strong></p><p><em>This is running a script to count the number of entries in the DynamoDB table, not that the item count stays 0 while there are no pods at the start, but then start increasing as the pods come up to process the messages in the queue</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fxu2N4nFNKss%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dxu2N4nFNKss&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fxu2N4nFNKss%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2dbaa7210f30cd3a5b53a523af8fdbec/href">https://medium.com/media/2dbaa7210f30cd3a5b53a523af8fdbec/href</a></iframe><h3>Conclusion</h3><p>By adopting KEDA, you can unlock the ability to scale Kubernetes workloads based on external even-driven metrics, overcoming the limitations of HPA. This will allows you to cater to diverse scaling requirements, enabling more efficient and cost-effective scaling for your workloads. Whether it’s scaling based on external metrics like AWS CloudWatch or event sources like Kafka, KEDA provides a flexible and extensible solution to meet our growing scaling needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36eb700e7c08" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Good, Bad & The Ugly of AWS Lambda]]></title>
            <link>https://medium.com/@geethika.guruge/the-good-bad-the-ugly-of-aws-lambda-e06df5930a9?source=rss-6ba87da8eeb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e06df5930a9</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Geethika Guruge]]></dc:creator>
            <pubDate>Mon, 16 Jan 2023 04:46:35 GMT</pubDate>
            <atom:updated>2023-01-16T04:46:35.474Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Serverless technologies promises to make cloud development faster, cheaper, and more reliable; however, a badly designed serverless application can mean exactly the opposite of this. And AWS Lambda is undoubtably the single most useful serverless building block in AWS. In this post we’ll look at some of the good, the bad and the ugly of AWS Lambda usage.</p><h3>So How did we get here</h3><p>Back in the day systems administrators would prepare physical servers for software to be deployed. This would involve installing the operating system, associated device drivers, making sure there was enough memory/disk/processor available, installing any prerequisites, etc. They would also take care of hardware upgrades and so forth. This was known as a <strong>bare metal</strong> environment. There is strong coupling between the physical hardware and the deployed software and the unit of deployment was an actual server.</p><p>The next iteration was the use of <strong>virtual machines</strong>. Here instead of deploying application code into a given piece of hardware, developers were able to target a virtual server. This helped increasing the flexibility with upgrades and migrations, and also made deployments a lot more repeatable. It also enabled decoupling software from hardware, for an example if there was a hardware failure, the virtual machine could be migrated to different hardware and avoid issues.</p><p>The follow-up to virtual machines was <strong>containerized deployment</strong>. At this stage various containerization technologies like Docker etc were born. These technologies made it possible to “section off” an operating system and have different applications running on the same system without them interfering with each other. Developers could now have a lightweight environment that closely matched the production environment, leading to more consistent operations between environments.</p><p>So then we came to <strong>Serverless</strong> paradigm, which enables another level of abstraction, which is the code itself. With this new level of abstraction, engineers wouldn’t need to be as concerned “where” the code is hosted.</p><h3>The Good (Why you should use lambdas)</h3><p>One of the biggest reasons to move to serverless is that it provides On demand infrastructure, where you don’t have to keep running a server to accept that one single request you may or may not get. The code can simply be deployed into a lambda and be assured that when a request is finally received the code will be executed.</p><p>And then of course the money factor, although the cloud in general, you pay for what you use, but if you’re running a server 24/7 then you’re paying for that server for all that time. But with serverless architectures, you will only be paying for the time that your code is being executed and/or for the number of times you call your functions.</p><p>And most importantly now that all the underlying concerns are abstracted out, your team has more time to focus on improving your code. Those generic tasks such as taking care of the servers and keeping them up to date, will be taken care of by AWS.</p><h3>The Bad (When you can’t use lambdas)</h3><p>A single execution of a lambda can last only upto 15 mins. Although this is a significant amount of time especially considering that a lambda should be a single responsibility function, the bottom line is you have to be absolutely certain that your code will complete its execution under 15 mins</p><p>And given that you’ll be writing single responsibility functions, by nature, your overall architecture will get too complicated too soon, This may lead to some of the anti patterns we’ll be discussing further down this post as well.</p><p>Another consideration when building lambdas is the dependency management, any common libraries would need to be packaged with the individual lambdas, which is a terribly inefficient way of managing code, however there are improvements in this area such as usage of lambda layers and container images for lambdas. But the bottom line is it can get out of hand if you don’t plan properly</p><p>The single biggest downside of lambdas is — not all workloads are stateless. Ideally you’d want your lambda to be stateless and any state related data should be externalized. But in the interest of performance and efficiency there are some usecase you’d much rather maintain the state locally and in these cases lambdas may not be your best option.</p><h3>The Ugly (Lambda Anti Patterns)</h3><h4>Lambdalith (Lambda Monolith)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*kAxpTeBHQJzshNJ-Xz4zxQ.png" /></figure><p>When developers “lift and shift” existing code into lambdas they often end up writing one big lambda which would take care of all application logic. This may be a good starting point, but very soon this becomes an overhead and eats into your development efficiencies.</p><p>The main down sides here are</p><p><strong>The package sizes</strong> — as the lambda would a lot of work, chances are you’ll have to package lots of dependencies together with it as well.</p><p><strong>Enforcing Privileges</strong> — As the lambda is responsible of performing multiple activities its harder to enforce least privilege access in the IAM role attached to the lambda.</p><p>Further <strong>upgradability, maintainability, code reuse and unit testing</strong> will all become more challenging when the lambda is performing many tasks.</p><p>To avoid building a lambda monolith, you can always split your application logic into multiple functions and have seperate lambdas to handle those. As depicted in the below diagram, if you’re writing a web application, a good starting point would be to have separate lambdas to handle different API Gateway routes such as GET, PUT and DELETE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nIoroIyGFHOt0id-j-V3rg.png" /></figure><h4>Lambda Orchestrator</h4><p>Another common anti pattern is using Lambda as an Orchestrator</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SU2zABfkznyCKtcn-MFKnA.png" /></figure><p>For an example if we take a typical Order workflow it may look like this</p><ol><li>Customer places an order</li><li>System notifies the restaurant</li><li>Restaurant accepts the order</li><li>System notifies the customer</li><li>Food is delivered to the customer</li></ol><p>And if you try to handle this whole workflow with in one single lambda you can see the number of call going in and out of this lambda, mind you this is before you even start to include payment workflows or any error handling or retry logic. So this gets ugly very soon</p><h4>Lambda Pinball</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qiNI3QSac-xQRi-PfjAxCQ.png" /></figure><p>So in this implementation the same workflow discussed above is now split into multiple, single responsibility lambdas. However in this scenario, once you receive a request from the front end, it will be bounced around to various lambdas and if you’re lucky you’ll see some response at the other end. Troubleshooting a failed request in an implementation like this will be very challenging.</p><p>Step Functions can be used to avoid both these pitfalls. With StepFunctions you’d still write single responsibility functions, and the state machine is managed in the form of easily readable Json file.</p><h4>Invocation Loops</h4><p>If the service or resource that invokes a lambda function is as same as the service or resource that lambda function outputs to, there is a high chance of an invocation loop being created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCS7Pie6lgfr8G2cQEoC2w.png" /></figure><p>In a traditional application a similar infinite loop will eventually crash the application with an outOfMemory error or similar as the resources are limited by the physical hardware available. But as AWS is elastic, lambda will automatically scale, and so is any other services it will write to, — in the above example S3- And the result is, potentially getting a bill shock at the end of the month.</p><p>So in order to avoid such situations, you should ideally make sure that service that invokes a Lambda is different to the service that the function outputs to. If you really want to do this, you should at least</p><p><strong>Use a positive trigger</strong> — for an example using metadata to trigger the lambda only on the first S3 Put Object</p><p><strong>Use reserved concurrency</strong> for lambda so it wont scale out of hand</p><p><strong>Use Alarms</strong> (CloudWatch) so you know when it happens and even automate circuit breakers</p><h4>Lambda calling Lambda</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7atr64hv2WOuYDep2i6lA.png" /></figure><p>In this example function A calls function B which intern calls function C. If this was a traditional server based application, this synchorouns flow may be the only available option of implementation. However when it comes to serverless implementation it introduces some avoidable problems, such as</p><p><strong>Cost </strong>— as your outer most function is now running for the entire duration of the workflow, and with serverless you are paying for the duration of the function being invocated.</p><p><strong>Complex error handling</strong> — if the inner most function throws an error, outer functions may require to process special error handling logic, thereby making the implementation of those functions more complex</p><p><strong>Tight coupling</strong>- The contract of a downstream function can not be changed without affecting the outer functions,</p><p><strong>Availability &amp; Scaling</strong> — the availability of the entire workflow is limited by the slowest function, and this limits your ability to scale given the concurrency of all functions having to be equal.</p><p>In a traditional server based application these limitations may be unavoidable, but in the distributed serverless world you can easily overcome these by decoupling the functions via queues, SNS topics or even event bridge.</p><h4>Synchronous Waiting</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*APmnUPHMAHAkDw8Vm-fALQ.png" /></figure><p>In the above example a lambda function is writing to an S3 Bucket and also to a DynamoDB table. If you implement this sequentially, the wait time for the lambda is compounded.</p><p>So if the tasks are independent you can run them parallel, this way your wait time is reduced to the time taken by the longest task only.</p><p>If you can’t run them in parallel, then you can use an event driven pattern as shown in the below diagram, where your execution flow is driven by the events and lambdas become single responsibility.</p><h4>Conclusion</h4><p>As discussed in the above, although lambda is a very powerful technology which can help you achieve faster, cheaper, and more reliable cloud development, using lambdas without proper considerations into various limitations may result in exactly the opposite. Simply put Lambda is NOT a silver bullet, you can’t use it to magically modernize your legacy code. You need to re architect your workflows to make it cloud native, and ideally event driven.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e06df5930a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon CodeGuru — where code quality meets Machine Learning]]></title>
            <link>https://medium.com/@geethika.guruge/amazon-codeguru-where-code-quality-meets-machine-learning-dddd719971c0?source=rss-6ba87da8eeb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/dddd719971c0</guid>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[codeguru]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Geethika Guruge]]></dc:creator>
            <pubDate>Mon, 03 Aug 2020 13:12:38 GMT</pubDate>
            <atom:updated>2020-08-07T21:42:00.514Z</atom:updated>
            <content:encoded><![CDATA[<h3>Amazon CodeGuru — Where Code Quality meets Machine Learning</h3><p>Over the years I’ve been part of number of software development teams, and one thing remained constant in all of them, was the emphasis on code review, and code quality. As the late 2000s approached most teams started looking at ways to automate this process as much as possible. But a human code review is still required and most (good) teams would spend somewhere between 20%-30% of development time on a peer review of the code.</p><p>When AWS announced the general availability of CodeGuru, I was curious to see where does it stand in the already crowded market place of code review and application performance monitoring tools. So I set it up against a sample code base and did some playing around.</p><h3>What is CodeGuru</h3><p>CodeGuru is actually not one, but two separate services. <em>CodeGuru Reviewer</em> and <em>CodeGuru Profiler</em>. They pretty much do exactly what those names suggests. The reviewer plays in the static code analysis space competing with the likes of SonarQube, and various IDE plugins, but with some AI capabilities. And the Profiler is looking at your code from the runtime perspective, trying to find inefficiencies in the code and identify the most expensive lines of code.</p><h4><strong>Supported Platforms</strong></h4><p>CodeGuru Reviewer can only analyse Java source code, and it can be integrated with the below repositories</p><ul><li>AWS CodeCommit</li><li>Bitbucket</li><li>GitHub</li><li>GitHub Enterprise Cloud</li><li>GitHub Enterprise Server</li></ul><p>CodeGuru Profiler can provide recommendations for applications written in Java and it has some limited capabilities to provide a subset of recommendations for applications written in other JVM languages</p><h4><strong>Setting up</strong></h4><p>Attaching CodeGuru reviewer to your repository is very straight forward. It only involves login into the CodeGuru console and entering the credentials for your source provider before selecting a target repository. These steps can be found <a href="https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/step-one.html">here</a></p><p>Setting up CodeGuru profiler involves two parts. One is to setup the profiling group and associated IAM permissions, and the other is running the application with the profiling agent. Again these steps are very straight forward and can be found <a href="https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up.html">here</a></p><h3>Using CodeGuru Reviewer</h3><p>After attaching a repository, CodeGuru Reviewer is triggered by any pull requests raised in the attached repository. Once a PR is detected, the reviewer spins into action, and start making recommendations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Az17LBU7fpueM_LW4xxDHQ.png" /><figcaption>CodeGuru Reviewer in AWS Console</figcaption></figure><p>These recommendations will be of following categories.</p><ul><li>AWS best practices — i.e correct usage of the aws apis, pagination etc</li><li>Concurrency — i.e atomicity violations, excessive synchronisations etc</li><li>Resource leak prevention</li><li>Sensitive information leak prevention</li><li>Common coding best practices</li><li>Refactoring — i.e identifying duplicated code</li><li>Input validation</li></ul><p>The CodeGuru will add all the recommendations as review comments on the PR as well. The user has the ability provide feedback on the recommendations by commenting on the code in the pull request. I believe AWS uses these feedback to train their machine learning algorithms to improve CodeGuru reviewer over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*orhUIGOqSSH2tFxTY6iH1w.png" /><figcaption>CodeGuru Reviewer PR Comment</figcaption></figure><h3>Using CodeGuru Profiler</h3><p>After the profiling group is setup and the application is running with the profiling agent, the CodeGuru Profiler will collect application profiling data and this can be visualized in AWS console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4WMAIeG6pw7-SajJ902vgw.png" /><figcaption>CodeGuru Profile Visualizations</figcaption></figure><p>These visualizations are collections of stack frames that were profiled in the running application. A stack frame contains the state of one method invocation. Hoovering over a frame will show its full information including the timing details and CPU cost of the method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uOp_V5a3qlQX8Aj-y3rn_Q.png" /><figcaption>Stack Frame information</figcaption></figure><h4>CodeGuru Profiler Recommendations</h4><p>Once the CodeGuru Profiler is setup it will continuously analyse the application profiles in real-time and will identify any potential performance-impacting issues. These are then listed as recommendations under each profiling group. It is also possible to configure a SNS topic to receive notifications on any recommendation as and when they are detected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GEYf4G7oq_lmcOdRjNYvcg.png" /><figcaption>CodeGuru Profiler Recommendation</figcaption></figure><h3>Conclusion</h3><p>When I started exploring CodeGuru, I was pleasantly surprised by how easy it was to setup, compared to any other static code review tools I’ve used in the past. Also I am excited by the fact that rules and logic behind review recommendations are not static any more. This will undoubtably save a lot of time as you don’t have to maintain the underlying rules. Further another one of the most valuable capability in my opinion is its ability to identify potential concurrency issues in multithreaded code.</p><p>Looking at CodeGuru Profiler, the single biggest advantage in my opinion is its ability to tag a dollar value to your code. This will obviously give an extra insight on top of the application’s overall performance data.</p><p>All these factors combined I believe there is a very compelling case for CodeGuru to be used in your code review and application performance monitoring framework. However I do not believe it will completely remove the need of human code reviews. But teams should aim for making CodeGuru Reviewer to be the first gate of PR process, so most of the issues are ironed out before it reaches a human reviewer.</p><p>As far as CodeGuru Profiler is concerned, obviously it will not replace any of the application monitoring platforms, as its capabilities are only around monitoring the application performance. But given how well it integrates with AWS echo system, and most importantly its ability to estimate the cost of running code in certain ways, I believe CodeGuru Profiler has the potential to be an important part of your application performance monitoring platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eviZ1bXB3uDoOEm7qNzm9w.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dddd719971c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>