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
- Navigate to the IAM console page.
- Select Roles from the left-hand menu.
- Select Create role.
- Select Lambda as the trusted entity.
- Add the following managed policies:
- AmazonS3ReadOnlyAccess
- AmazonTranscribeFullAccess
- CloudWatchLogsFullAccess
- Name the role "lab-lambda-role".
- Create a Lambda Function
- Navigate to the AWS Lambda console page.
- Select Create function.
- Create a function from scratch with the following:
- Called "lab-lambda-transcribe"
- Runs Python 3.6
- Uses the policy created from the previous task
- Edit the function and add the supplied code.
- Paste the code in the file
lab-1-lambda-code.py1
.
- Create a Trigger for the Lambda Function
- Navigate to the AWS S3 console page.
- Navigate into the settings for our input-… bucket.
- Navigate into the Properties of the bucket.
- Scroll to Events for that bucket.
- 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.