- Lab
- A Cloud Guru
Generating a CSV Report from a DynamoDB Table
In this lab, you will walk through the creation of a Lambda function that can read the first 1000 items from your DynamoDB table and export them as a CSV into your S3 bucket. You will have to grant your Lambda function the appropriate permissions to be able to access both the database and the S3 bucket. If you are not interested in learning about the code, you can copy the code from the GitHub repository provided and only complete the permissions part of the lab. You can find the Lambda code and the JSON permissions file in the **Additional Resources** section of the lab.
Path Info
Table of Contents
-
Challenge
Copy Your S3 Bucket's Amazon Resource Name
- Navigate to the S3 service.
- Click on the S3 bucket created for the lab.
- Record the bucket's Amazon Resource Name (ARN).
-
Challenge
Create a Lambda Function That Reads 1000 Lines from Your DynamoDB Table and Exports Them to a CSV File in Your S3 Bucket
- Navigate to the Lambda service.
- Create a new function with a Python runtime (or the runtime of your choice).
- Write and deploy the code needed to scan 1000 items from your DynamoDB table.
-
Challenge
Give Your Lambda Function Permissions to Read from Your DynamoDB Table and Write to Your S3 Bucket
- From your Lambda function, navigate to the Configuration tab.
- From the Permissions view, create a new policy for the Lambda's execution role.
- Write a policy that grants your Lambda function
Write
access to your S3 bucket andRead
access from your DynamoDB table. - Attach this new permissions policy to your Lambda execution role.
-
Challenge
Test Your Lambda Function and Verify That the CSV File Is Created in Your S3 Bucket
- Navigate back to your Lambda function.
- From the Test tab, execute a test, which should now succeed.
- Navigate to your S3 bucket and verify the presence of the generated CSV file.
-
Challenge
Add Items to Your DynamoDB Table
- Navigate to the DynamoDB service.
- Navigate to the DynamoDB table created for this lab.
- From the Explore table items interface, add 3 or more items to your DynamoDB table to test the solution.
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.