Generating a CSV Report from a DynamoDB Table

1 hour
  • 5 Learning Objectives

About this Hands-on Lab

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.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

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).
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.
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 and Read access from your DynamoDB table.
  • Attach this new permissions policy to your Lambda execution role.
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.
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 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.

Sign In
Welcome Back!

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

Get Started
Who’s going to be learning?