hands-on lab

Process Amazon S3 Events with AWS Lambda

Difficulty: Beginner
Duration: Up to 1 hour
Students: 7,265
Rating: 4.5/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

Amazon Simple Storage Service (S3) lets you store, retrieve, update, and version objects in the Cloud. Not only does it guarantee durability and high availability at low cost, but it also enables event-driven systems by notifying you whenever objects are created, updated, or deleted. This lets you connect S3 to SQS queues, SNS notifications, or AWS Lambda for custom processing.

In this lab, we will learn how to process new image files uploaded into S3 with a Lambda Function. As a simple example, we will use Python to compress the input image and generate a gzipped version.

Learning Objectives

Upon completion of this lab you will be able to:

  • Use Lambda to respond to events in Amazon S3
  • Utilize Python Lambda functions for event processing including use of the boto3 library
  • Compress data to reduce costs

Intended Audience

  • Developers working with event-driven paradigms
  • Practitioners looking to automate processing of S3 files

Prerequisites

Experience with S3 and the Lambda command-line will be beneficial but is not required.

The following courses can be used to fulfill the prerequisites:

Updates

June 5th, 2021 - Updated Amazon S3 screenshots to reflect the latest user interface changes

March 9th, 2021 - Updated AWS Lambda lab steps to reflect latest user interface updates

January 22nd, 2021 - Updated AWS Lambda lab steps to reflect latest user interface updates

October 27th, 2020 - Updated instructions and screenshots for the lambda creation to reflect the updated UI

July 29th, 2020 - Updated lab to reflect the latest console experience and resolved an issue in the Python code causing the function to fail to zip processed images

January 10th, 2019 - Added a validation Lab Step to check the work you perform in the Lab

September 10, 2018 - Updated instructions and images to improve the lab experience

Covered topics

Lab steps

Logging In to the Amazon Web Services Console
Amazon S3 Events Overview
Creating an Amazon S3 Bucket
Implementing an AWS Lambda Function to Process Amazon S3 Events
Testing the Amazon S3 Trigger