<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Benjamin Ajewole</title>
    <description>The latest articles on DEV Community by Benjamin Ajewole (@rexben001).</description>
    <link>https://dev.to/rexben001</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F121418%2Fe15281a4-b1eb-46d3-8466-f04316fcb31c.jpg</url>
      <title>DEV Community: Benjamin Ajewole</title>
      <link>https://dev.to/rexben001</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rexben001"/>
    <language>en</language>
    <item>
      <title>Replacing Glue Lambdas with EventBridge Pipes</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Wed, 11 Mar 2026 21:41:00 +0000</pubDate>
      <link>https://dev.to/aws-builders/replacing-glue-lambdas-with-eventbridge-pipes-40j1</link>
      <guid>https://dev.to/aws-builders/replacing-glue-lambdas-with-eventbridge-pipes-40j1</guid>
      <description>&lt;p&gt;Serverless architectures on AWS often rely on Lambda for more than business logic. In many systems, Lambda functions are used as intermediaries between event sources and downstream services, handling simple filtering, transformation, or event forwarding. Although this approach works, it can introduce unnecessary compute, more infrastructure to manage, and added complexity. EventBridge Pipes offers a more streamlined alternative by connecting sources and targets directly, reducing the need for intermediary Lambda functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Traditional Pattern
&lt;/h2&gt;

&lt;p&gt;A common approach starts with a source such as DynamoDB Streams capturing changes made to a table, after which a Lambda function consumes the stream record and forwards it to another AWS service such as SQS, EventBridge, or Step Functions. This design is flexible and familiar, but it often places Lambda in the middle of the flow even when the function is doing little more than forwarding records after light filtering or reshaping. In these cases, Lambda is being used more as infrastructure plumbing than as a true execution layer for application logic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fupwfwmgvfneq6489tb1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fupwfwmgvfneq6489tb1v.png" alt=" " width="800" height="153"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;In the traditional design, a new order written to DynamoDB triggers a Lambda function through DynamoDB Streams. Lambda then filters, transforms, and forwards the event to SQS or Step Functions.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How EventBridge Pipes Simplifies the Architecture
&lt;/h2&gt;

&lt;p&gt;EventBridge Pipes provides a more direct way to move events from a source to a target without placing a Lambda function in the middle. Instead of writing and maintaining code whose only job is to receive records from DynamoDB Streams and forward them elsewhere, you can connect the stream directly to supported targets such as EventBridge, SQS, or Step Functions. This moves filtering, transformation, and routing from custom code into a managed AWS integration, reducing the number of moving parts and making the event flow easier to understand.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdu6ypk9pjpx8iqaot7n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxdu6ypk9pjpx8iqaot7n.png" alt=" " width="800" height="129"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;In the EventBridge Pipes design, a new order written to DynamoDB flows from DynamoDB Streams into a pipe, which filters, transforms, and routes the event directly to SQS or Step Functions.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of Using EventBridge Pipes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lower operational overhead and potential latency reduction&lt;/strong&gt; With fewer Lambda functions in the middle, there are fewer deployments, permissions, logs, and runtime concerns to manage. In some cases, this can also improve end-to-end performance by removing an extra compute hop and avoiding Lambda cold starts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduces intermediary Lambda functions&lt;/strong&gt;
 EventBridge Pipes can replace Lambda functions that exist only to move events from a source to a target.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in filtering and transformation&lt;/strong&gt;
 Pipes can filter relevant events and reshape payloads before they reach the target, reducing the need for custom code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cleaner event flow&lt;/strong&gt;
 By creating a more direct connection between source and target, EventBridge Pipes makes the architecture easier to understand, maintain, and evolve.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When to Use EventBridge Pipes Instead of Lambda
&lt;/h2&gt;

&lt;p&gt;Use EventBridge Pipes instead of Lambda when your main goal is to move events from a supported source to a supported target with minimal custom processing. It is a strong fit when a Lambda function would otherwise exist only to forward, lightly filter, or reshape events, because Pipes already supports point-to-point routing, filtering, input transformation, and optional enrichment.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Lambda Is Still the Better Choice
&lt;/h2&gt;

&lt;p&gt;Lambda is still the better choice when the event requires complex business logic, external API calls, custom validation, enrichment logic that cannot be expressed cleanly through Pipes, or application-specific decision making. While EventBridge Pipes supports enrichment with services such as Lambda, API destinations, API Gateway, and Step Functions Express workflows, Pipes itself is best suited to managed integration rather than general-purpose compute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;EventBridge Pipes is most valuable when the problem is integration, not computation. If a Lambda function exists only to consume an event, discard some records, reshape others, and forward the rest, that function is often a candidate for replacement. By moving filtering, optional enrichment, and transformation into a managed source-to-target service, EventBridge Pipes can reduce infrastructure overhead and make event-driven architectures easier to reason about. Lambda still has a clear place when real application logic is required, but for simple routing flows, Pipes is often the cleaner design choice.&lt;/p&gt;

</description>
      <category>serveless</category>
      <category>events</category>
      <category>aws</category>
      <category>pipes</category>
    </item>
    <item>
      <title>AWS Durable Functions vs Step Functions: Is Code-First Orchestration the New Standard?</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Sun, 21 Dec 2025 22:47:39 +0000</pubDate>
      <link>https://dev.to/aws-builders/aws-durable-functions-vs-step-functions-a-code-first-way-to-build-serverless-workflows-28mb</link>
      <guid>https://dev.to/aws-builders/aws-durable-functions-vs-step-functions-a-code-first-way-to-build-serverless-workflows-28mb</guid>
      <description>&lt;p&gt;At the re:Invent 2025 keynote held in Las Vegas, AWS announced and launched &lt;strong&gt;Durable Functions for AWS Lambda&lt;/strong&gt;, and for many serverless developers, this marked a major shift.&lt;/p&gt;

&lt;p&gt;For the first time, AWS introduced a &lt;strong&gt;code-first approach&lt;/strong&gt; to building long-running, stateful workflows directly inside Lambda, without requiring developers to define and manage Step Functions state machines.&lt;/p&gt;

&lt;p&gt;As serverless applications grow more complex, workflows often need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pause for minutes or hours
&lt;/li&gt;
&lt;li&gt;Wait for external events
&lt;/li&gt;
&lt;li&gt;Retry safely after failures
&lt;/li&gt;
&lt;li&gt;Resume without losing state
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Until December 2025, &lt;strong&gt;AWS Step Functions&lt;/strong&gt; were the primary solution. They are powerful and reliable, but they rely on &lt;strong&gt;JSON-based workflow definitions&lt;/strong&gt; that feel disconnected from application code.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AWS Durable Functions change that model entirely.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This article explains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What AWS Durable Functions are&lt;/li&gt;
&lt;li&gt;How they work under the hood&lt;/li&gt;
&lt;li&gt;How they compare to Step Functions&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;full working example&lt;/strong&gt; (handler + CDK)&lt;/li&gt;
&lt;li&gt;Real execution screenshots&lt;/li&gt;
&lt;li&gt;IAM and deployment configuration explained&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Are AWS Durable Functions?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AWS Durable Functions&lt;/strong&gt; allow you to write &lt;strong&gt;long-running, stateful workflows directly inside a Lambda function&lt;/strong&gt; using standard code (Node.js and Python for now).&lt;/p&gt;

&lt;p&gt;Instead of defining workflows using Amazon States Language (ASL), you write normal async logic using a Durable Functions SDK.&lt;/p&gt;

&lt;p&gt;Durable Functions are called &lt;em&gt;durable&lt;/em&gt; because they:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Persist execution state automatically&lt;/li&gt;
&lt;li&gt;Resume from the last completed step&lt;/li&gt;
&lt;li&gt;Support long waits and external events&lt;/li&gt;
&lt;li&gt;Survive Lambda restarts and failures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it like writing a normal function, except AWS guarantees it will &lt;strong&gt;never forget where it left off&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Durable Function SDK: Core APIs
&lt;/h3&gt;

&lt;p&gt;The Durable Execution SDK adds orchestration primitives to Lambda:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;API&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;step(name, fn)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Executes business logic with built-in retries and automatic checkpointing.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;wait(name, duration)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Suspends execution for a specified duration (up to 1 year) without compute charges.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;waitForCallback(name)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pauses execution until an external event or human approval signal is received.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;createCallback()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Creates a callback that external systems can complete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;waitForCondition(fn)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Waits for a condition to be met by periodically checking state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;parallel(tasks)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Executes multiple branches with durable operations in parallel with optional concurrency control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;invoke(name, payload)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Invokes another durable or non-durable function with the specified input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;runInChildContext(name, fn)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runs a function in a child context with isolated state and execution tracking&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How Durable Functions Work: The Replay Model
&lt;/h2&gt;

&lt;p&gt;Durable Functions rely on a &lt;strong&gt;replay model&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here’s what happens when your function pauses:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your Lambda runs and reaches a &lt;code&gt;wait()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;AWS checkpoints the execution state&lt;/li&gt;
&lt;li&gt;The Lambda invocation ends&lt;/li&gt;
&lt;li&gt;Later, AWS &lt;strong&gt;replays the function from the beginning&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Completed steps are skipped&lt;/li&gt;
&lt;li&gt;Execution resumes from the pause point&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This allows workflows to pause for minutes, hours, or days without consuming Lambda runtime.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pro‑Tip: Determinism Is Critical
&lt;/h3&gt;

&lt;p&gt;Because of replay, orchestration code must be &lt;strong&gt;deterministic&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No &lt;code&gt;Math.random()&lt;/code&gt; during orchestration&lt;/li&gt;
&lt;li&gt;No reading current time directly&lt;/li&gt;
&lt;li&gt;No external API calls in orchestration logic&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cold Starts &amp;amp; Replay Performance
&lt;/h3&gt;

&lt;p&gt;At first glance, replay sounds expensive, but AWS optimizes heavily:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Checkpoint state is cached in the execution environment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Previously completed steps are skipped, not re-executed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cold starts only replay orchestration logic, not step bodies&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice, replay overhead is milliseconds, even for multi-step workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are AWS Step Functions?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AWS Step Functions&lt;/strong&gt; are a fully managed workflow service where logic is defined using &lt;strong&gt;Amazon States Language (ASL)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visual workflow diagrams&lt;/li&gt;
&lt;li&gt;Built-in retries and error handling&lt;/li&gt;
&lt;li&gt;Native integration with 200+ AWS services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Step Functions are excellent for &lt;strong&gt;service-heavy orchestration&lt;/strong&gt;, but they are &lt;strong&gt;configuration-first&lt;/strong&gt;, not code-first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Durable Functions vs Step Functions: Limits &amp;amp; Constraints
&lt;/h3&gt;

&lt;p&gt;This is the key question readers ask: “Why would I still use Step Functions?”&lt;/p&gt;

&lt;h4&gt;
  
  
  Durable Functions: Constraints
&lt;/h4&gt;

&lt;p&gt;State Size Limit: Durable execution checkpoint data is currently limited (≈256 KB). Large payloads should be stored externally (S3, DynamoDB).&lt;/p&gt;

&lt;p&gt;Visibility: Durable Functions rely on logs and execution history, not a visual graph UI.&lt;/p&gt;

&lt;p&gt;Extremely Long Sequences: Step Functions handle massive branching workflows (thousands of states) more efficiently than deep replay chains.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step Functions: Tradeoffs
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JSON‑heavy definitions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Harder to unit test&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Workflow logic split from application code&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both tools remain valuable; it’s about choosing the right abstraction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing Durable Functions (Huge Advantage)
&lt;/h3&gt;

&lt;p&gt;One of the biggest benefits of Durable Functions is its testability.&lt;/p&gt;

&lt;p&gt;Because workflows are just code, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Unit test orchestration logic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mock DurableContext&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use standard tools like Jest or Vitest&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { LocalDurableTestRunner } from "@aws/durable-execution-sdk-js-testing";
import { handler } from "../src/handlers/cartReminder";

describe("cartReminder handler", () =&amp;gt; {
  beforeAll(async () =&amp;gt; {
    await LocalDurableTestRunner.setupTestEnvironment({ skipTime: true });
  });

  afterAll(async () =&amp;gt; {
    await LocalDurableTestRunner.teardownTestEnvironment();
  });

  it("sends a reminder after the wait when the cart is not checked out", async () =&amp;gt; {
    const runner = new LocalDurableTestRunner({
      handlerFunction: handler,
    });

    const execution = await runner.run({
      payload: {
        userId: "user-123",
        cartId: "cart-456",
        email: "user@example.com",
      },
    });

    expect(execution.getStatus()).toBe("SUCCEEDED");
    expect(execution.getResult()).toMatchObject({
      userId: "user-123",
      cartId: "cart-456",
      email: "user@example.com",
      reminderSent: true,
      timestamp: expect.any(String),
    });
  });
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Full Working Example: Order Workflow
&lt;/h3&gt;

&lt;p&gt;This Durable Function:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Receives an event when a user adds an item to their cart&lt;/li&gt;
&lt;li&gt;Waits 24 hours&lt;/li&gt;
&lt;li&gt;Sends a reminder if the cart hasn't been checked out&lt;/li&gt;
&lt;li&gt;Returns a summary of the action taken&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Durable Function Handler (TypeScript)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {
  DurableExecutionHandler,
  withDurableExecution,
} from "@aws/durable-execution-sdk-js";

type CartReminderInput = {
  userId: string;
  cartId: string;
  email: string;
};

type CartReminderResult = {
  cartId: string;
  userId: string;
  reminderSent: boolean;
  timestamp: string;
};

export const makeHandler = () =&amp;gt; {
  const durableHandler: DurableExecutionHandler&amp;lt;
    CartReminderInput,
    CartReminderResult
  &amp;gt; = async (event, context) =&amp;gt; {
    const { cartId, userId, email } = event;
    const startTime = new Date().toISOString();

    await context.step("cart-added", async () =&amp;gt; {
      console.log(`User ${userId} added cart ${cartId} at ${startTime}`);
    });

    // Wait 24 hours before checking cart status
    await context.wait("wait-before-reminder", { hours: 24 });

    // Check if cart was already checked out (mocked logic)
    const cartCheckedOut = false; // Simulate lookup

    if (!cartCheckedOut) {
      await context.step("send-reminder", async (stepContext) =&amp;gt; {
        stepContext.logger.info("Sending cart reminder", { userId, cartId, email });
      });

      return {
        cartId,
        userId,
        email,
        reminderSent: true,
        timestamp: new Date().toISOString(),
      };
    }

    return {
      cartId,
      userId,
      email,
      reminderSent: false,
      timestamp: new Date().toISOString(),
    };
  };

  return withDurableExecution(durableHandler);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Deploying with AWS CDK
&lt;/h4&gt;

&lt;p&gt;You can deploy the Durable Function using AWS CDK with just a few steps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const customRole = new iam.Role(this, "CustomRole", {
  assumedBy: new iam.ServicePrincipal("lambda.amazonaws.com"),
});

const cartReminderFn = new NodejsFunction(this, "CartReminderFn", {
  runtime: lambda.Runtime.NODEJS_LATEST,
  entry: "../src/handlers/cartReminder/index.ts",
  handler: "handler",
  durableConfig: {
    executionTimeout: Duration.hours(25),
    retentionPeriod: Duration.days(30),
  },
  role: customRole,
});

customRole.attachInlinePolicy(
  new iam.Policy(this, "DurablePolicy", {
    statements: [
      new iam.PolicyStatement({
        actions: [
          "lambda:CheckpointDurableExecution", // Save progress
          "lambda:GetDurableExecutionState", // Resume function state
        ],
        resources: [`${cartReminderFn.functionArn}:*`],
      }),
    ],
  })
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;executionTimeout&lt;/strong&gt;: The amount of time that Lambda allows a durable function to run before stopping it, between &lt;strong&gt;a second&lt;/strong&gt; and &lt;strong&gt;366 days&lt;/strong&gt;. If exceeded, the function will fail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;retentionPeriod&lt;/strong&gt;: The duration for which AWS retains the execution history and state after the workflow completes. Useful for logs, audit, or manual retries. It must be between 1 and 90 days&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For this article, I set it to 1 minute&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Test execution
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwsocu1ojt8ebvtizo2d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwsocu1ojt8ebvtizo2d.png" alt=" " width="800" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Durable configuration &amp;amp; Executions.
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mlx9uy79z6fq97ow9a9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mlx9uy79z6fq97ow9a9.png" alt=" " width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Durable Operations
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F37zjou7iy84gplxl842a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F37zjou7iy84gplxl842a.png" alt=" " width="800" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Event History
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29hw686v3010tf68i0cu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29hw686v3010tf68i0cu.png" alt=" " width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  When Should You Use Each?
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Use Durable Functions when:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You prefer writing workflows in code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Logic is Lambda-based&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You want clean unit tests and no extra state machines&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Use Step Functions when:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You need visual debugging and monitoring&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your workflow spans many AWS services&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You prefer declarative configuration (JSON/ASL)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;The 2025 launch of AWS Durable Functions gives developers a new, elegant way to build workflows directly inside Lambda. No state machines. No JSON. Just code.&lt;/p&gt;

&lt;p&gt;If you're building serverless apps and prefer async/await to YAML and JSON, Durable Functions are made for you.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>serverless</category>
      <category>lambda</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Getting Started with Azure for AWS Professionals: A Quick Guide</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Thu, 03 Apr 2025 19:37:09 +0000</pubDate>
      <link>https://dev.to/rexben001/getting-started-with-azure-for-aws-professionals-a-quick-guide-25e8</link>
      <guid>https://dev.to/rexben001/getting-started-with-azure-for-aws-professionals-a-quick-guide-25e8</guid>
      <description>&lt;h4&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;When I started my current job, I had extensive experience with AWS but had never worked with Azure before. It wasn’t easy to get started, and I felt a bit lost navigating a new cloud platform. Mapping AWS services to their Azure equivalents helped me get up to speed. Once I saw the similarities and understood the key differences, I became more comfortable working with Azure.&lt;/p&gt;

&lt;p&gt;This guide is designed to help you do the same, quickly grasp Azure by relating it to your existing AWS knowledge. We’ll cover the most commonly used services and map them directly to what you already know, highlighting key differences and practical tips to make your transition smoother.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7uwibru1qvciedgi9urg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7uwibru1qvciedgi9urg.png" alt="EC2" width="200" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. Compute: From EC2 to Virtual Machines&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In AWS, you probably use &lt;strong&gt;EC2&lt;/strong&gt; for virtual server instances. In Azure, the equivalent is &lt;strong&gt;Virtual Machines (VMs)&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (EC2)&lt;/th&gt;
&lt;th&gt;Azure (Virtual Machines)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;EC2 Instances&lt;/td&gt;
&lt;td&gt;Virtual Machines (VMs)&lt;/td&gt;
&lt;td&gt;Azure VMs do offer integrated support for Windows workloads, aligning with Microsoft's ecosystem.​&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AMI (Amazon Machine Image)&lt;/td&gt;
&lt;td&gt;Azure Images&lt;/td&gt;
&lt;td&gt;Images are created and managed differently.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auto Scaling&lt;/td&gt;
&lt;td&gt;Virtual Machine Scale Sets (VMSS)&lt;/td&gt;
&lt;td&gt;VMSS is Azure’s native scaling service.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Azure VMs require you to specify a &lt;strong&gt;Resource Group&lt;/strong&gt; during creation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/azure/architecture/aws-professional/compute" rel="noopener noreferrer"&gt;Read more&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv8avhgoaf7zob1c15irj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv8avhgoaf7zob1c15irj.png" alt="Severless" width="200" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Serverless Computing: From Lambda to Azure Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (Lambda)&lt;/th&gt;
&lt;th&gt;Azure (Functions)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Lambda Functions&lt;/td&gt;
&lt;td&gt;Azure Functions&lt;/td&gt;
&lt;td&gt;Similar in concept, but Azure supports multiple triggers natively.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AWS Step Functions&lt;/td&gt;
&lt;td&gt;Logic Apps&lt;/td&gt;
&lt;td&gt;Step Functions focus on stateful orchestration, while Logic Apps are event-driven and connector-based.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Logic Apps are more suited for business process automation and integrating with SaaS applications, while Step Functions excel at orchestrating microservices and serverless functions.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljpeibdijqdl4yvndky4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljpeibdijqdl4yvndky4.png" alt="EKS" width="200" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Containers and Orchestration: AWS Fargate for ECS, EKS to AKS, ACI&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you’ve worked with &lt;strong&gt;AWS Fargate&lt;/strong&gt; or &lt;strong&gt;EKS&lt;/strong&gt;, Azure offers &lt;strong&gt;AKS (Azure Kubernetes Service)&lt;/strong&gt; and &lt;strong&gt;ACI (Azure Container Instances)&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (ECS/EKS)&lt;/th&gt;
&lt;th&gt;Azure (AKS/ACI)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;EKS (Elastic Kubernetes Service)&lt;/td&gt;
&lt;td&gt;AKS (Azure Kubernetes Service)&lt;/td&gt;
&lt;td&gt;AKS is fully managed and integrates with Azure AD for identity management.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AWS Fargate&lt;/td&gt;
&lt;td&gt;ACI (Azure Container Instances)&lt;/td&gt;
&lt;td&gt;Both are serverless container options. ACI is more suited for standalone containers, while Fargate works with ECS or EKS.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Use &lt;strong&gt;Azure Container Registry (ACR)&lt;/strong&gt;, similar to &lt;strong&gt;Amazon ECR&lt;/strong&gt;, for storing and managing container images. &lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa276apcmft13ibvy7wwu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa276apcmft13ibvy7wwu.png" alt="S3" width="200" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. Storage: From S3 to Blob Storage (Including Tiers)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Azure’s &lt;strong&gt;Blob Storage&lt;/strong&gt; is similar to &lt;strong&gt;S3&lt;/strong&gt;, but storage tiers differ slightly.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (S3)&lt;/th&gt;
&lt;th&gt;Azure (Blob Storage)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;S3 Buckets&lt;/td&gt;
&lt;td&gt;Blob Containers&lt;/td&gt;
&lt;td&gt;Similar structure but different tiering.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Standard&lt;/td&gt;
&lt;td&gt;Hot&lt;/td&gt;
&lt;td&gt;Similar performance and cost for frequent access.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intelligent-Tiering&lt;/td&gt;
&lt;td&gt;Cool&lt;/td&gt;
&lt;td&gt;Lower cost for infrequent access.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Glacier/Deep Archive&lt;/td&gt;
&lt;td&gt;Archive&lt;/td&gt;
&lt;td&gt;For long-term, rarely accessed data.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Azure Blob Storage supports &lt;strong&gt;Immutable Blobs&lt;/strong&gt; for data protection, similar to &lt;strong&gt;S3 Object Lock&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftnf0kvrfck94mljekr4g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftnf0kvrfck94mljekr4g.png" alt="Secrets" width="200" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. Identity and Secrets: From IAM, PCA, Secrets Manager to Azure AD, Key Vault&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Managing credentials and identity is crucial. Azure’s approach is slightly different but offers similar services.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (IAM, PCA, Secrets Manager)&lt;/th&gt;
&lt;th&gt;Azure (AD, Key Vault)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;IAM (Identity and Access Management)&lt;/td&gt;
&lt;td&gt;Azure AD (Active Directory)&lt;/td&gt;
&lt;td&gt;Azure AD has built-in SSO and enterprise identity management.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secrets Manager&lt;/td&gt;
&lt;td&gt;Azure Key Vault&lt;/td&gt;
&lt;td&gt;Both store secrets, but Key Vault also handles certificates.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amazon Certificate Manager (ACM)&lt;/td&gt;
&lt;td&gt;Azure Key Vault Certificates&lt;/td&gt;
&lt;td&gt;Manages TLS/SSL certificates.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Private Certificate Authority (PCA)&lt;/td&gt;
&lt;td&gt;Azure Key Vault Certificate Management&lt;/td&gt;
&lt;td&gt;Key Vault supports issuing and managing private certificates.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Use &lt;strong&gt;Managed Identities&lt;/strong&gt; in Azure to avoid managing secrets directly, similar to &lt;strong&gt;IAM roles&lt;/strong&gt; in AWS. Azure AD's functionalities extend beyond those of AWS IAM, encompassing broader identity management features.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9u68l3mrfa2ocjf3w7kh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9u68l3mrfa2ocjf3w7kh.png" alt="Events" width="200" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;6. Messaging and Event Handling: From SQS, SNS, EventBridge to Service Bus, Event Grid&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Azure provides comparable services for messaging and event-driven architectures.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (SQS, SNS, EventBridge)&lt;/th&gt;
&lt;th&gt;Azure (Service Bus, Event Grid)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SQS (Simple Queue Service)&lt;/td&gt;
&lt;td&gt;Service Bus Queues&lt;/td&gt;
&lt;td&gt;Service Bus supports more advanced messaging patterns.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SNS (Simple Notification Service)&lt;/td&gt;
&lt;td&gt;Service Bus Topics&lt;/td&gt;
&lt;td&gt;Topics in Service Bus support subscriptions and filters.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EventBridge&lt;/td&gt;
&lt;td&gt;Event Grid&lt;/td&gt;
&lt;td&gt;Event Grid is more integrated with Azure services.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Use &lt;strong&gt;Azure Logic Apps&lt;/strong&gt; to build workflows that react to events, similar to &lt;strong&gt;AWS Step Functions&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0gpsard59ym7jvzs0up0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0gpsard59ym7jvzs0up0.png" alt="API" width="200" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;7. API Gateway: From AWS API Gateway to Azure API Management (APIM)&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (API Gateway)&lt;/th&gt;
&lt;th&gt;Azure (APIM)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;API Gateway&lt;/td&gt;
&lt;td&gt;API Management (APIM)&lt;/td&gt;
&lt;td&gt;APIM supports versioning, throttling, and transformation out of the box.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lambda Integration&lt;/td&gt;
&lt;td&gt;Function App Integration&lt;/td&gt;
&lt;td&gt;Similar serverless backend support.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Azure’s APIM developer portal is more "built-in" and ready to use out of the box compared to AWS API Gateway, which requires manual deployment and configuration of a developer portal.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1axnc3zz5wa0n9r4fq84.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1axnc3zz5wa0n9r4fq84.png" alt="CDN" width="200" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;8. DNS and CDN: From Route 53 and CloudFront to Azure DNS and CDN&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (Route 53, CloudFront)&lt;/th&gt;
&lt;th&gt;Azure (DNS, CDN)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Route 53&lt;/td&gt;
&lt;td&gt;Azure DNS&lt;/td&gt;
&lt;td&gt;Route 53 provides DNS name management and DNS-level traffic routing and failover services.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CloudFront&lt;/td&gt;
&lt;td&gt;Azure CDN&lt;/td&gt;
&lt;td&gt;CloudFront offers Lambda@Edge, while Azure CDN integrates with Front Door.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Azure CDN supports integration with &lt;strong&gt;Azure Front Door&lt;/strong&gt; for application acceleration and global load balancing. In Azure, Azure DNS provides domain and DNS management while Traffic Manager provides DNS-level traffic routing, load balancing, and failover capabilities.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngwcnr9y1rgr7ptoq610.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngwcnr9y1rgr7ptoq610.png" alt="AI" width="200" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;9. AI and Machine Learning: From SageMaker to Azure Machine Learning&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (SageMaker)&lt;/th&gt;
&lt;th&gt;Azure (Machine Learning)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SageMaker Notebooks&lt;/td&gt;
&lt;td&gt;Azure Machine Learning Notebooks&lt;/td&gt;
&lt;td&gt;Both provide Jupyter-based environments.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SageMaker Models&lt;/td&gt;
&lt;td&gt;Azure Models&lt;/td&gt;
&lt;td&gt;Azure ML integrates tightly with &lt;strong&gt;Azure DevOps&lt;/strong&gt; for CI/CD.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Comprehend&lt;/td&gt;
&lt;td&gt;Text Analytics&lt;/td&gt;
&lt;td&gt;Similar NLP capabilities.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rekognition&lt;/td&gt;
&lt;td&gt;Computer Vision&lt;/td&gt;
&lt;td&gt;Azure offers pre-trained and customizable models.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Azure has a broader set of cognitive services for vision, speech, and language, similar to AWS AI services.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fte9c9ghz0zc0cur6gm29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fte9c9ghz0zc0cur6gm29.png" alt="CosmosDB" width="200" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;10. Database Services: From RDS, DynamoDB, Aurora to Azure SQL, Cosmos DB&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AWS and Azure both offer a wide array of database services, but their approach and feature sets differ. AWS provides managed relational and NoSQL databases through services like RDS, DynamoDB, and Aurora. Azure offers similar capabilities through Azure SQL Database, Cosmos DB, and other data services.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (RDS, DynamoDB, Aurora)&lt;/th&gt;
&lt;th&gt;Azure (SQL Database, Cosmos DB)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RDS (Relational Database Service)&lt;/td&gt;
&lt;td&gt;Azure SQL Database&lt;/td&gt;
&lt;td&gt;RDS supports multiple engines, while Azure SQL focuses on SQL Server compatibility.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Aurora.&lt;/td&gt;
&lt;td&gt;SQL Managed Instance.&lt;/td&gt;
&lt;td&gt;Aurora offers MySQL and PostgreSQL compatibility, while SQL MI offers full SQL Server support.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DynamoDB.&lt;/td&gt;
&lt;td&gt;Cosmos DB.&lt;/td&gt;
&lt;td&gt;Cosmos DB provides multi-model support, including SQL, MongoDB, Cassandra, and Graph APIs.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redshift&lt;/td&gt;
&lt;td&gt;Azure Synapse Analytics&lt;/td&gt;
&lt;td&gt;Redshift focuses on data warehousing, while Synapse integrates data lakes and big data processing.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ElastiCache&lt;/td&gt;
&lt;td&gt;Azure Cache for Redis&lt;/td&gt;
&lt;td&gt;Both provide in-memory caching but differ in their integration with other cloud services.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Choose Cosmos DB for multi-region, globally distributed apps, and Azure SQL Database for SQL Server workloads that need high availability and scaling.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwwd5wsujxuu8t7hguag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwwd5wsujxuu8t7hguag.png" alt="VPC" width="200" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;11. Networking: From VPC to VNet&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Networking is a critical aspect of both AWS and Azure, providing foundational services for connecting and managing resources.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS (VPC)&lt;/th&gt;
&lt;th&gt;Azure (VNet)&lt;/th&gt;
&lt;th&gt;Key Differences&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;VPC (Virtual Private Cloud)&lt;/td&gt;
&lt;td&gt;VNet (Virtual Network)&lt;/td&gt;
&lt;td&gt;Both provide isolated networks, but VNet natively integrates with Azure services.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Direct Connect&lt;/td&gt;
&lt;td&gt;ExpressRoute&lt;/td&gt;
&lt;td&gt;Both provide private, high-speed connectivity, but pricing and integration vary.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transit Gateway&lt;/td&gt;
&lt;td&gt;Virtual WAN&lt;/td&gt;
&lt;td&gt;Transit Gateway connects VPCs, while Virtual WAN provides a centralized networking hub.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Quick Tip:&lt;/strong&gt; Use Azure Bastion for secure RDP and SSH connectivity to VMs without exposing them to the public internet.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Transitioning from AWS to Azure doesn’t have to be overwhelming. By understanding how key services map to each other, you can quickly become proficient with Azure. Focus on familiar concepts, explore the Azure Portal and CLI, and practice building simple setups to get hands-on experience. Whether it’s compute, storage, AI, or serverless, Azure has the tools to match your AWS expertise.  &lt;/p&gt;

&lt;p&gt;Would you like more deep dives into specific services or practical migration tips? Let me know!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>azure</category>
      <category>microsoft</category>
      <category>amazon</category>
    </item>
    <item>
      <title>Leveraging AWS API Destination to Trigger External APIs</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Thu, 27 Mar 2025 19:40:00 +0000</pubDate>
      <link>https://dev.to/aws-builders/leveraging-aws-api-destination-to-trigger-external-apis-l59</link>
      <guid>https://dev.to/aws-builders/leveraging-aws-api-destination-to-trigger-external-apis-l59</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Last year, while developing an AWS solution to integrate Salesforce and Microsoft Dynamics NAV, I was tasked with designing a system to capture DynamoDB stream updates and send them to both platforms. During this process, I discovered AWS API Destinations, which provided a seamless way to securely invoke external APIs, simplifying API call management and authentication.&lt;/p&gt;

&lt;p&gt;AWS EventBridge API Destinations allow users to configure rules that securely send events to external APIs. They improve reliability by automatically retrying failed requests based on built-in retry policies. This article explores how to use API Destinations, referencing a high-level architecture diagram.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97afkv72p9q0z3q6rd8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97afkv72p9q0z3q6rd8q.png" alt="API Destination" width="800" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  High-Level Architecture explanation
&lt;/h2&gt;

&lt;p&gt;The architecture consists of the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AWS DynamoDB&lt;/strong&gt;: Acts as the primary data store.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stream Handler (AWS Lambda)&lt;/strong&gt;: This listens for changes in the DynamoDB stream and sends updates to EventBridge.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;EventBridge Event Bus&lt;/strong&gt;: Routes events to API Destination.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CloudWatch Logs&lt;/strong&gt;: Captures logs for monitoring and debugging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;API Destination&lt;/strong&gt;: Acts as an intermediary to send requests to external APIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DLQ (Dead Letter Queue)&lt;/strong&gt;: Captures failed event deliveries for further analysis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AWS Secret Manager&lt;/strong&gt;: Manages credentials for secure API authentication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Connection&lt;/strong&gt;: Defines the authorization method, credentials, and network connectivity for EventBridge to communicate securely with the external webhook.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Webhook&lt;/strong&gt;: The final external API endpoint that receives the triggered request.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Important AWS Considerations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Only Public APIs Supported&lt;/strong&gt;: API Destinations support only public domain names with publicly trusted certificates for HTTPS endpoints. Private APIs that are not publicly resolvable and mutual TLS (mTLS) authentication are not supported.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Execution Timeout&lt;/strong&gt;: Requests to API Destinations must complete within 5 seconds. If the target endpoint takes longer, EventBridge will time out the request and retry it according to the maximums set in the configured retry policy.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use Cases for AWS API Destination
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Third-party Service Integration&lt;/strong&gt;: You can easily integrate AWS event-driven architectures with SaaS platforms like Salesforce, Slack, or Stripe.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Webhook-based Notifications&lt;/strong&gt;: Automate event-driven notifications to external services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross-Cloud Communications&lt;/strong&gt;: Bridge AWS events with APIs hosted on other cloud providers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security and Compliance Monitoring&lt;/strong&gt;: Send security logs to third-party SIEM tools for real-time analysis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automated Data Synchronization&lt;/strong&gt;: Push updates from AWS services to external databases or applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Best Practices for Using API Destination
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Optimize API Response Time&lt;/strong&gt;: Since API Destination has a 5-second timeout, ensure that the external API is optimized for quick responses. Use caching or lightweight processing where possible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Utilize Dead Letter Queues (DLQ)&lt;/strong&gt;: Configure DLQs to capture failed API calls for debugging and retrying later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Monitor with CloudWatch Logs&lt;/strong&gt;: Enable logging to track API calls, errors, and response times for troubleshooting and optimization.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Leverage AWS Secrets Manager&lt;/strong&gt;: Store API keys and authentication credentials securely instead of hardcoding them in API Destination configurations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set Up Rate Limits&lt;/strong&gt;: To prevent exceeding third-party API limits, use throttling mechanisms or request prioritization strategies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Exponential Backoff for Retries&lt;/strong&gt;: Configure EventBridge retry policies to use exponential backoff, reducing the likelihood of overloading external APIs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test with Mock APIs&lt;/strong&gt;: Before integrating with a production API, use mock APIs to validate EventBridge configurations and request formatting.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Implement Security Best Practices&lt;/strong&gt;: Restrict access to API Destinations by using IAM roles and policies to prevent unauthorized access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Any HTTP Method Except CONNECT and TRACE&lt;/strong&gt;: API Destination supports various HTTP methods, excluding CONNECT and TRACE.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Leverage Input Transformers&lt;/strong&gt;: Customize event payloads to match the expected parameters of the external API endpoint, ensuring seamless integration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Understand EventBridge Retry Behavior&lt;/strong&gt;: Amazon EventBridge retries requests that receive HTTP error codes 401, 407, 409, 429, and any 5xx errors. It does not retry requests with 1xx, 2xx, 3xx, or most 4xx errors, except for the specified ones.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  AWS CDK example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create a secret for client credentials
const clientSecret = new Secret(scope, 'SecretName', {
    secretName: 'secret-name',
});

// Create a secure connection for API authentication
const connection = new Connection(stack, 'ConnectionId', {
    connectionName: 'MyConnection',
    authorization: Authorization.oauth({
        authorizationEndpoint: "authorization-url",
        clientId: "client-id",
        clientSecret: clientSecret.secretValue,
        httpMethod: HttpMethod.POST,
        bodyParameters: {
            grant_type: "client_credentials",
        },
    }),
});

// Define the API Destination
const apiDestination = new ApiDestination(stack, 'ApiDestinationId', {
    apiDestinationName: 'ApiDestination',
    connection,
    endpoint: "endpoint-url",
    httpMethod: HttpMethod.POST,
    rateLimitPerSecond: 10,
});

// Create a Dead Letter Queue (DLQ) for failed events
const deadLetterQueue = new Queue(stack, 'DLQ');

// Define an EventBridge Rule
new Rule(stack, "EventBridgeRuleId", {
    ruleName: "EventBridgeRuleId",
    eventBus: new EventBus(stack, 'MyEventBus'),
    eventPattern: {
        source: ["eventSourceName"],
        detailType: ["eventDetailType"],
    },
    targets: [
        new ApiDestinationTarget(apiDestination, {
            deadLetterQueue,
            event: { detail: { key: "value" } },
            retryAttempts: 185,
            maxEventAge: Duration.hours(24),
        }),
    ],
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;AWS API Destination simplifies the process of securely triggering external APIs based on AWS events. Developers can build robust and scalable event-driven integrations with external services by leveraging managed authentication, retry policies, and monitoring capabilities. However, when designing solutions with API Destinations, it's essential to be mindful of execution time limits and supported API types.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>salesforce</category>
      <category>async</category>
      <category>lambda</category>
    </item>
    <item>
      <title>Create Certificate Authority with AWS Private CA SDK</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Tue, 23 Apr 2024 21:00:00 +0000</pubDate>
      <link>https://dev.to/aws-builders/create-certificate-authority-with-aws-private-ca-sdk-dan</link>
      <guid>https://dev.to/aws-builders/create-certificate-authority-with-aws-private-ca-sdk-dan</guid>
      <description>&lt;p&gt;In cybersecurity, the importance of secure communication cannot be overstated. Certificates are the bedrock for establishing encrypted and authenticated connections over networks, safeguarding data integrity, confidentiality, and authenticity. When managing certificates at scale within cloud environments like Amazon Web Services (AWS), leveraging tools like AWS Private Certificate Authority (acm-pca) SDK becomes indispensable. In this article, we'll explore the fundamentals of certificates, the significance of certificate authorities, and the practical steps involved in setting up a secure infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Certificates?
&lt;/h2&gt;

&lt;p&gt;Certificates are digital documents used to establish trust between parties in a communication exchange. These certificates contain vital information like the identity of the certificate holder, public keys, and cryptographic signatures.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the usefulness of certificates?
&lt;/h2&gt;

&lt;p&gt;Certificates serve various purposes in ensuring the security of online transactions and communications, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authentication&lt;/strong&gt;: Certificates verify the identity of parties involved in a transaction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Encryption&lt;/strong&gt;: Certificates enable secure transmission of data by encrypting it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrity&lt;/strong&gt;: Certificates ensure the integrity of transmitted data, preventing tampering or unauthorized modifications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust&lt;/strong&gt;: Certificates establish trust between communicating parties, ensuring that sensitive information is shared only with trusted entities.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Components of a Certificate
&lt;/h3&gt;

&lt;p&gt;A typical certificate comprises several components, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Subject&lt;/strong&gt;: The entity to which the certificate is issued.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Issuer&lt;/strong&gt;: The entity that issues the certificate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public Key&lt;/strong&gt;: The cryptographic key used for encryption and verification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signature&lt;/strong&gt;: A digital signature created by the issuer to validate the certificate's authenticity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validity Period&lt;/strong&gt;: The duration for which the certificate remains valid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extensions&lt;/strong&gt;: Additional information such as key usage, subject alternative names, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Types of Certificates
&lt;/h3&gt;

&lt;p&gt;There are various types of certificates tailored to specific use cases, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SSL/TLS Certificates&lt;/strong&gt;: Used to secure websites and establish encrypted connections.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Signing Certificates(CSR)&lt;/strong&gt;: Ensures the authenticity and integrity of software.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email Certificates&lt;/strong&gt;: Secures email communications by encrypting and digitally signing messages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Certificate Authority (CA) certificates&lt;/strong&gt;: A Certificate Authority (CA) certificate is a digital certificate issued by a trusted Certificate Authority.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What is a certificate authority?
&lt;/h3&gt;

&lt;p&gt;A Certificate Authority (CA) is a trusted entity responsible for issuing and managing digital certificates. It verifies the identity of entities requesting certificates and signs them to establish their authenticity.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a root certificate?
&lt;/h3&gt;

&lt;p&gt;A Root Certificate is a self-signed certificate at the top of the certificate hierarchy. It represents the highest level of trust in a certificate chain and is used to sign other certificates, including intermediate certificates.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an intermediate certificate?
&lt;/h3&gt;

&lt;p&gt;An Intermediate Certificate is a subordinate certificate issued by a root certificate. It sits between the root certificate and end-entity certificates. Intermediate certificates help in enhancing security by segregating certificate issuance and revocation processes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why do I need to create an intermediate certificate?
&lt;/h3&gt;

&lt;p&gt;Creating an intermediate certificate offers several advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Security&lt;/strong&gt;: Intermediate certificates provide an additional layer of security, reducing the risk associated with compromising a root certificate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Intermediate certificates allow for better management and delegation of certificate issuance responsibilities, particularly in large-scale environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Granular Control&lt;/strong&gt;: By utilizing intermediate certificates, administrators can implement fine-grained access control and policy enforcement&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create a root and intermediate certificate with OpenSSL
&lt;/h3&gt;

&lt;p&gt;Using OpenSSL, a widely-used open-source toolkit, one can generate root and intermediate certificates. Below are the OpenSSL commands to accomplish this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Generate a root private key&lt;/span&gt;
openssl genpkey &lt;span class="nt"&gt;-algorithm&lt;/span&gt; RSA &lt;span class="nt"&gt;-out&lt;/span&gt; root.key

&lt;span class="c"&gt;# Generate a root certificate signing request&lt;/span&gt;
openssl req &lt;span class="nt"&gt;-new&lt;/span&gt; &lt;span class="nt"&gt;-key&lt;/span&gt; root.key &lt;span class="nt"&gt;-out&lt;/span&gt; root.csr

&lt;span class="c"&gt;# Self-sign the root certificate&lt;/span&gt;
openssl x509 &lt;span class="nt"&gt;-req&lt;/span&gt; &lt;span class="nt"&gt;-in&lt;/span&gt; root.csr &lt;span class="nt"&gt;-signkey&lt;/span&gt; root.key &lt;span class="nt"&gt;-out&lt;/span&gt; root.crt

&lt;span class="c"&gt;# Generate an intermediate private key&lt;/span&gt;
openssl genpkey &lt;span class="nt"&gt;-algorithm&lt;/span&gt; RSA &lt;span class="nt"&gt;-out&lt;/span&gt; intermediate.key

&lt;span class="c"&gt;# Generate an intermediate certificate signing request&lt;/span&gt;
openssl req &lt;span class="nt"&gt;-new&lt;/span&gt; &lt;span class="nt"&gt;-key&lt;/span&gt; intermediate.key &lt;span class="nt"&gt;-out&lt;/span&gt; intermediate.csr

&lt;span class="c"&gt;# Sign the intermediate certificate using the root certificate&lt;/span&gt;
openssl x509 &lt;span class="nt"&gt;-req&lt;/span&gt; &lt;span class="nt"&gt;-in&lt;/span&gt; intermediate.csr &lt;span class="nt"&gt;-CA&lt;/span&gt; root.crt &lt;span class="nt"&gt;-CAkey&lt;/span&gt; root.key &lt;span class="nt"&gt;-set-serial&lt;/span&gt; 01 &lt;span class="nt"&gt;-out&lt;/span&gt; intermediate.crt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a root and intermediate certificate with acm-pca
&lt;/h3&gt;

&lt;p&gt;AWS Private CA enables the creation of private certificate authority (CA) hierarchies, including root and intermediate/subordinate CAs. &lt;br&gt;
Using the AWS Certificate Manager Private Certificate Authority (acm-pca) SDK, you can automate the process of creating root and intermediate certificates. Here's how to achieve it using TypeScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ACMPCAClient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;IssueCertificateCommand&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;CreateCertificateAuthorityCommand&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@aws-sdk/client-acm-pca&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ACMPCAClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;us-east-1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Create Root CA&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rootCommand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CreateCertificateAuthorityCommand&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;CertificateAuthorityType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ROOT&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Specifies that this CA is a root CA  KeyAlgorithm: 'RSA_2048',&lt;/span&gt;
    &lt;span class="na"&gt;CertificateAuthorityConfiguration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;Subject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;US&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;Organization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Example Corp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;OrganizationalUnit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;IT&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;State&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;California&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;Locality&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;San Francisco&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;CommonName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Root CA&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;SerialNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;202401&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;SigningAlgorithm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;SHA256WITHRSA&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;KeyAlgorithm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;RSA_2048&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rootResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rootCommand&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rootArn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rootResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CertificateAuthorityArn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Create Intermediate CA&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;intermediateCommand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;IssueCertificateCommand&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;CertificateAuthorityArn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;rootArn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;Csr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;csrPem&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="na"&gt;SigningAlgorithm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;SHA256WITHRSA&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;TemplateArn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;arn:aws:acm-pca:::template/SubordinateCACertificate_PathLen0/V1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;Validity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;365&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;DAYS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;intermediateResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;intermediateCommand&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  AWS Private CA Templates
&lt;/h3&gt;

&lt;p&gt;AWS Private CA offers predefined templates to streamline certificate issuance for various use cases. These templates encapsulate best practices and simplify the process of generating certificates for specific scenarios.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;End Entity Certificate Template&lt;/strong&gt;: For issuing certificates directly to end entities such as servers, clients, or IoT devices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subordinate CA Certificate Template&lt;/strong&gt;: Simplifies the creation of intermediate CAs for delegating certificate issuance authority.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Root CA Certificate Template&lt;/strong&gt;: Facilitates the creation of self-signed root certificates for establishing trust within the PKI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Read more on &lt;a href="https://docs.aws.amazon.com/privateca/latest/userguide/UsingTemplates.html#template-varieties"&gt;AWS Templates&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, the AWS Private CA SDK provides a powerful toolkit for managing digital certificates, allowing organizations to establish robust security postures and ensure the integrity and confidentiality of their data. By leveraging AWS Private CA, developers can automate certificate management processes and focus on building secure and scalable applications.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>certificates</category>
      <category>awssecurity</category>
      <category>security</category>
    </item>
    <item>
      <title>Leveraging Custom Resources in AWS CloudFormation</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Sun, 03 Mar 2024 12:44:00 +0000</pubDate>
      <link>https://dev.to/aws-builders/leveraging-custom-resources-in-aws-cloudformation-4fcj</link>
      <guid>https://dev.to/aws-builders/leveraging-custom-resources-in-aws-cloudformation-4fcj</guid>
      <description>&lt;p&gt;AWS CloudFormation is a powerful AWS infrastructure-as-code service, it enables you to define and provision AWS infrastructure resources in a declarative way using JSON or YAML templates. These templates describe the desired state of the AWS environment, including resources such as VPCs, EC2 instances, S3 buckets, Step Functions, Lambda functions, and more. CloudFormation automates the provisioning and management of these resources, making it easier to deploy and maintain complex AWS architectures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limitations of CloudFormation
&lt;/h3&gt;

&lt;p&gt;While CloudFormation is an efficient tool for managing AWS resources, it does have some limitations. One major limitation is its inability to directly interact with external systems or perform actions beyond the scope of AWS services. This can be restrictive when needing to integrate with external APIs and databases or perform custom actions during stack creation or updates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Introducing Custom Resource
&lt;/h3&gt;

&lt;p&gt;To overcome the limitations of CloudFormation, AWS provides Custom Resources. Custom Resources allow you to extend CloudFormation's capabilities by incorporating custom logic or integrating with external systems during stack creation, update, or deletion. Essentially, Custom Resources enables you to define and manage AWS resources that are not natively supported by CloudFormation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Other Use Cases of Custom Resource
&lt;/h3&gt;

&lt;p&gt;Custom Resources can be utilized for various use cases, including:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Integration with External Systems&lt;/strong&gt;: Execute custom logic or interact with external APIs, databases, or services during stack operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dependency Management&lt;/strong&gt;: Manage dependencies between AWS resources that are not directly supported by CloudFormation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration Management&lt;/strong&gt;: Dynamically configure resources based on parameters or conditions not directly supported by CloudFormation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Transformation&lt;/strong&gt;: Perform data transformations or enrichments during resource creation or updates.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  CloudFormation for Creating Custom Resource
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;Resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;MyCustomResource&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Custom::MyCustomResource&lt;/span&gt;
    &lt;span class="na"&gt;Properties&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;ServiceToken&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;arn:aws:lambda:REGION:ACCOUNT_ID:function:MyCustomResourceFunction&lt;/span&gt;
      &lt;span class="na"&gt;ResourceName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;MyResource&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  CDK Code for Creating a Custom Resource
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@aws-cdk/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@aws-cdk/aws-lambda&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;cr&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@aws-cdk/custom-resources&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyCustomResourceStack&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Define the Lambda function for the Custom Resource&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myLambdaFunction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MyCustomResourceHandler&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;runtime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODEJS_20_X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;index.handler&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromAsset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lambda&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Define the Custom Resource Provider&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;cr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MyCustomResourceProvider&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;onEventHandler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;myLambdaFunction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Create the Custom Resource&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CustomResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MyCustomResource&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;serviceToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;myProvider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;serviceToken&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Custom properties for the resource if needed&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  When to Use AwsCustomResource and Provider
&lt;/h3&gt;

&lt;p&gt;AWS CDK offers two primary mechanisms for implementing Custom Resources: &lt;code&gt;AwsCustomResource&lt;/code&gt; and &lt;code&gt;Provider&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AwsCustomResource&lt;/strong&gt;: It provides a means to extend CloudFormation's capabilities by integrating custom AWS-specific logic seamlessly into the stack operations. You can use this when you have simple Custom Resource requirements and prefer a more streamlined, high-level abstraction. It's suitable for quick implementations and scenarios where simplicity outweighs advanced customization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provider&lt;/strong&gt;: When the necessity arises to communicate with external systems or services beyond the AWS ecosystem, the Provider mechanism is utilized. It allows for the integration with external APIs or services through the use of Lambda functions or SDKs. With Providers, custom logic can be efficiently managed to orchestrate interactions with external systems as part of the CloudFormation stack operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Custom Resources offers a powerful way to extend the capabilities of AWS CloudFormation beyond its native functionalities. By leveraging Custom Resources, developers can integrate with external systems, perform custom actions, and manage dependencies more effectively within CloudFormation templates. Whether it's executing AWS API calls or interacting with external services, Custom Resources provides the flexibility needed to orchestrate complex AWS environments seamlessly.&lt;/p&gt;

&lt;p&gt;Read more on Custom Resource:&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources.AwsCustomResource.html"&gt;https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources.AwsCustomResource.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources.Provider.html"&gt;https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources.Provider.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-customresource.html#cfn-cloudformation-customresource-servicetoken"&gt;https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-customresource.html#cfn-cloudformation-customresource-servicetoken&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>awcommunity</category>
      <category>cloudformation</category>
      <category>cdk</category>
    </item>
    <item>
      <title>Understanding Transactions in Amazon DynamoDB</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Mon, 12 Feb 2024 19:04:47 +0000</pubDate>
      <link>https://dev.to/aws-builders/understanding-transactions-in-amazon-dynamodb-3i40</link>
      <guid>https://dev.to/aws-builders/understanding-transactions-in-amazon-dynamodb-3i40</guid>
      <description>&lt;h3&gt;
  
  
  DynamoDB Transactions
&lt;/h3&gt;

&lt;p&gt;Maintaining data consistency and integrity is crucial, particularly in applications managing large transaction volumes. Amazon DynamoDB, a fully managed NoSQL database service provided by Amazon Web Services (AWS), offers robust solutions for handling such scenarios through its transaction support.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are Transactions?
&lt;/h3&gt;

&lt;p&gt;Within the context of databases, a transaction is a unit of work that encapsulates one or more database operations, such as reads or writes, which should be executed as a single, indivisible unit. The ACID (Atomicity, Consistency, Isolation, Durability) properties define the essential characteristics of a transaction. These properties ensure that transactions are executed reliably, consistently, and with integrity, even amidst system failures or concurrent execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  DynamoDB Transactions
&lt;/h3&gt;

&lt;p&gt;Introduced in 2018, DynamoDB transactions allow developers to perform multiple operations on one or more items atomically. This ensures that either all operations in the transaction succeed, or none of them are applied. Adhering to the principles of ACID, DynamoDB transactions assure data consistency and integrity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features of DynamoDB Transactions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Atomicity&lt;/strong&gt;: DynamoDB transactions are atomic, meaning that either all operations in the transaction succeed, or none of them is applied. This prevents partial updates or inconsistent states in the database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt;: Transactions in DynamoDB maintain the consistency of data by ensuring that all reads and writes within a transaction are isolated from other operations. This prevents concurrent modifications from interfering with the transaction’s outcome.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Isolation&lt;/strong&gt;: DynamoDB transactions provide isolation between concurrent transactions, ensuring that the effects of one transaction are not visible to others until it is committed. This prevents concurrency issues such as dirty reads, non-repeatable reads, and phantom reads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Durability&lt;/strong&gt;: Once a transaction is committed, the changes made to the database are durable and will persist even in the event of system failures or crashes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Support for Conditional Writes&lt;/strong&gt;: DynamoDB transactions support conditional writes, allowing developers to specify conditions that must be met for an operation to succeed. This feature is particularly useful for implementing business logic or enforcing data constraints within transactions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Transactional APIs
&lt;/h3&gt;

&lt;p&gt;DynamoDB offers two transactional APIs for performing transactions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transaction Write Actions&lt;/strong&gt;: This API enables developers to perform multiple Put, Update, or Delete operations within a single transaction. You can optionally include a client token when you make a TransactWriteItems call to ensure that the request is idempotent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transaction Get Actions&lt;/strong&gt;: This API allows developers to perform multiple Get operations within a single transaction, ensuring read consistency across multiple items. The Get actions are performed atomically so that either all of them succeed or all of them fail&lt;/p&gt;

&lt;h3&gt;
  
  
  TransactionCanceledException
&lt;/h3&gt;

&lt;p&gt;This exception is thrown when working with DynamoDB transactions. This exception can be thrown for different reasons including:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conditional check failed&lt;/strong&gt;: One or more conditions specified in the transaction request were not met, causing the transaction to be cancelled.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transaction conflict&lt;/strong&gt;: Another transaction concurrently modified one or more items that are part of the transaction, causing a conflict and resulting in the transaction being cancelled. DynamoDB automatically retries the transaction if this exception occurs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Item collection size exceeded&lt;/strong&gt;: The total size of the items in the transaction exceeds the maximum allowed item collection size, leading to the transaction being cancelled.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provisioned throughput limit exceeded&lt;/strong&gt;: The transaction exceeded the provisioned throughput limits for the table or index, causing the transaction to be cancelled. This can happen if the transaction rate exceeds the provisioned capacity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Cases
&lt;/h3&gt;

&lt;p&gt;DynamoDB transactions are well-suited for various use cases where data consistency and integrity are critical:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;E-commerce Platforms&lt;/strong&gt;: Ensuring inventory updates, order processing, and payment transactions are executed atomically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Financial Services&lt;/strong&gt;: Handling financial transactions, account balances, and fund transfers securely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Collaborative Editing Tools&lt;/strong&gt;: Synchronizing concurrent edits to documents or collaborative projects without conflicts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;p&gt;When working with DynamoDB transactions, it’s essential to adhere to best practices to maximize performance, scalability, and reliability:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep Transactions Short&lt;/strong&gt;: Minimize the duration of transactions to reduce the likelihood of conflicts and improve throughput.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Batch Operations&lt;/strong&gt;: Utilize batch operations whenever possible to reduce the number of round trips to the DynamoDB service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimistic Concurrency Control&lt;/strong&gt;: Use optimistic concurrency control to handle conflicts by detecting concurrent modifications and retrying transactions when necessary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monitor Performance&lt;/strong&gt;: Monitor transaction throughput, latency, and error rates using Amazon CloudWatch metrics to identify and address performance bottlenecks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let’s incorporate examples using the SDK (Software Development Kit) for DynamoDB transactions.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;br&gt;
We want to ensure that when a customer places an order, we deduct the purchased items from the inventory and record the order details atomically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { DynamoDBClient, TransactWriteItemsCommand } from "@aws-sdk/client-dynamodb";

// Create a DynamoDBClient instance
const client = new DynamoDBClient({
    region: 'eu-west-1'
});

// Define the parameters for the transaction
const params = {
  TransactItems: [
    {
      Update: {
        TableName: 'InventoryTable',
        Key: { productId: 'product1' },
        UpdateExpression: 'SET quantity = quantity - :quantity',
        ConditionExpression: 'quantity &amp;gt;= :quantity',
        ExpressionAttributeValues: { ':quantity': 1 },
        ReturnValuesOnConditionCheckFailure: 'ALL_OLD'
      }
    },
    {
      Put: {
        TableName: 'OrderTable',
        Item: {
          orderId: 'order123',
          productId: 'product1',
          quantity: 1,
          customerName: 'John Doe'
        },
      }
    }
  ]
};

try {
    const command = new TransactWriteItemsCommand(params);
    const data = await client.send(command);
    console.log('Transaction executed successfully:', data);
} catch (err) {
    console.error('Unable to execute transaction. Error:', err);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;br&gt;
We want to implement a transaction that allows a user to like a post and update the corresponding user’s and post’s data atomically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { DynamoDBClient, TransactWriteItemsCommand } from "@aws-sdk/client-dynamodb";


const client = new DynamoDBClient({
    region: 'eu-west-1'
});

const params = {
    TransactItems: [
        {
            Update: {
                TableName: 'PostsTable',
                Key: { postId: 'post123'},
                UpdateExpression: 'SET likes = likes + :increment',
                ExpressionAttributeValues: { ':increment': 1 }
            }
        },
        {
            Update: {
                TableName: 'UsersTable',
                Key: { userId: 'user456' },
                UpdateExpression: 'ADD likedPosts :postIds',
                ExpressionAttributeValues: { ':postIds': ['post123'] }
            }
        },
        {
            Update: {
                TableName: 'PostsTable',
                Key: { postId: 'post123' },
                UpdateExpression: 'ADD likedBy :userIds',
                ExpressionAttributeValues: { ':userIds': ['user456'] }
            }
        }
    ]
};

try {
    const command = new TransactWriteItemsCommand(params);
    const data = await client.send(command);
    console.log('Transaction executed successfully:', data);
} catch (err) {
    console.error('Unable to execute transaction. Error:', err);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Amazon DynamoDB transactions provide developers with powerful tools for ensuring data consistency and integrity in high-throughput applications. By adhering to the principles of ACID and offering support for atomic, consistent, isolated, and durable transactions, DynamoDB equips developers to build robust and reliable systems capable of handling complex transactional workflows. Understanding and effectively leveraging DynamoDB transactions are essential for building scalable and resilient applications on AWS.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>dynamodb</category>
      <category>databasetransactions</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Prevent Lambda cold start using CDK</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Mon, 11 Sep 2023 22:10:36 +0000</pubDate>
      <link>https://dev.to/aws-builders/prevent-lambda-cold-start-using-cdk-461p</link>
      <guid>https://dev.to/aws-builders/prevent-lambda-cold-start-using-cdk-461p</guid>
      <description>&lt;p&gt;A notable challenge within the realm of serverless architecture lies in the phenomenon known as "cold starts." A cold start occurs when a fresh instance of a function must be generated and initialized before processing an incoming request. While cold starts may not significantly impact applications that don't require an immediate response, such as background tasks or batch processes, they can pose substantial challenges when your AWS Lambda functions are integrated with API Gateway and are expected to deliver responses with minimal latency.&lt;br&gt;
In scenarios where API Gateway and Lambda are closely coupled, cold starts can lead to delays in serving requests, affecting the overall responsiveness and user experience of your application.&lt;/p&gt;

&lt;p&gt;There are different ways to prevent Lambda cold start&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provisioned concurrency&lt;/li&gt;
&lt;li&gt;Cold start times are affected by the memory allocated to your Lambda function. Higher memory allocations come with more CPU power and network bandwidth.&lt;/li&gt;
&lt;li&gt;Reducing the size of your deployment packages generally leads to quicker cold start times. Achieve this by eliminating superfluous dependencies, files, or libraries from your deployment bundle and opting for minimalistic runtime environments whenever feasible.&lt;/li&gt;
&lt;li&gt;Create a specialized warm-up process, like a Lambda warm-up function, that triggers your Lambda function at regular intervals to ensure it remains in a warmed state. Another approach is to schedule recurring CloudWatch Events that invoke your function periodically, preventing it from experiencing full cold starts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Provisioned Concurrency?
&lt;/h4&gt;

&lt;p&gt;Provisioned concurrency initializes a requested number of execution environments so that they are prepared to respond immediately to your function's invocations. Note that configuring provisioned concurrency incurs charges to your AWS account.&lt;br&gt;
With provisioned concurrency, you don't need to worry about cold starts because your Lambda functions will be in a warm state ready to respond immediately without initializations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lambda Warm State Setup with CDK
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as lambdaEventSources from 'aws-cdk-lib/aws-lambda-event-sources';

const myLambda = new lambda.Function(this, 'MyLambda', {
  runtime: lambda.Runtime.NODEJS_14_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('path/to/lambda-code'),
  memorySize: 256,
});

const aliasOptions = {
  aliasName: 'MyAlias',
  version: myLambda.currentVersion,
  provisionedConcurrentExecutions: 2 //there will always be at least two Lambda functions running
};

new lambda.Alias(this, 'MyLambdaAlias', aliasOptions);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Apart from using provisioned concurrency, you can spend more time on making sure your Lambda function code is highly efficient by minimizing unnecessary initialization and resource allocation during function execution. You can also minimize the number of external dependencies your Lambda function relies on. Fewer dependencies mean less initialization work when the function starts.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
    </item>
    <item>
      <title>Different ways to invoke AWS Lambda Functions</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Sun, 10 Sep 2023 22:36:07 +0000</pubDate>
      <link>https://dev.to/aws-builders/different-ways-to-invoke-aws-lambda-functions-2iaf</link>
      <guid>https://dev.to/aws-builders/different-ways-to-invoke-aws-lambda-functions-2iaf</guid>
      <description>&lt;p&gt;&lt;a href="https://aws.amazon.com/lambda/" rel="noopener noreferrer"&gt;AWS Lambda&lt;/a&gt; is a Serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers. You can trigger Lambda from over 200 AWS services and software-as-a-service (SaaS) applications and only pay for what you use.&lt;/p&gt;

&lt;p&gt;Check out my previous posts on &lt;a href="https://dev.to/aws-builders/setup-cicd-for-your-aws-lambda-with-serverless-framework-and-github-actions-4f12"&gt;how to create a Lambda function and deploy it the CI/CD way&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;AWS Lambda can be invoked in several ways which include through the Lambda console, a function URL HTTP(S) endpoint, the Lambda API, Amazon API Gateway, an AWS SDK, the AWS Command Line Interface (AWS CLI), and AWS toolkits. You can also configure other AWS services to invoke your function, or you can configure Lambda to read from a stream or queue and invoke your function.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will be covering how to invoke using the Lambda console, function URL, AWS SDK and the AWS Command Line Interface (AWS CLI).&lt;/p&gt;

&lt;h3&gt;
  
  
  Invoking your Lambda function through the Lambda console
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Lambda function&lt;/li&gt;
&lt;li&gt;Click on Test&lt;/li&gt;
&lt;li&gt;Input an Event Name and click on Invoke, this will invoke the function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A4800%2F1%2ABIz1M0n4qo9c0tzdjzCT_g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A4800%2F1%2ABIz1M0n4qo9c0tzdjzCT_g.gif" alt="Lambda Console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Invoking your Lambda function through the function URL
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Function URLs are not supported in the following regions: Asia Pacific (Hyderabad) (ap-south-2), Asia Pacific (Melbourne) (ap-southeast-4), Europe (Spain) (eu-south-2), Europe (Zurich) (eu-central-2), Israel (Tel Aviv) (il-central-1), and Middle East (UAE) (me-central-1)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Follow these steps to create a function URL for your Lambda function&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Lambda console&lt;/li&gt;
&lt;li&gt;Click on the Configuration tab&lt;/li&gt;
&lt;li&gt;Click on Function URL&lt;/li&gt;
&lt;li&gt;Click on Create Function URL&lt;/li&gt;
&lt;li&gt;Select None and click on Save&lt;/li&gt;
&lt;li&gt;Open the link on your browser&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A4800%2F1%2ABIz1M0n4qo9c0tzdjzCT_g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A4800%2F1%2ABIz1M0n4qo9c0tzdjzCT_g.gif" alt="Lambda Function URL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Invoking your Lambda function using AWS SDK
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {InvokeCommand, LambdaClient} from "@aws-sdk/client-lambda";

const client = new LambdaClient({
region: "eu-west-1"
});

client.send(new InvokeCommand({
  FunctionName: "helloWord"
}))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Invoking your Lambda function using AWS CLI
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# run this following commands

aws configure #configure aws cli

aws lambda invoke - function-name helloWorld response.json # invoke lambda function

cat response.json # read the response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy coding!!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
      <category>serverless</category>
      <category>awscommunitybuilder</category>
    </item>
    <item>
      <title>Understanding AWS Fargate (Serverless Container or CaaS)</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Mon, 01 Aug 2022 12:20:55 +0000</pubDate>
      <link>https://dev.to/aws-builders/understanding-aws-fargate-serverless-container-or-caas-4kd7</link>
      <guid>https://dev.to/aws-builders/understanding-aws-fargate-serverless-container-or-caas-4kd7</guid>
      <description>&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/userguide/what-is-fargate.html"&gt;AWS Fargate&lt;/a&gt; is a technology you can use with Amazon ECS to run containers without managing servers or clusters of Amazon EC2 instances. With Fargate, you no longer have to provision, configure, or scale clusters of virtual machines to run containers. This removes the need to choose server types, decide when to scale your clusters or optimize cluster packing. It's both compatible with AWS ECS and AWS EKS.&lt;/p&gt;

&lt;p&gt;AWS Fargate is also referred to as Container as a Service (CaaS). &lt;a href="https://www.atlassian.com/microservices/cloud-computing/containers-as-a-service"&gt;Containers as a service (CaaS)&lt;/a&gt; is a cloud-based service that allows software developers and IT departments to upload, organize, run, scale, and manage containers by using container-based virtualization.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are Containers?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/learn/what-are-containers#:~:text=Containers%20are%20packages%20of%20software,on%20a%20developer's%20personal%20laptop."&gt;Containers&lt;/a&gt; are packages of software that contain all of the necessary elements to run in any environment. In this way, containers virtualize the operating system and run anywhere, from a private data center to the public cloud or even on a developer's personal laptop.&lt;/p&gt;

&lt;p&gt;With Amazon ECS, you can choose between two launch types: Fargate launch type (AWS managed) and Amazon EC2 launch type(User managed).&lt;/p&gt;

&lt;h3&gt;
  
  
  What difference between Fargate and EC2 launch types?
&lt;/h3&gt;

&lt;p&gt;EC2 lets you create your own cluster, while Fargate allows you to simply deploy your containers to AWS' cluster, saving you the time and effort of managing your own machines and clusters.&lt;/p&gt;

&lt;p&gt;Costs differ for EC2 and AWS Fargate. With EC2, billing is based on the cost of the EC2 instances used; AWS Fargate also charges for CPU cores and memory consumed.&lt;/p&gt;

&lt;h3&gt;
  
  
  What problems does AWS Fargate solve?
&lt;/h3&gt;

&lt;p&gt;One of AWS Fargate's main advantages is a solution to the challenges of hosting, scaling and managing cloud infrastructure to run containerized applications. Amazon Fargate abstracts infrastructure operations, devoting more effort to creating containerized applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  How AWS Fargate works?
&lt;/h3&gt;

&lt;p&gt;The steps in the deployment cycle are:&lt;br&gt;
1) Build a container image&lt;br&gt;
2) Host your container image on AWS ECR or DockerHub&lt;br&gt;
3) Choose an orchestration service: Amazon ECS or Amazon EKS&lt;br&gt;
4) Create a Cluster taking the AWS Fargate option&lt;/p&gt;

&lt;h3&gt;
  
  
  Cons of AWS Fargate?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Less Customization&lt;/strong&gt;: AWS Fargate is not well-suited for users or organisations that want to have greater control over their containers.&lt;br&gt;
&lt;strong&gt;Not cost-effective for small workloads&lt;/strong&gt;: If you have a ton of small services which are rarely used, it can be a lot cheaper to use EC2 instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of AWS Fargate?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Reduce Complexity&lt;/strong&gt;: AWS Fargate is a container as a service, so you don't need to worry about where and how to manage and scale your containers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Better Security&lt;/strong&gt;: AWS handles the security of your infrasctructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS Fargate pricing?
&lt;/h3&gt;

&lt;p&gt;AWS Fargate pricing is calculated based on the vCPU, memory, Operating Systems, CPU Architecture, and storage resources used per second. Read more here: &lt;a href="https://aws.amazon.com/fargate/pricing/"&gt;https://aws.amazon.com/fargate/pricing/&lt;/a&gt;&lt;br&gt;
How to get started with AWS Fargate?&lt;br&gt;
&lt;a href="https://aws.amazon.com/fargate/getting-started/"&gt;https://aws.amazon.com/fargate/getting-started/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/fargate-getting-started.html"&gt;https://docs.aws.amazon.com/eks/latest/userguide/fargate-getting-started.html&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setup CI/CD for your AWS Lambda with Serverless Framework and GitHub Actions</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Sat, 05 Feb 2022 11:36:49 +0000</pubDate>
      <link>https://dev.to/aws-builders/setup-cicd-for-your-aws-lambda-with-serverless-framework-and-github-actions-4f12</link>
      <guid>https://dev.to/aws-builders/setup-cicd-for-your-aws-lambda-with-serverless-framework-and-github-actions-4f12</guid>
      <description>&lt;p&gt;Previously I wrote about how to &lt;a href="https://dev.to/rexben001/create-a-serverless-backend-with-aws-lambda-function-and-amazon-api-gateway-3d9l"&gt;Create a Serverless backend with AWS Lambda Function, Amazon API Gateway and Serverless Framework&lt;/a&gt;. In that tutorial, I showed you how to create, test and deploy your serverless app to AWS Lambda and Amazon API Gateway manually but in this tutorial, I'll be showing you how to deploy it using CI/CD.&lt;/p&gt;

&lt;h4&gt;
  
  
  What's CI/CD?
&lt;/h4&gt;

&lt;p&gt;CI/CD stands for continuous integration, continuous deployment and continuous delivery. It's a process that alienates manual processes of doing things. It is the art of automating the process of building, testing, deployment and delivery of apps to your customers. There are different tools used for CI/CD, they include &lt;a href="https://www.jenkins.io/" rel="noopener noreferrer"&gt;Jenkins&lt;/a&gt;, &lt;a href="https://github.com/features/actions" rel="noopener noreferrer"&gt;GitHub Actions&lt;/a&gt;, &lt;a href="https://docs.gitlab.com/ee/ci/" rel="noopener noreferrer"&gt;GitLab CI&lt;/a&gt;, &lt;a href="https://circleci.com/" rel="noopener noreferrer"&gt;CircleCI&lt;/a&gt;, &lt;a href="https://www.travis-ci.com/" rel="noopener noreferrer"&gt;Travis CI&lt;/a&gt;, &lt;a href="https://bitbucket.org/product/features/pipelines" rel="noopener noreferrer"&gt;Bitbucket Pipelines&lt;/a&gt;, &lt;a href="https://aws.amazon.com/codebuild/" rel="noopener noreferrer"&gt;AWS CodeBuild&lt;/a&gt;, &lt;a href="https://aws.amazon.com/codedeploy/" rel="noopener noreferrer"&gt;AWS CodeDeploy&lt;/a&gt;, &lt;a href="https://aws.amazon.com/codepipeline/" rel="noopener noreferrer"&gt;AWS CodePipeline&lt;/a&gt; and many more.&lt;/p&gt;

&lt;p&gt;In this tutorial, I'll be using AWS, Serverless framework and GitHub Actions&lt;/p&gt;

&lt;h4&gt;
  
  
  GitHub Actions
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://docs.github.com/en/actions" rel="noopener noreferrer"&gt;GitHub Actions&lt;/a&gt; automate, customize, and execute your software development workflows right in your repository with GitHub Actions. You can discover, create, and share actions to perform any job you'd like, including CI/CD, and combine actions in a completely customized workflow.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prerequisites to follow along:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Have a GitHub account&lt;/li&gt;
&lt;li&gt;Fork and clone this repo (contains code from my &lt;a href="https://dev.to/rexben001/create-a-serverless-backend-with-aws-lambda-function-and-amazon-api-gateway-3d9l"&gt;previous tutorial&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Have an AWS account&lt;/li&gt;
&lt;li&gt;Create an &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html" rel="noopener noreferrer"&gt;AWS IAM user&lt;/a&gt; that has the following permissions: &lt;strong&gt;IAMFullAccess&lt;/strong&gt;, &lt;strong&gt;AmazonS3FullAccess&lt;/strong&gt;, &lt;strong&gt;CloudWatchFullAccess&lt;/strong&gt;, &lt;strong&gt;AWSCloudFormationFullAccess&lt;/strong&gt;, &lt;strong&gt;AWSLambda_FullAccess&lt;/strong&gt; and &lt;strong&gt;AmazonAPIGatewayInvokeFullAccess&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Store the AWS user API key and secret key (keep it safe)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Create a main.yml file to define the workflow configuration
&lt;/h4&gt;

&lt;p&gt;After ticking all the prerequisites, create a file called main.yml in folder &lt;code&gt;.github/workflows&lt;/code&gt; and paste this code&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;A workflow is a configurable automated process made up of one or more jobs. &lt;/p&gt;

&lt;h5&gt;
  
  
  Workflow syntax
&lt;/h5&gt;

&lt;p&gt;&lt;strong&gt;name&lt;/strong&gt;: the name of the workflow&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;on&lt;/strong&gt;: the type of event that can run the workflow. Our workflow will only run when there's a git push to either the master or develop branch. Read more &lt;a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;jobs&lt;/strong&gt;: a workflow consists of one or more jobs. Jobs run in parallel unless a &lt;code&gt;needs&lt;/code&gt; keyword is used. Each job runs in a runner environment specified by &lt;code&gt;runs-on&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;steps&lt;/strong&gt;: sequence of tasks to be carried out&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;uses&lt;/strong&gt;: selects an action to run as part of a step in your job. An action is a reusable unit of code. Read more &lt;a href="https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;with&lt;/strong&gt;: a map of input parameters&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;run&lt;/strong&gt;: runs command-line programs&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;env&lt;/strong&gt;: set the environment variables&lt;/p&gt;

&lt;h4&gt;
  
  
  Add API key and secret key to GitHub secret
&lt;/h4&gt;

&lt;p&gt;Go to &lt;strong&gt;settings&lt;/strong&gt; on the forked repo to add your API Key and Secret key. Click on &lt;strong&gt;Secrets&lt;/strong&gt; on the left side nav and click on &lt;strong&gt;New repository secret&lt;/strong&gt; to add your secrets. The API Key and Secret Key gives us programmatic access to your AWS environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwtitf408r436n10xa5ym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwtitf408r436n10xa5ym.png" alt="GitHub Secrets"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Push changes to GitHub to start the workflow
&lt;/h4&gt;

&lt;p&gt;You can now commit your changes locally and push it to GitHub. Navigate the repo on GitHub, click on the actions, you should be able to see your workflows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5jv8nheu07diumw667q0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5jv8nheu07diumw667q0.png" alt="GitHub workflows"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Extra resources
&lt;/h5&gt;

&lt;p&gt;You can see the full project &lt;a href="https://github.com/Rexben001/aws-lambda-serverless-starter/tree/develop" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
Read the &lt;a href="https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions" rel="noopener noreferrer"&gt;docs&lt;/a&gt; to know more about GitHub actions&lt;br&gt;
Read more about Serverless framework &lt;a href="https://www.serverless.com/framework/docs/providers/aws/guide/intro" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
Learn more about AWS &lt;a href="https://aws.amazon.com/training/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Create a Serverless backend with AWS Lambda Function, Amazon API Gateway and Serverless framework</title>
      <dc:creator>Benjamin Ajewole</dc:creator>
      <pubDate>Tue, 23 Nov 2021 22:30:28 +0000</pubDate>
      <link>https://dev.to/rexben001/create-a-serverless-backend-with-aws-lambda-function-amazon-api-gateway-and-serverless-framework-5063</link>
      <guid>https://dev.to/rexben001/create-a-serverless-backend-with-aws-lambda-function-amazon-api-gateway-and-serverless-framework-5063</guid>
      <description>&lt;p&gt;Serverless backend may also be called Backend as a Service (Baas) and Function as a Service(Faas).&lt;/p&gt;

&lt;p&gt;According to Wikipedia, &lt;strong&gt;Serverless computing&lt;/strong&gt; is a cloud computing execution model in which the cloud provider allocates machine resources on-demand, taking care of the servers on behalf of their customers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros of a Serverless architecture
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Serverless is inherently scalable, it will be able to handle an unusually high number of requests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Low cost and more efficient because you only pay when your Serverless function is running&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy to deploy and update&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No server management is required&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Cons of a Serverless architecture
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Serverless is not built for long-running processing, it has a time frame. For instance, AWS Lambda timeout after 15 minutes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is difficult to debug because you will be dependent on your providers for debugging and monitoring tools&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Long-running processing could be more costly on serverless compared to a dedicated server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It may take some time for your serverless backend to handle that first function request, so, you might need to keep it in a running state.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I will be creating a Serverless backend endpoint that returns information about the client’s OS information with the following tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Serverless framework&lt;/strong&gt; — a more general-purpose tool for deploying and managing &lt;strong&gt;serverless&lt;/strong&gt; application&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AWS Lambda&lt;/strong&gt; — a serverless compute service that lets you run code without provisioning or managing servers, creating workload-aware cluster scaling logic, maintaining event integrations, or managing runtimes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;API Gateway&lt;/strong&gt; — a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Nodejs&lt;/strong&gt; — a JavaScript runtime built on Chrome’s V8 JavaScript engine&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  To get started:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You must already have &lt;a href="https://nodejs.org/en/download/"&gt;Nodejs&lt;/a&gt; installed on your local machine,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;you also have an &lt;a href="https://aws.amazon.com/resources/create-account/"&gt;AWS account&lt;/a&gt;,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;you also have to create an &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html#id_users_create_console"&gt;IAM user&lt;/a&gt; with programmatic access but for the sake of this article, I’ll be using the root user,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;copy the access key id and secret access key from your &lt;a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html"&gt;AWS console&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Install &lt;a href="https://www.serverless.com/"&gt;Serverless&lt;/a&gt; framework globally using npm&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g serverless
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Configure serverless AWS credentials&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;serverless config credentials --provider aws --key AKJAPB7TR3*** --secret ****F4WA1JfG1sx9+7/+kKg/a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Replace the key and secret you copied from your AWS console. You can use serverless with different providers like Azure, AWS, GCP etc.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Create a serverless project using the Serverless AWS Nodejs template&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;serverless create --template aws-nodejs --path clientOs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above command will create a folder called *clientOs *and inside this folder, you’ll see the following files/folders:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;.serverless folder (&lt;em&gt;This folder contains generated CloudFormation file and zipped bundle&lt;/em&gt;, &lt;em&gt;the folder gets regenerated every time you run&lt;/em&gt; &lt;strong&gt;serverless deploy&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;.gitignore file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;handler.js file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;serverless.yml file ( &lt;em&gt;This file contains serverless deployment configuration&lt;/em&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;handler.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict';
const os = require('os');

module.exports.getOsInfo = async (event) =&amp;gt; {
  return {
    statusCode: 200,
    body: JSON.stringify(
      {
        osName: os.hostname(),
        osPlatform: os.platform(),
        osCPU: os.cpus(),
        // 1mb = 1048576
        osMemory: os.totalmem() / 1048576,
      },
      null,
      2
    ),
  };
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I updated the &lt;em&gt;handler.js&lt;/em&gt; to get client’s operating system information. All I did was to import &lt;em&gt;os&lt;/em&gt; from Nodejs library and call different methods like hostname(), platform() etc.&lt;/p&gt;

&lt;p&gt;serverless.yml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service: clientos

provider:
  name: aws
  runtime: nodejs12.x

functions:
  getOsInfo:
    handler: handler.getOsInfo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also updated the &lt;em&gt;serverless.yml&lt;/em&gt; with the new function we just created. I added &lt;em&gt;getOsInfo&lt;/em&gt; function.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Test the function locally&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sls invoke local -f getOsInfo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Deploy the function to AWS&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sls deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can login into your AWS console, search for Lambda, under functions, you’ll see your newly deployed function&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Amazon API Gateway&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/api-gateway/"&gt;Amazon API Gateway&lt;/a&gt; is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the “front door” for applications to access data, business logic, or functionality from your backend services. Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications. API Gateway supports containerized and serverless workloads, as well as web applications.&lt;/p&gt;

&lt;p&gt;I am going to create an API endpoint for the &lt;em&gt;getOsInfo&lt;/em&gt; function using AmazonAPI Gateway. It’s quite easy with serverless framework, all you need to do is to add some lines of code in serverless.yml and deploy&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;events:
  - http:
      path: client/os
      method: get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We add events with the type http, then the route and the API method which is get.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service: clientos

provider:
  name: aws
  runtime: nodejs12.x

functions:
  getOsInfo:
    handler: handler.getOsInfo
    events:
      - http:
         path: client/os
         method: get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your updated serverless.yml should look like this.&lt;/p&gt;

&lt;p&gt;Deploy the function to AWS&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sls deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check your console, you should see something like this&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;endpoints:
  GET - [https://shs8k2mrea.execute-api.us-east-1.amazonaws.com/dev/](https://shs8k2ryia.execute-api.us-east-1.amazonaws.com/dev/say/hello)client/os
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can copy the URL and test it on your browser or Postman or whichever tool you prefer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We learnt the definition of Serverless computing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We learnt the pros and cons of Serverless&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We learnt how to create a serverless backend with API using serverless framework, AWS Lambda, Amazon API Gateway and Nodjes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We learnt how to test functions locally&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We learnt how to deploy functions&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In my next article, I'll be showing you how to deploy your serverless applications using cloudFormation templates&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
