<?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>AWS on {O}</title>
    <link>https://omarmakled.com/tags/aws/</link>
    <description>Recent content in AWS on {O}</description>
    <generator>Hugo -- 0.151.1</generator>
    <language>en-us</language>
    <atom:link href="https://omarmakled.com/tags/aws/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>Deploy a Python App to AWS with Elastic Beanstalk &amp; Terraform</title>
      <link>https://omarmakled.com/posts/eb-terraform/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/eb-terraform/</guid>
      <description>&lt;p&gt;This example shows how to build and deploy a &lt;strong&gt;simple Python application&lt;/strong&gt; using &lt;strong&gt;AWS Elastic Beanstalk&lt;/strong&gt; for managed hosting and &lt;strong&gt;Terraform&lt;/strong&gt; for infrastructure as code. The &lt;code&gt;deploy.sh&lt;/code&gt; script automates the application packaging and deployment process.&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;app/&lt;/code&gt;&lt;/strong&gt;: Contains the Python application, &lt;code&gt;main.py&lt;/code&gt;, along with &lt;code&gt;Procfile&lt;/code&gt; for defining the web server, and &lt;code&gt;requirements.txt&lt;/code&gt; for Python dependencies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;terraform/&lt;/code&gt;&lt;/strong&gt;: Holds all the Terraform configuration files (&lt;code&gt;.tf&lt;/code&gt;) that define the AWS infrastructure:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;main.tf&lt;/code&gt;: Defines the core AWS resources like the S3 bucket for application versions, IAM roles for Elastic Beanstalk, and the Elastic Beanstalk application and environment themselves.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;variables.tf&lt;/code&gt;: Declares input variables for customizability (e.g., AWS region, instance type).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;outputs.tf&lt;/code&gt;: Exports important values like the S3 bucket name and the Elastic Beanstalk environment URL.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;deploy.sh&lt;/code&gt;&lt;/strong&gt;: A shell script that orchestrates the deployment process:
&lt;ul&gt;
&lt;li&gt;Reads outputs from Terraform to get dynamic values.&lt;/li&gt;
&lt;li&gt;Zips the &lt;code&gt;app/&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;Uploads the zipped application to the designated S3 bucket.&lt;/li&gt;
&lt;li&gt;Creates a new Elastic Beanstalk application version.&lt;/li&gt;
&lt;li&gt;Updates the Elastic Beanstalk environment to use the new version.&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;First, Terraform provisions all necessary AWS resources for Elastic Beanstalk. Then, the &lt;code&gt;deploy.sh&lt;/code&gt; script automates the rest: it fetches deployment details from Terraform, zips your Python application, uploads it to S3, and finally, updates your Elastic Beanstalk environment with this new application version.&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>Host Static Website on AWS with Terraform, S3, and CloudFront</title>
      <link>https://omarmakled.com/posts/s3-cloudfront/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/s3-cloudfront/</guid>
      <description>&lt;p&gt;This example outlines a method for deploying static websites on &lt;strong&gt;Amazon Web Services (AWS)&lt;/strong&gt; using &lt;strong&gt;Terraform&lt;/strong&gt; for infrastructure as code, &lt;strong&gt;Amazon S3&lt;/strong&gt; for content storage, and &lt;strong&gt;Amazon CloudFront&lt;/strong&gt; for global content delivery. The deployment process is fully automated.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;project-structure&#34;&gt;Project Structure&lt;/h3&gt;
&lt;p&gt;Below is an overview of the project&amp;rsquo;s key directories and files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;public/&lt;/code&gt;&lt;/strong&gt;: Contains the static website assets, such as &lt;code&gt;index.html&lt;/code&gt; and &lt;code&gt;404.html&lt;/code&gt;. These are the files that will be served to users.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;terraform/&lt;/code&gt;&lt;/strong&gt;: This directory holds all the Terraform configuration files (&lt;code&gt;.tf&lt;/code&gt;) responsible for provisioning and managing AWS resources.
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;main.tf&lt;/code&gt;: Defines the core AWS resources, including the S3 bucket and CloudFront distribution.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;variables.tf&lt;/code&gt;: Contains input variables to parameterize the Terraform configuration (e.g., bucket names, domain names).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;outputs.tf&lt;/code&gt;: Specifies output values that are useful after Terraform applies the configuration, such as the CloudFront distribution domain name.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;deploy.sh&lt;/code&gt;: A shell script to execute the Terraform plan and apply the infrastructure, including uploading static files to S3.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;destroy.sh&lt;/code&gt;: A shell script to tear down all provisioned AWS resources.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Project Repository:&lt;/strong&gt; &lt;a href=&#34;https://github.com/OmarMakled/aws-terraform-s3&#34;&gt;https://github.com/OmarMakled/aws-terraform-s3&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Organize AWS Lambda Projects with Nested Stacks and Layers in SAM</title>
      <link>https://omarmakled.com/posts/sam-layer/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-layer/</guid>
      <description>&lt;p&gt;This example shows how to build a &lt;strong&gt;modular AWS Lambda project&lt;/strong&gt; using &lt;strong&gt;SAM (Serverless Application Model)&lt;/strong&gt; with &lt;strong&gt;nested stacks&lt;/strong&gt; and a &lt;strong&gt;shared layer&lt;/strong&gt;. This helps keep your project clean and organized by separating logic and shared dependencies.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&#34;how-it-works&#34;&gt;How It Works&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;layer.yaml&lt;/code&gt;&lt;/strong&gt; creates a shared Lambda Layer that contains Node.js packages (like &lt;code&gt;axios&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;order.yaml&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;log.yaml&lt;/code&gt;&lt;/strong&gt; are two Lambda functions that use this shared layer.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;root template (&lt;code&gt;template.yaml&lt;/code&gt;)&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Creates the layer stack.&lt;/li&gt;
&lt;li&gt;Passes the layer reference to the other stacks as a parameter.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sam build
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sam deploy --guided
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Project Repository:&lt;/strong&gt; &lt;a href=&#34;https://github.com/OmarMakled/sam-nested-layer&#34;&gt;https://github.com/OmarMakled/sam-nested-layer&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>AWS SAM Nested Stacks for a Structured GraphQL API</title>
      <link>https://omarmakled.com/posts/sam-graphql/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-graphql/</guid>
      <description>&lt;p&gt;This example provides a structured approach to deploying a &lt;strong&gt;Serverless GraphQL API&lt;/strong&gt; using &lt;strong&gt;AWS Serverless Application Model (SAM)&lt;/strong&gt;, leveraging &lt;strong&gt;Nested Stacks&lt;/strong&gt; for modularity.&lt;/p&gt;
&lt;h3 id=&#34;project-structure-modular-stacks&#34;&gt;Project Structure: Modular Stacks&lt;/h3&gt;
&lt;p&gt;The core idea is to break down the infrastructure into specialized, manageable units using SAM&amp;rsquo;s Nested Stacks. This separation enhances clarity, reusability, and maintainability.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Root Template&lt;/strong&gt; acts as the orchestrator, defining the dependencies between the smaller stacks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;RolesStack&lt;/code&gt; (stacks/roles.yaml):&lt;/strong&gt; Creates the necessary &lt;strong&gt;IAM Roles&lt;/strong&gt; for Lambda execution and for AppSync to invoke the Lambda function.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;GraphQLStack&lt;/code&gt; (stacks/graphql.yaml):&lt;/strong&gt; Provisions the &lt;strong&gt;AWS AppSync GraphQL API&lt;/strong&gt;, including the API itself, the API Key, and the Schema definition (which is assumed to be uploaded to an S3 location).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;FunctionsStack&lt;/code&gt; (stacks/functions.yaml):&lt;/strong&gt; Deploys the &lt;strong&gt;Lambda function&lt;/strong&gt;, the &lt;strong&gt;AppSync Data Source&lt;/strong&gt;, and the &lt;strong&gt;Resolvers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;query.graphql&lt;/code&gt;&lt;/strong&gt; the schema definition can also be split into smaller files (types, queries, and mutations). These fragments are then merged into a single final schema file (schema.graphql).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The best thing about this design is that everything is &lt;strong&gt;organized and independent&lt;/strong&gt;. Each group of functions or resources is in its own box (stack).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Understanding AWS Lambda Functions</title>
      <link>https://omarmakled.com/posts/sam-lambda/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-lambda/</guid>
      <description>&lt;h3 id=&#34;what-is-aws-lambda&#34;&gt;What is AWS Lambda?&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;AWS Lambda&lt;/strong&gt; is a &lt;strong&gt;serverless computing service&lt;/strong&gt; from Amazon.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No servers to manage&lt;/strong&gt; – AWS handles all the infrastructure.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Automatic scaling&lt;/strong&gt; – if 10,000 users call your API, AWS runs 10,000 copies of your function.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cost-efficient&lt;/strong&gt; – you pay only for execution time, not idle time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fast to deploy&lt;/strong&gt; – perfect for small tasks or microservices.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id=&#34;how-does-it-work&#34;&gt;How does it work?&lt;/h3&gt;
&lt;p&gt;Each Lambda function is triggered by an &lt;strong&gt;event&lt;/strong&gt; — like an HTTP request, a file upload, or a message. When that event happens, AWS automatically runs your code.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Using Parameters vs. Export/Import in AWS SAM: What’s Better?</title>
      <link>https://omarmakled.com/posts/sam-import-vs-export/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://omarmakled.com/posts/sam-import-vs-export/</guid>
      <description>&lt;p&gt;When you build serverless applications with AWS SAM or CloudFormation, sometimes you need to &lt;strong&gt;share resources between stacks&lt;/strong&gt;. For example, you may have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;Cognito User Pool&lt;/strong&gt; in one stack (for user authentication)&lt;/li&gt;
&lt;li&gt;And an &lt;strong&gt;API Gateway&lt;/strong&gt; in another stack that needs to use that Cognito pool&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are two main ways to connect these stacks:&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;option-1-using-parameters&#34;&gt;Option 1: Using Parameters&lt;/h2&gt;
&lt;p&gt;You can pass values like the &lt;strong&gt;User Pool ARN&lt;/strong&gt; or &lt;strong&gt;ID&lt;/strong&gt; as a parameter when you deploy the second stack.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
