Triggering an AWS Lambda Function from an S3 Event

1 hour
  • 3 Learning Objectives

About this Hands-on Lab

The event ecosystem of AWS (along with its API) makes it one of the most powerful cloud platforms available. Lambda is AWS’s serverless, Function as a Service (FaaS) compute platform, and it can execute in response to many different events within AWS. In this hands-on lab, we will create a Lambda function that will trigger whenever an object is placed into an S3 bucket. Specifically, we will trigger a job within Amazon Transcribe to transcribe speech from an audio file placed into S3. No development knowledge is required for this lab, as all the code is provided, but we will take a look at the code and how it works.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create IAM Role for Lambda
  1. Navigate to the IAM console page.
  2. Select Roles from the left-hand menu.
  3. Select Create role.
  4. Select Lambda as the trusted entity.
  5. Add the following managed policies:
    • AmazonS3ReadOnlyAccess
    • AmazonTranscribeFullAccess
    • CloudWatchLogsFullAccess
  6. Name the role "lab-lambda-role".
Create a Lambda Function
  1. Navigate to the AWS Lambda console page.
  2. Select Create function.
  3. Create a function from scratch with the following:
    • Called "lab-lambda-transcribe"
    • Runs Python 3.6
    • Uses the policy created from the previous task
  4. Edit the function and add the supplied code.
  5. Paste the code in the file lab-1-lambda-code.py1.
Create a Trigger for the Lambda Function
  1. Navigate to the AWS S3 console page.
  2. Navigate into the settings for our input-… bucket.
  3. Navigate into the Properties of the bucket.
  4. Scroll to Events for that bucket.
  5. Inside the Events window, select Add notification and set with the following properties:
    • Add a meaningful name for the event.
    • Check All object create events.
    • For Send to, select Lambda Function.
    • Select the Lambda function created in the previous task.
    • Select Save.

Additional Resources

Our company records its meetings and stores them in AWS S3. Management wants to be able to access transcriptions of the meetings soon after the files are stored, and we want to implement an automated solution.

The videos will walk through each of the steps, including navigating into the AWS console.

Log in to the AWS Management Console using the credentials provided, and make sure you are in the us-east-1 (N. Virginia) region throughout the lab.

All the resources for this lab, including a sample audio file, can be found here: Click here for the lab files.

Note: The Transcribe service outputs to a service managed S3 bucket and now does not specify the Output URL, but you can just choose the Download full transcript button to download the JSON file.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!