Serverless Image Processing with AWS SAM: Uploads, Thumbnails & S3 Events

This example demonstrates a robust serverless architecture on AWS for handling file uploads and automated thumbnail generation. It leverages AWS SAM (Serverless Application Model), Lambda functions, API Gateway, and S3 event notifications to create a streamlined and scalable image processing pipeline. Project Structure Here’s a quick overview of the project’s key components: functions/: Contains the core Lambda function code: event.mjs: Handles S3 event notifications, triggering the thumbnail generation process. upload.mjs: Manages the initial file upload through API Gateway. layers/nodejs/: A Lambda layer containing shared code and dependencies for the functions: lib/utils.mjs: Common utility functions. package.json & package-lock.json: Node.js dependencies for the layer. template.yaml: The AWS SAM template defining the serverless resources: Lambda functions, API Gateway endpoints, S3 buckets, and their respective permissions and event triggers. How It Works The workflow is straightforward and efficient: ...

Customizing Cognito Emails with AWS SAM and Lambda

This example shows how to use AWS SAM to create a user sign-up system (Cognito) and change the automatic emails it sends, like account verification or password reset emails. This is a great method if you want your application’s messages to match your brand’s style. Project Components The project has two main files: cognito-email/index.js: This file contains a simple Lambda function. Its job is to change the content of the emails. template.yaml: This file tells AWS what to build. It includes: Cognito User Pool: The place where user data is saved. Lambda Function: A simple function that runs when needed. Permissions: These allow Cognito to call the Lambda function. How It Works This setup customizes the email messages that Cognito sends in different user flows, such as: ...

Serverless API Monitoring with AWS SAM: Lambda, API Gateway & CloudWatch Alarms

This example demonstrates how to build a lightweight, serverless API using AWS SAM (Serverless Application Model) while integrating real-time error monitoring and email alerts using CloudWatch Alarms and SNS. This pattern is ideal for production-ready serverless applications that need observability without heavy tooling. Project Structure The project includes the following core components: functions/: Contains the Lambda function that handles HTTP requests: app.mjs: Returns a simple response (e.g., “Hello World”). template.yaml: The SAM template defining resources including: Lambda Function (hello handler) API Gateway (to expose the function via HTTP) CloudWatch Alarm (monitors API 5XX errors) SNS Topic & Subscription (sends email alerts) How It Works This architecture sets up an API and monitors its availability in real time: ...