<?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: Manusha Chethiyawardhana</title>
    <description>The latest articles on DEV Community by Manusha Chethiyawardhana (@manusha17).</description>
    <link>https://dev.to/manusha17</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%2F917357%2F97886fe7-d4c4-4c98-b5be-a19413d1f189.webp</url>
      <title>DEV Community: Manusha Chethiyawardhana</title>
      <link>https://dev.to/manusha17</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manusha17"/>
    <language>en</language>
    <item>
      <title>It’s 2026: Stop Using AWS IAM and Start Using IAM Identity Center</title>
      <dc:creator>Manusha Chethiyawardhana</dc:creator>
      <pubDate>Sun, 11 Jan 2026 07:18:17 +0000</pubDate>
      <link>https://dev.to/aws-builders/its-2026-stop-using-aws-iam-and-start-using-iam-identity-center-18f0</link>
      <guid>https://dev.to/aws-builders/its-2026-stop-using-aws-iam-and-start-using-iam-identity-center-18f0</guid>
      <description>&lt;p&gt;For over a decade, AWS Identity and Access Management (IAM) users were the standard for accessing AWS accounts. Developers created IAM users, generated Access Keys and Secret Keys, and stored them in &lt;code&gt;~/.aws/credentials&lt;/code&gt; files or, worse, hardcoded them into applications.&lt;/p&gt;

&lt;p&gt;It is now 2026. The cloud landscape has matured, and security best practices have evolved. The era of long-lived IAM user credentials should be over. If you are still managing individual IAM users for your team members, you are incurring unnecessary security risks and operational overhead. The modern standard is &lt;strong&gt;AWS IAM Identity Center&lt;/strong&gt; (formerly AWS Single Sign-On). Even though AWS recommended using Identity Center over IAM users for more than 2 years, I still see industry accounts clinging to the same old setup, fearing migration.&lt;/p&gt;

&lt;p&gt;This article explores why traditional IAM users are obsolete for human access, the benefits of Identity Center, and how to migrate your organization today.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with Traditional IAM Users
&lt;/h2&gt;

&lt;p&gt;While IAM users are still necessary for certain service accounts or specific edge cases, they are fundamentally flawed for human access in a modern, multi-account environment.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The Security Risk of Long-Lived Credentials&lt;br&gt;
When you create an IAM user, you typically generate an Access Key ID and a Secret Access Key. These credentials do not expire by default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Leakage:&lt;/strong&gt; If a developer accidentally commits these keys to a public GitHub repository, attackers can access your account within seconds.&lt;br&gt;
&lt;strong&gt;Rotation Fatigue:&lt;/strong&gt; Enforcing key rotation policies is manual and often ignored, leading to “stale” keys that remain valid for years after an employee has left or changed roles.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Operational Overhead at Scale&lt;br&gt;
Managing IAM users becomes a nightmare as your organization grows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Siloed Identities:&lt;/strong&gt; If you have three AWS accounts (Dev, Staging, Prod), you often end up creating three separate IAM users for the same developer.&lt;br&gt;
&lt;strong&gt;Policy Drift:&lt;/strong&gt; Ensuring that “John Doe” has the exact same permissions across all accounts requires complex synchronization of policies. Instead of fine-grained access, administrators would likely rely on granting broader access levels.&lt;br&gt;
&lt;strong&gt;Onboarding/Offboarding:&lt;/strong&gt; Revoking access requires an administrator to log into every single AWS account and manually delete the user or keys.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lack of Centralized Visibility&lt;br&gt;
With individual IAM users scattered across multiple accounts, auditing “who has access to what” requires aggregating data from every single account. There is no single pane of glass for workforce identity, so it is easy for mistakes to go unnoticed.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Solution: IAM Identity Center
&lt;/h2&gt;

&lt;p&gt;AWS IAM Identity Center is the recommended service for managing human access to AWS resources. It builds on the concepts of Single Sign-On (SSO) to provide a centralized, secure, and user-friendly access management system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Identity Center&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Short-Term Credentials:&lt;/strong&gt; Identity Center uses temporary security credentials. When a user logs in, they receive a token that expires automatically (e.g., after 8 hours). There are no permanent access keys to leak.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Centralized Multi-Account Access:&lt;/strong&gt; You manage users and groups in one place. You can grant the “Developers” group access to 20 different AWS accounts with a single configuration change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration with Identity Providers (IdP):&lt;/strong&gt; You don’t need to create new users in AWS. Identity Center connects with Microsoft Entra ID (Azure AD), Okta, Google Workspace, or Ping Identity. Users log in with their existing organization credentials.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved CLI Experience:&lt;/strong&gt; The AWS CLI integrates natively with Identity Center. Developers run aws sso login, authorize via their browser, and their terminal is automatically configured with valid credentials.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting Up IAM Identity Center (New Setup)
&lt;/h2&gt;

&lt;p&gt;If you are starting fresh, setting up Identity Center is straightforward.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An AWS Organization (Not mandatory, but a recommended best practice).&lt;/li&gt;
&lt;li&gt;Administrative access to the Management Account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Enable Identity Center&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to the IAM Identity Center console in your Management Account.&lt;/li&gt;
&lt;li&gt;Click Enable.&lt;/li&gt;
&lt;li&gt;Choose whether to enable it in the AWS Region where your organization is based.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Choose Your Identity Source&lt;/strong&gt;&lt;br&gt;
By default, AWS provides a built-in Identity Store. However, for most businesses, you might have to connect to an external IdP.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to Settings &amp;gt; Identity source.&lt;/li&gt;
&lt;li&gt;Select Actions &amp;gt; Change identity source.&lt;/li&gt;
&lt;li&gt;Choose External identity provider.&lt;/li&gt;
&lt;li&gt;Download the AWS metadata file and upload it to your IdP (e.g., Okta or Google Workspace).&lt;/li&gt;
&lt;li&gt;Upload your IdP’s SAML metadata file back to AWS.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Create Permission Sets&lt;/strong&gt;&lt;br&gt;
A Permission Set is essentially a managed IAM Policy template.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to Permission sets &amp;gt; Create permission set.&lt;/li&gt;
&lt;li&gt;Select a Predefined permission set (e.g., AdministratorAccess or ViewOnlyAccess) or create a Custom one.&lt;/li&gt;
&lt;li&gt;Define the session duration (e.g., 8 hours).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Assign Users to Accounts&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to AWS accounts.&lt;/li&gt;
&lt;li&gt;Select the AWS accounts you want to grant access to.&lt;/li&gt;
&lt;li&gt;Click Assign users or groups.&lt;/li&gt;
&lt;li&gt;Select the Users/Groups (synced from your IdP) and the Permission Sets they should have.
Note: For more streamlined management, create Groups rather than adding individual users to accounts.
Once configured, your users will receive a User Portal URL (e.g., &lt;code&gt;https://my-org.awsapps.com/start&lt;/code&gt;). They can log in there and see every AWS account they have access to.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Migration Guide: Moving from IAM to Identity Center
&lt;/h2&gt;

&lt;p&gt;Migrating from an existing IAM user base can be challenging, but with proper planning, it can be completed without disrupting workflows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 1: Parallel Adoption&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set up Identity Center as described above.&lt;/li&gt;
&lt;li&gt;Map Permissions: Audit your existing IAM Groups. Create equivalent Permission Sets in Identity Center.&lt;/li&gt;
&lt;li&gt;Onboard Teams: Ask a pilot team to start using the aws sso login workflow instead of their Access Keys.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Tip: If you use complex inline policies, when mapping permissions, convert them to Customer Managed Policies so they can be easily attached to Permission Sets (or you can add them directly as an inline policy to the permission set).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Prerequisite: AWS CLI Version 2 is required. You can follow &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" rel="noopener noreferrer"&gt;this guide&lt;/a&gt; to install or update it.&lt;/p&gt;

&lt;p&gt;Developers need to update their local &lt;code&gt;~/.aws/config&lt;/code&gt; files. Instead of static profiles, they will use SSO profiles.&lt;br&gt;
Run the automatic configuration wizard:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws configure sso
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or manually update the config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[profile my-sso-profile]
sso_session = my-session
sso_account_id = 123456789012
sso_role_name = AdministratorAccess
region = us-east-1
output = json

[sso-session my-session]
sso_start_url = https://my-org.awsapps.com/start
sso_region = us-east-1
sso_registration_scopes = sso:account:access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Phase 2: The “Scream Test” (Soft Deprecation)&lt;/strong&gt;&lt;br&gt;
Once teams are comfortable with the new login flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identify IAM users that correspond to humans.&lt;/li&gt;
&lt;li&gt;Deactivate (do not delete) their Access Keys in the IAM Console.&lt;/li&gt;
&lt;li&gt;Wait for complaints. If a script or tool breaks, you can instantly reactivate the key while you help the user migrate that tool to an IAM Role or the SSO workflow.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Phase 3: Cleanup&lt;/strong&gt;&lt;br&gt;
After a period of stability (e.g., 30 days):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Delete the IAM Users.&lt;/li&gt;
&lt;li&gt;Update your onboarding documentation to point strictly to the Identity Center portal.&lt;/li&gt;
&lt;li&gt;Implement Service Control Policies (SCPs) in AWS Organizations to prevent the creation of new IAM Users (except for specific break-glass scenarios).&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;In 2026, the overhead and risk associated with long-term IAM credentials are no longer acceptable. AWS IAM Identity Center provides a robust, scalable, and secure mechanism for managing workforce identity.&lt;/p&gt;

&lt;p&gt;By centralizing access, integrating with your corporate IdP, and enforcing short-term credentials, you significantly improve your security posture while simplifying the login experience for your engineers.&lt;/p&gt;

&lt;p&gt;Stop managing keys. Start managing identities.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>tutorial</category>
      <category>devops</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Troubleshooting Async AWS Lambda Flows</title>
      <dc:creator>Manusha Chethiyawardhana</dc:creator>
      <pubDate>Thu, 10 Aug 2023 17:43:32 +0000</pubDate>
      <link>https://dev.to/aws-builders/troubleshooting-async-aws-lambda-flows-5bod</link>
      <guid>https://dev.to/aws-builders/troubleshooting-async-aws-lambda-flows-5bod</guid>
      <description>&lt;p&gt;Asynchronous invocation of AWS Lambda functions is a powerful feature that allows event producers and consumers to be decoupled, facilitating efficient and scalable event processing.&lt;/p&gt;

&lt;p&gt;It enables developers to create highly scalable and responsive applications. However, troubleshooting async Lambda flows may present significant complexities, necessitating familiarity with techniques and tools to overcome these challenges.&lt;/p&gt;

&lt;p&gt;This article will provide an overview of troubleshooting techniques for asynchronous AWS Lambda flows and discuss some best practices for handling errors and retries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Asynchronous Invocation Overview
&lt;/h2&gt;

&lt;p&gt;AWS services such as &lt;a href="https://aws.amazon.com/s3/" rel="noopener noreferrer"&gt;Amazon S3&lt;/a&gt;, &lt;a href="https://aws.amazon.com/sns/" rel="noopener noreferrer"&gt;Amazon SNS&lt;/a&gt;, &lt;a href="https://aws.amazon.com/sqs/" rel="noopener noreferrer"&gt;Amazon SQS&lt;/a&gt;, and &lt;a href="https://aws.amazon.com/eventbridge/" rel="noopener noreferrer"&gt;Amazon EventBridge&lt;/a&gt; can invoke Lambda functions asynchronously. When a Lambda function is invoked asynchronously, the event is placed in a queue, and the caller does not need to wait for the function to complete its execution. Instead, Lambda takes over the responsibility of processing the event. It is possible to configure Lambda to handle errors and send invocation records to a downstream resource that supports asynchronous invocations, which allows for connecting various components of your application.&lt;/p&gt;

&lt;p&gt;By setting the invocation type parameter to “Event,” you can enable asynchronous invocation. An example AWS CLI command to invoke an async function is shown below. If you are using AWS CLI version 2, the &lt;code&gt;cli-binary-format&lt;/code&gt; option is required.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ aws lambda invoke \
--function-name myAsyncFunction \
--invocation-type Event \
--cli-binary-format raw-in-base64-out \
--payload '{ "name": "value" }' response.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the response you get when the event is queued would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "StatusCode": 202
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Challenges of Troubleshooting Asynchronous Invocations
&lt;/h2&gt;

&lt;p&gt;Troubleshooting asynchronous AWS Lambda invocations can be challenging due to several factors:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Limited Visibility:&lt;/strong&gt; When an event is queued, you will receive a status code as confirmation. However, it’s important to note that a separate process handles the execution of your function by reading events from the queue. Therefore, you won’t receive immediate feedback confirming whether the event was successfully processed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic Retries:&lt;/strong&gt; If the function encounters an error, Lambda automatically makes two attempts to run it by default. The documentation does not mention the specific time gap between these retries. Function errors can encompass errors returned by the function’s code and runtime errors, such as timeouts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delivery Failures:&lt;/strong&gt; When Lambda encounters difficulties in sending a record to a configured destination, it reports &lt;code&gt;DestinationDeliveryFailures&lt;/code&gt; to Amazon CloudWatch. This situation may arise if your configuration includes an unsupported destination type, such as an Amazon SQS FIFO queue or an Amazon SNS FIFO topic. Additionally, errors related to permissions and size limitations can also lead to delivery failures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function Invocation Looping:&lt;/strong&gt; One scenario where this can occur is when your function manages resources within the same AWS service that triggered it. For example, you might create a function that stores an object in an Amazon S3 bucket configured with a notification that triggers the function again, creating a loop of invocations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Concurrency Limits:&lt;/strong&gt; Processing delays can arise due to concurrency limits. When a function is invoked repeatedly, the Lambda service may throttle the invocations, causing delays in processing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s see how we can overcome these challenges.&lt;/p&gt;

&lt;h2&gt;
  
  
  Error Handling and Automatic Retries
&lt;/h2&gt;

&lt;p&gt;It is important to understand the retry behavior of the invoking service and any other services involved in the request to ensure proper handling of errors in asynchronous invocations.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;get-function-event-invoke-config&lt;/code&gt; command can be used to obtain the configuration for the asynchronous invocation of a function. Below is an example response syntax you will receive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "DestinationConfig": { 
      "OnFailure": { 
         "Destination": "string"
      },
      "OnSuccess": { 
         "Destination": "string"
      }
   },
   "FunctionArn": "string",
   "LastModified": number,
   "MaximumEventAgeInSeconds": number,
   "MaximumRetryAttempts": number
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the &lt;code&gt;put-function-event-invoke-config&lt;/code&gt; command, You can configure a function with a maximum event age and maximum retry attempts. This command overwrites any existing configuration on the function.&lt;br&gt;
For example, to configure a function with a maximum event age of two hours and no retries, you can use the AWS CLI command given below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ aws lambda put-function-event-invoke-config --function-name myAsyncFunction \
--maximum-event-age-in-seconds 7200 --maximum-retry-attempts 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use the &lt;code&gt;update-function-event-invoke-config&lt;/code&gt; command to configure an option without resetting others.&lt;/p&gt;

&lt;p&gt;You can also use the AWS Lambda console to configure asynchronous invocation settings on a function.&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%2Fefhzk31ikqjasv0d05ve.jpeg" 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%2Fefhzk31ikqjasv0d05ve.jpeg" alt="AWS Lambda console asynchronous invocation overview" width="800" height="364"&gt;&lt;/a&gt;&lt;br&gt;
You can select and edit asynchronous invocation configurations by navigating to the configuration tab.&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%2Fhiel7nfgdkmezm8k0po6.jpeg" 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%2Fhiel7nfgdkmezm8k0po6.jpeg" alt="Using AWS Lambda console to configure asynchronous invocation settings on a function" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Lambda Destinations
&lt;/h2&gt;

&lt;p&gt;Lambda Destinations provide a way to send asynchronous invocation records to various services, including SQS queues, SNS topics, Lambda functions, or EventBridge. By utilizing Lambda Destinations, you can effectively handle successful and unsuccessful execution scenarios, enhancing monitoring capabilities and error handling without requiring additional code.&lt;/p&gt;

&lt;p&gt;You can use either the AWS CLI or the Lambda console to manage the settings for asynchronous invocation in Lambda Destinations. For instance, you can use the following command to add a failure destination to your asynchronous invocation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ aws lambda update-function-event-invoke-config --function-name myAsyncFunction \
--destination-config '{"OnFailure":{"Destination": "arn:aws:sqs:us-east-2:112233445566:destination"}}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function execution result is a JSON document containing information about the event, the response, and the reason for sending the record. The JSON format varies depending on the destination.&lt;/p&gt;

&lt;p&gt;An example function execution result would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "version": "string,"
    "timestamp": "string,"
    "requestContext": {},
    "requestPayload": {
        "ORDER_IDS": []
    },
    "responseContext": {},
    "responsePayload": {}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now monitor the health of your serverless applications using execution status.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dead-Letter Queues
&lt;/h2&gt;

&lt;p&gt;On the Lambda function, you can also configure a dead-letter queue to capture events that were not successfully processed. They are comparable to failure destinations. However, unlike destinations, dead-letter queues allow you to save failed messages for later debugging and analysis. They are instrumental when isolating problematic messages and investigating why their processing failed.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;update-function-configuration&lt;/code&gt; command to set up a dead-letter queue with the AWS CLI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ aws lambda update-function-configuration --function-name myAsyncFunction \
--dead-letter-config TargetArn=arn:aws:sns:us-east-2:123456789012:my-topic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response includes the request-id, the error code, and the error message. This information can be used to determine the error returned by the function or to correlate the event with logs or an AWS X-Ray trace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitoring and Troubleshooting
&lt;/h2&gt;

&lt;p&gt;Understanding behavior and errors cannot be based solely on error handling. Monitoring and observability, which include metrics, logs, and tracing, are also a major part of debugging and troubleshooting.&lt;/p&gt;

&lt;p&gt;For example, monitoring Lambda functions can help manage Lambda functions’ concurrency limit, preventing throttling and processing delays.&lt;/p&gt;

&lt;p&gt;To make things even easier, Lambda integrates with monitoring and tracing tools such as Amazon CloudWatch, AWS X-Ray, and Helios to provide monitoring of async function invocations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Amazon CloudWatch
&lt;/h2&gt;

&lt;p&gt;When a function completes event processing, Lambda sends metrics about the invocation to Amazon CloudWatch. This includes metrics for errors that occur during the invocation and should be monitored and addressed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Errors —&lt;/strong&gt; the number of invocations that result in a function error (include exceptions that both your code and the Lambda runtime throw).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Throttles —&lt;/strong&gt; the number of invocation requests that are throttled (note that throttled requests and other invocation errors don’t count as errors in the previous metric).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AWS introduced three new Amazon CloudWatch metrics for asynchronous AWS Lambda function invocations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AsyncEventsDropped —&lt;/strong&gt; the number of events dropped without successfully running the function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DestinationDeliveryFailures —&lt;/strong&gt; the number of times Lambda attempts to send an event to a destination but fails (typically because of permissions, misconfigured resources, or size limits).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DeadLetterErrors —&lt;/strong&gt; the number of times Lambda attempts to send an event to a dead-letter queue but fails (typically because of misconfigured resources or size limits).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These metrics provide visibility for asynchronous Lambda function invocations.&lt;/p&gt;

&lt;p&gt;Using the error metric is highly recommended for alerting function errors. Additionally, leveraging metrics offers valuable insights into retry behavior, including the interval between retries. For instance, if a function fails due to a downstream system overload, you can rely on metrics like AsyncEventAge and Concurrency metrics to better understand the situation.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS X-Ray
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://eu-north-1.console.aws.amazon.com/xray/home" rel="noopener noreferrer"&gt;AWS X-Ray&lt;/a&gt; offers powerful visualization capabilities for your application’s components, helping you identify performance bottlenecks and troubleshoot error-causing requests. However, it’s crucial to remember that AWS X-Ray doesn’t track every request. The sampling rate is set to one request per second, with an additional 5% request rate that cannot be configured. This means that relying solely on AWS X-Ray to troubleshoot a failed invocation may not be sufficient, as the failed invocation could be absent from the sampled traces.&lt;/p&gt;

&lt;h2&gt;
  
  
  Helios
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://gethelios.dev/" rel="noopener noreferrer"&gt;Helios&lt;/a&gt; is an OpenTelemetry-based tool that allows developers to install distributed tracing easily. It enables you to gain end-to-end visibility for Lambda function invocations.&lt;/p&gt;

&lt;p&gt;With Helios, you can enhance your monitoring capabilities by utilizing &lt;a href="https://docs.gethelios.dev/docs/labels-alerts-notifications" rel="noopener noreferrer"&gt;labels and alerts&lt;/a&gt;. These features allow you to save search queries and identify specific behaviors of interest for each Lambda function. This customization empowers you to focus on the precise data important to you, whether it be applicative events or AWS Lambda metrics. Furthermore, Helios conveniently provides automatic access to CloudWatch logs. With a simple button click, you can effortlessly retrieve the relevant logs from CloudWatch for each span, streamlining the troubleshooting process.&lt;/p&gt;

&lt;p&gt;One notable advantage of Helios is its ability to offer users valuable insights through &lt;a href="https://gethelios.dev/blog/seeing-vs-understanding-the-power-of-visualization/" rel="noopener noreferrer"&gt;data and visualizations&lt;/a&gt;. For instance, you can easily access information such as the execution time, involved services, and error codes returned for each span, allowing for a comprehensive understanding of your application’s behavior.&lt;/p&gt;

&lt;p&gt;Furthermore, Helios provides a convenient feature that enables the replay of specific flows. This functionality automatically generates the necessary code, configures and executes it in a different environment, and allows for a thorough investigation of the root cause of an issue. Finally, it enables verification to ensure that the solution is functioning correctly.&lt;/p&gt;

&lt;p&gt;These powerful features offered by Helios significantly contribute to the effective troubleshooting of asynchronous AWS function invocations.&lt;/p&gt;

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

&lt;p&gt;In conclusion, troubleshooting asynchronous AWS Lambda flows requires a comprehensive understanding of the error handling and automatic retry mechanisms provided by AWS Lambda and the available monitoring and troubleshooting tools. By utilizing a combination of dead-letter queues, Lambda Destinations, custom parameters, and adapted processing code, you can effectively handle errors and optimize your asynchronous Lambda flows to suit your specific use case.&lt;/p&gt;

&lt;p&gt;I hope these tips and tools prove invaluable in troubleshooting your asynchronous Lambda functions easily and efficiently. Thank you for taking the time to read, and happy coding!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
      <category>cloud</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Fast and Secure Frontend Serving with AWS CloudFront CDN</title>
      <dc:creator>Manusha Chethiyawardhana</dc:creator>
      <pubDate>Mon, 29 Aug 2022 16:35:00 +0000</pubDate>
      <link>https://dev.to/aws-builders/fast-and-secure-frontend-serving-with-aws-cloudfront-cdn-183d</link>
      <guid>https://dev.to/aws-builders/fast-and-secure-frontend-serving-with-aws-cloudfront-cdn-183d</guid>
      <description>&lt;p&gt;Modern frontends are blazingly fast and responsive. Moreover, it requires specialized tools and platforms to deliver at scale. One such platform is AWS CloudFront, a CDN (Content Delivery Network), highly customizable.&lt;/p&gt;

&lt;p&gt;So, in this article, I will take you through 6 best practices to optimize CloudFront for fast and secure frontend serving. Let's get started.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Caching Frontend Assets using the CDN
&lt;/h2&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%2Fgj5307eutstgkp7a4sa2.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%2Fgj5307eutstgkp7a4sa2.png" alt="Fast and Secure Frontend Serving with AWS CloudFront" width="639" height="346"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;b&gt;Reference: &lt;a href="https://aws.amazon.com/blogs/architecture/a-case-study-in-global-fault-isolation" rel="noopener noreferrer"&gt;A Case Study in Global Fault Isolation&lt;/a&gt;&lt;/b&gt;



&lt;p&gt;AWS CloudFront CDN acts as the middle man between your frontend hosting and the users. With CloudFront, you can cache HTML, CSS, JavaScript, and images. Since the cache is closer to the user, the content will be delivered with minimal latency.&lt;/p&gt;

&lt;p&gt;You can also configure CloudFront with origin failover for fallback handling in scenarios requiring high availability.&lt;/p&gt;

&lt;p&gt;And the best advantage is that AWS CloudFront natively supports integrating Amazon S3, where you can host your frontend artifacts. Besides, you can host your frontend anywhere and still serve through AWS CloudFront.&lt;/p&gt;

&lt;p&gt;For more details, refer to the AWS article on &lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-serve-static-website/" rel="noopener noreferrer"&gt;Using CloudFront to Serve Static Websites&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Using Cache Invalidation Upon New Deployments
&lt;/h2&gt;

&lt;p&gt;It is always good to invalidate the cache when performing a new deployment to prevent browsers from retrieving old file versions from the cache.&lt;/p&gt;

&lt;p&gt;AWS CloudFront now supports fast cache invalidation, allowing you to deploy updates to your SPA instantly while still having the benefit of CDN caching.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: As a practice, you could invalidate only the files that are modified in your deployment. For instance, if you use Webpack with default configuration, you only need to invalidate the index.html since each modified JS and CSS will have new file names.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You could also use AWS Amplify to simplify your deployments and cache invalidations with built-in optimizations.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Use Private S3 Buckets and Origin Access Identity for Security
&lt;/h2&gt;

&lt;p&gt;If you’re using an Amazon S3 bucket as the origin for a CloudFront distribution, it’s essential to restrict public access to S3.&lt;/p&gt;

&lt;p&gt;Restricting access prevents someone from bypassing CloudFront and accessing content that you want to keep secure via the Amazon S3 URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You will wonder why does it matter since it’s frontend assets that are meant to be public?&lt;/strong&gt; The reason is that serving through AWS CloudFront comes with more control, where you can set Web Application Firewall (WAF) rules and other restrictions on your content for security.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. For Hash-less URLs, use Lambda@Edge
&lt;/h2&gt;

&lt;p&gt;Lambda@Edge allows you to intercept HTTP requests that go through CloudFront. These functions run in CloudFront Edge Locations closer to the user, making it faster to respond or act upon content at transit.&lt;/p&gt;

&lt;p&gt;Some common use cases of Lamda@Edge are,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamically generate custom content based on request or response attributes, such as resizing images based on request attributes.&lt;/li&gt;
&lt;li&gt;To add logic to requests and responses, such as creating pretty URLs and managing authentication and authorization for origin requests.&lt;/li&gt;
&lt;li&gt;To increase the cache hit ratio, resulting in improved application performance by avoiding latency caused by a cache miss.&lt;/li&gt;
&lt;li&gt;To handle custom authentication and authorization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you need to explore more about Lamda@Edge, you can look through the &lt;a href="https://aws.amazon.com/blogs/networking-and-content-delivery/lambdaedge-design-best-practices/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; provided by AWS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If you need simple needs like using only Hashless URLs, there is a simple follow-up approach. Since the objective is to serve the index.html even a user directly goes to a route, we can set the CloudFront error handling to server the index.html if S3 returns the error “resource not found” with error code 404.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. Using Compression (Brotli, Gzip)
&lt;/h2&gt;

&lt;p&gt;Another best practice I encourage you to follow is using a compression method. With AWS CloudFront, you can serve your applications using Brotli or GZip and reduce content download speed drastically.&lt;/p&gt;

&lt;p&gt;Faster downloads, especially for JavaScript and CSS files, can result in the faster rendering of your SPA.&lt;/p&gt;

&lt;p&gt;Furthermore, because CloudFront data transfer costs are based on the total amount of data served, serving compressed files is less expensive than serving uncompressed files.&lt;/p&gt;

&lt;p&gt;Brotli is a widely used lossless compression algorithm that frequently outperforms Gzip in terms of compression ratio. Compared to Gzip, CloudFront’s Brotli edge compression results in up to 24% smaller file sizes.&lt;/p&gt;

&lt;p&gt;Compression features can be enabled via the CloudFront Console, SDK, and the CLI. You need to set EnableAcceptEncodingGzip to true to return Gzip compressed objects and EnableAcceptEncodingBrotli to true to return Brotli compressed objects. CloudFront will use Brotli when the viewer supports both formats.&lt;/p&gt;

&lt;p&gt;The Chrome and Firefox web browsers support Brotli compression only when the request is sent using HTTPS. Brotli is not supported with HTTP requests in these browsers.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Using Versioned File Names
&lt;/h2&gt;

&lt;p&gt;When performing a new deployment, you can either invalidate files or give them versioned file names to control the versions of files served by your distribution. If you frequently update your files, it is best to use file versioning.&lt;/p&gt;

&lt;p&gt;Versioning gives you better control over the content that CloudFront serves. slider_v1.js, image_v1.jpg are some example file versioning names you can use.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Versioning makes it easier to analyze the effects of file changes because CloudFront access logs include file names.&lt;/li&gt;
&lt;li&gt;Versioning enables different versions of files to be served to different users.&lt;/li&gt;
&lt;li&gt;Versioning simplifies rolling back and forth between file revisions.&lt;/li&gt;
&lt;li&gt;The cost of versioning is lower. You must still pay CloudFront to transfer new versions of your files to edge locations, but you don’t have to pay for invalidating files.&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;No matter how well you design and develop applications, users will be less attracted if it is not performing well. Using AWS CloudFront, you could address most of the performance and security challenges that affect your application frontend.&lt;/p&gt;

&lt;p&gt;Therefore, I invite you to try out AWS CloudFront and follow these practices to speed up and secure your frontends at scale.&lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
