• About Me
  • Projects
  • WebApp
  • Archive

Barnaby Baron. Exploring AWS.

  • Building a message handling service with Amazon SQS and AWS Lambda!
  • Building a message handling service with Amazon SQS and AWS Lambda!
  • Building a message handling service with Amazon SQS and AWS Lambda!

    Building a message handling service with Amazon SQS and AWS Lambda!

    May 29, 2024 3 min read Projects Barny Baron

    Journey: 📊 Community Builder 📊

    Subject matter: Building on AWS

    Task: Building a message handling service with Amazon SQS and AWS Lambda!

    This project practices Scalability.

    Using the 6 Pillars of the AWS Well-Architected Framework, Operational Excellence, Security, Reliability, Performance Efficiency, and Sustainability will be achieved in this build.

    I’m really enjoying the serverless aspect of building in the cloud.

    This week, I built a message-handling service with Amazon SQS and AWS Lambda!

    I started by creating a new Amazon Simple Queue Service [SQS] queue, which is a highly scalable message queuing service, that acts as a buffer and queueing requests to be processed asynchronously.

    Amazon SQS is a managed service and can scale as your services require it without manual intervention. You can also choose between two types of queue, Standard and FIFO. We’ll choose Standard for this project as we don’t mind what order the messages are polled in. However, if you need it, a FIFO queue configuration will process in a First In, First Out order and process a task exactly once.

    Processing

    After configuring the SQS queue, I then used Lambda to automatically manage the SQS queued events. This becomes a simple, effective fault-tolerant event-driven architecture.

    Resource credit: This serverless architecture was created using guidance from Oğuzhan Hızıroğlu on Medium Here.

    What did I use to build this environment?

    • Amazon Simple Queue Service
    • AWS Lambda
    • Amazon CloudWatch
    • AWS IAM

    What is built?

    • An SQS queue
    • A Lambda Function which handles messages sent to the SQS queue
    • A CloudWatch log stream to confirm Lambda has handled the queued data

    Use case: Businesses use SQS and serverless event-driven architectures to collect datasets, such as sensor data which is then queued and then passed for onward processing and data handling. Additional services such as Lambda, S3, DynamoDB, or RDS and SNS can be utilised to house and analyse sensor data being passed to the SQS queue(s).

    In this task, I created a new SQS queue in my desired region. I then created some test messages to be polled and received. After manually processing and deleting those queued messages, I created a new Lambda function.

    To keep things simple, this function leveraged one of the existing blueprint offerings for SQS. After creating a new execution role, I pointed my Lambda function to my SQS queue and enabled the trigger. As I used the SQS queue blueprint, the Lambda code was created for me which made things easier!

    After returning to the SQS queue and sending some new message requests to the queue, I observed that when polling for messages, my new message was not seen. This is good news as it meant that my Lambda function had successfully handled the request and cleared SQS of the queued message I sent. Great stuff!

    Processed data

    I then opened Amazon CloudWatch and found the new log group stream waiting.

    To further evidence the Lambda function doing its job correctly, I found the log entry and confirmed my message had been processed and deleted from the queued events!

    Some of the highlights…

    New SQS queue:

    SQS queue

    SQS test message sent:

    Sent message

    Polling for messages, message received:

    Queued message

    New Lambda function:

    Lambda fn

    Blueprint-managed Lambda code:

    Lambda code

    SQS trigger enabled:

    Lambda SQS trigger

    A new test message was sent, now handled by Lambda:

    New test message

    Polling for new messages:

    Polling

    CloudWatch log stream check:

    CloudWatch log stream

    CloudWatch indicating successfully handled message by Lambda:

    CloudWatch successfully handled

    My interpretation of the architecture:

    Architecture

    I hope you have enjoyed the article!

    Cloud

    Community Builder SQS Lambda
    Latest posts
    • Designing a Formula 1 Race Track and gaining insights from Amazon Nova
    • Year 2 - AWS Community Builder
    • Troubleshooting an EKS Pod creation error - Persistent Volume Controller Failed Binding
    • Building an EKS cluster and mounting an S3 bucket within a pod using the CSI Driver
    • Sopra Steria Merch Delivery!
    • AWS Community Builders Application Window!
    • Building a VPC and provisioning an EC2 instance using Modules!
    Categories
    • AWS News (84)
    • Projects (29)
    • Exploring (19)
    • Troubleshooting (10)
    • General (8)
    • Quotes (5)
    • Video (3)
    Social media
    Archive
    © 2025 by Barny Baron
    Powered by Bilberry Hugo Theme