- Lab
- A Cloud Guru
Giving an AWS Lambda Function Access to a DynamoDB Table via an Execution Role
In this hands-on lab scenario, you are a software engineer working for a new startup that's launching an online bookstore for rare and antique books. The founder, Kia, needs your help with resolving a security error she's seeing with an AWS Lambda function. Since her technical lead is out sick, she's calling on you for assistance. In order to resolve the security error with the Lambda function, you will use a service role in AWS Identity & Access Management (IAM) to give the Lambda function the required access permissions.
Path Info
Table of Contents
-
Challenge
Create a Lambda Function Using Supplied Code
The student will create a Lambda function with a default execution role.
- Log in to the AWS Management console.
- Navigate to AWS Lambda.
- Click Create function.
- Ensure that Author from scratch is selected.
- In the Basic information section, set the following values:
- Function name: "CreateDynamoDBTable"
- Runtime: Python 3.7
- In Permissions, create a new role with basic Lambda permissions.
- Create the Lambda function.
- Copy and paste the Lambda function code from GitHub.
- Deploy the Lambda function.
-
Challenge
Test the Lambda Function and Note the Error
The student will excecute the Lambda code and make note of the error.
- Log in to the AWS Management console.
- Navigate to AWS Lambda.
- Open the
CreateDynamoDBTable
Lambda function. - Click Test.
- Create an empty test event.
- Name the test event.
- Click Create.
- Click Deploy.
- Click Test.
- Observe the "not authorized" error message.
-
Challenge
Modify Lambda Execution Role to Allow Access to DynamoDB
The student will update the Lambda's execution to allow access to DynamoDB.
- Log in to the AWS Management console.
- Navigate to AWS Lambda.
- Open the
CreateDynamoDBTable
Lambda function. - Click the Configuration tab.
- Click the Permissions tab.
- Click the execution role name.
- Attach the DynamoDB full access policy.
- Navigate back to AWS Lambda and test the function again.
- Observe that the table was created.
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.