<?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>API Gateway on {O}</title>
    <link>https://omarmakled.com/tags/api-gateway/</link>
    <description>Recent content in API Gateway on {O}</description>
    <generator>Hugo -- 0.151.1</generator>
    <language>en-us</language>
    <atom:link href="https://omarmakled.com/tags/api-gateway/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>Build a Simple API on AWS with Lambda, API Gateway, and SAM</title>
      <link>https://omarmakled.com/posts/lambda-api-sam/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/lambda-api-sam/</guid>
      <description>&lt;p&gt;This example shows 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 API fetches a list of todos from a public endpoint and returns them via an HTTP GET request.&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 Lambda function &lt;code&gt;ListTodos.mjs&lt;/code&gt;, which fetches todo items from a public API using Axios.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;tests/&lt;/code&gt;&lt;/strong&gt;: Contains a Jest test to ensure the function returns items with a 200 status code.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;layers/&lt;/code&gt;&lt;/strong&gt;: Optional shared layer for common dependencies (e.g., axios), defined under &lt;code&gt;nodejs/package.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;template.yaml&lt;/code&gt;&lt;/strong&gt;: AWS SAM template that defines the infrastructure:
&lt;ul&gt;
&lt;li&gt;Lambda function (&lt;code&gt;ListTodosFunction&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;API Gateway (&lt;code&gt;/posts&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Shared Layer&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;When a client makes a &lt;code&gt;GET&lt;/code&gt; request to &lt;code&gt;/todos&lt;/code&gt;, the Lambda function is triggered, fetches data from &lt;code&gt;https://jsonplaceholder.typicode.com/todos?_limit=3&lt;/code&gt;, and returns it as JSON.&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 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>
  </channel>
</rss>
