<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Serverless on {O}</title>
    <link>https://omarmakled.com/tags/serverless/</link>
    <description>Recent content in Serverless on {O}</description>
    <generator>Hugo -- 0.151.1</generator>
    <language>en-us</language>
    <atom:link href="https://omarmakled.com/tags/serverless/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Building a Practical Serverless API with SAM: Leveraging Nested Stacks for Organization</title>
      <link>https://omarmakled.com/posts/sam-nested/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-nested/</guid>
      <description>&lt;p&gt;This example demonstrates how to build and deploy a simple &lt;strong&gt;serverless API&lt;/strong&gt; using &lt;strong&gt;AWS Lambda&lt;/strong&gt;, &lt;strong&gt;API Gateway&lt;/strong&gt;, and &lt;strong&gt;AWS SAM&lt;/strong&gt; (Serverless Application Model). The core focus here is on leveraging &lt;strong&gt;modularity&lt;/strong&gt; and &lt;strong&gt;nested stacks&lt;/strong&gt; to create a well-organized and scalable project structure.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;project-structure&#34;&gt;Project Structure&lt;/h3&gt;
&lt;p&gt;Here&amp;rsquo;s a quick overview of the project&amp;rsquo;s key components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;api.yaml&lt;/code&gt;&lt;/strong&gt;: This SAM file defines the &lt;strong&gt;API Gateway&lt;/strong&gt;. It&amp;rsquo;s responsible for linking HTTP paths (like &lt;code&gt;/orders&lt;/code&gt; and &lt;code&gt;/logs&lt;/code&gt;) to the appropriate Lambda Functions. Crucially, it imports the API definition from &lt;code&gt;openapi.yaml&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;log.yaml&lt;/code&gt;&lt;/strong&gt;: This SAM file contains the definition for the &lt;strong&gt;Lambda Function&lt;/strong&gt; responsible for fetching logs (&lt;code&gt;GetLogs&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;order.yaml&lt;/code&gt;&lt;/strong&gt;: This SAM file contains the definition for the &lt;strong&gt;Lambda Function&lt;/strong&gt; responsible for fetching orders (&lt;code&gt;GetOrders&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;openapi.yaml&lt;/code&gt;&lt;/strong&gt;: This is the &lt;strong&gt;OpenAPI (Swagger) file&lt;/strong&gt; that specifies the API paths (e.g., &lt;code&gt;/orders&lt;/code&gt;, &lt;code&gt;/logs&lt;/code&gt;) and how they integrate with the Lambda Functions. Here, we define the &lt;code&gt;x-amazon-apigateway-integration&lt;/code&gt; that links each path to the ARN of the relevant Lambda Function.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;template.yaml&lt;/code&gt;&lt;/strong&gt;: This is the &lt;strong&gt;main SAM template&lt;/strong&gt; for your project. It acts as an orchestrator for all the sub-stacks (&lt;code&gt;OrderStack&lt;/code&gt;, &lt;code&gt;LogStack&lt;/code&gt;, &lt;code&gt;ApiStack&lt;/code&gt;). Each sub-stack points to its respective YAML file using the &lt;code&gt;Location&lt;/code&gt; property of &lt;code&gt;AWS::Serverless::Application&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&#34;why-modularity-and-nested-stacks&#34;&gt;Why Modularity and Nested Stacks?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Modularity &amp;amp; Organization:&lt;/strong&gt;  When you split your project into separate files like &lt;code&gt;order.yaml&lt;/code&gt;, &lt;code&gt;log.yaml&lt;/code&gt;, and &lt;code&gt;api.yaml&lt;/code&gt;, your project becomes easier to organize and understand. Each file focuses on one part of the app, so it&amp;rsquo;s easier to work on and update, especially when the project gets bigger.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Serverless Image Processing with AWS SAM: Uploads, Thumbnails &amp; S3 Events</title>
      <link>https://omarmakled.com/posts/sam-s3-event/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-s3-event/</guid>
      <description>&lt;p&gt;This example demonstrates a robust serverless architecture on AWS for handling file uploads and automated thumbnail generation. It leverages &lt;strong&gt;AWS SAM (Serverless Application Model)&lt;/strong&gt;, &lt;strong&gt;Lambda functions&lt;/strong&gt;, &lt;strong&gt;API Gateway&lt;/strong&gt;, and &lt;strong&gt;S3 event notifications&lt;/strong&gt; to create a streamlined and scalable image processing pipeline.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;project-structure&#34;&gt;Project Structure&lt;/h3&gt;
&lt;p&gt;Here&amp;rsquo;s a quick overview of the project&amp;rsquo;s key components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;functions/&lt;/code&gt;&lt;/strong&gt;: Contains the core Lambda function code:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;event.mjs&lt;/code&gt;: Handles S3 event notifications, triggering the thumbnail generation process.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;upload.mjs&lt;/code&gt;: Manages the initial file upload through API Gateway.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;layers/nodejs/&lt;/code&gt;&lt;/strong&gt;: A Lambda layer containing shared code and dependencies for the functions:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;lib/utils.mjs&lt;/code&gt;: Common utility functions.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;package.json&lt;/code&gt; &amp;amp; &lt;code&gt;package-lock.json&lt;/code&gt;: Node.js dependencies for the layer.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;template.yaml&lt;/code&gt;&lt;/strong&gt;: The AWS SAM template defining the serverless resources: Lambda functions, API Gateway endpoints, S3 buckets, and their respective permissions and event triggers.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&#34;how-it-works&#34;&gt;How It Works&lt;/h3&gt;
&lt;p&gt;The workflow is straightforward and efficient:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Serverless Messaging with AWS SAM: SNS, SQS, and Lambda</title>
      <link>https://omarmakled.com/posts/sam-sns-sqs/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-sns-sqs/</guid>
      <description>&lt;p&gt;This example shows how to build a &lt;strong&gt;serverless messaging pipeline&lt;/strong&gt; using &lt;strong&gt;AWS SAM&lt;/strong&gt;. The project uses &lt;strong&gt;SNS&lt;/strong&gt; to publish messages, &lt;strong&gt;SQS&lt;/strong&gt; queues to separate concerns, and &lt;strong&gt;Lambda functions&lt;/strong&gt; to process the data. It also uses &lt;strong&gt;filter policies&lt;/strong&gt; to control message delivery to each queue.&lt;/p&gt;
&lt;p&gt;This architecture is useful when you want to send different types of data to different consumers, and keep your application components decoupled.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;project-structure&#34;&gt;Project Structure&lt;/h3&gt;
&lt;p&gt;The template defines:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Customizing Cognito Emails with AWS SAM and Lambda</title>
      <link>https://omarmakled.com/posts/sam-cognito-custom-message/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-cognito-custom-message/</guid>
      <description>&lt;p&gt;This example shows how to use &lt;strong&gt;AWS SAM&lt;/strong&gt; to create a user sign-up system (&lt;strong&gt;Cognito&lt;/strong&gt;) and change the automatic emails it sends, like account verification or password reset emails. This is a great method if you want your application&amp;rsquo;s messages to match your brand&amp;rsquo;s style.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;project-components&#34;&gt;Project Components&lt;/h3&gt;
&lt;p&gt;The project has two main files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;cognito-email/index.js&lt;/code&gt;&lt;/strong&gt;: This file contains a simple &lt;strong&gt;Lambda&lt;/strong&gt; function. Its job is to change the content of the emails.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;template.yaml&lt;/code&gt;&lt;/strong&gt;: This file tells AWS what to build. It includes:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cognito User Pool&lt;/strong&gt;: The place where user data is saved.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lambda Function&lt;/strong&gt;: A simple function that runs when needed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Permissions&lt;/strong&gt;: These allow Cognito to call the Lambda function.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&#34;how-it-works&#34;&gt;How It Works&lt;/h3&gt;
&lt;p&gt;This setup customizes the email messages that Cognito sends in different user flows, such as:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Serverless API Monitoring with AWS SAM: Lambda, API Gateway &amp; CloudWatch Alarms</title>
      <link>https://omarmakled.com/posts/sam-api-alaram/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-api-alaram/</guid>
      <description>&lt;p&gt;This example demonstrates how to build a lightweight, serverless API using &lt;strong&gt;AWS SAM (Serverless Application Model)&lt;/strong&gt; while integrating real-time error monitoring and email alerts using &lt;strong&gt;CloudWatch Alarms&lt;/strong&gt; and &lt;strong&gt;SNS&lt;/strong&gt;. This pattern is ideal for production-ready serverless applications that need observability without heavy tooling.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;project-structure&#34;&gt;Project Structure&lt;/h3&gt;
&lt;p&gt;The project includes the following core components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;functions/&lt;/code&gt;&lt;/strong&gt;: Contains the Lambda function that handles HTTP requests:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;app.mjs&lt;/code&gt;: Returns a simple response (e.g., &amp;ldquo;Hello World&amp;rdquo;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;template.yaml&lt;/code&gt;&lt;/strong&gt;: The SAM template defining resources including:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lambda Function&lt;/strong&gt; (hello handler)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;API Gateway&lt;/strong&gt; (to expose the function via HTTP)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CloudWatch Alarm&lt;/strong&gt; (monitors API 5XX errors)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SNS Topic &amp;amp; Subscription&lt;/strong&gt; (sends email alerts)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&#34;how-it-works&#34;&gt;How It Works&lt;/h3&gt;
&lt;p&gt;This architecture sets up an API and monitors its availability in real time:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Organizing Serverless Code with AWS SAM: Lambda Layers and Testing with Jest</title>
      <link>https://omarmakled.com/posts/sam-jest/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-jest/</guid>
      <description>&lt;p&gt;This example demonstrates how to build &lt;strong&gt;clean, testable, and modular serverless applications&lt;/strong&gt; on AWS using &lt;strong&gt;AWS SAM&lt;/strong&gt;, &lt;strong&gt;Lambda Layers&lt;/strong&gt;, and &lt;strong&gt;Jest&lt;/strong&gt;. It focuses on two essential practices for scalable serverless development:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using &lt;strong&gt;Lambda Layers&lt;/strong&gt; to share code across functions&lt;/li&gt;
&lt;li&gt;Using &lt;strong&gt;Jest&lt;/strong&gt; to properly test each function and its dependencies&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By combining these two patterns, you get a powerful structure that’s maintainable, reusable, and confidently testable.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;project-overview-shared-logic--layer-for-node-modules--testing&#34;&gt;Project Overview: Shared Logic + Layer for Node Modules + Testing&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;functions/&lt;/code&gt;&lt;/strong&gt; – Your Lambda function handlers:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
