AWS S3 File Uploads: Storing File Names in DynamoDB | Solutions Architect Exam | Amazon

Store File Names in DynamoDB | SAA-C03 Exam | Amazon

Prev Question Next Question

Question

An application currently allows users to upload files to an S3 bucket.

You want to ensure that the file name for each uploaded file is stored in a DynamoDB table.

How could this be achieved? (SELECT TWO)

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answers - A and C.

You can create a Lambda function containing the code to process the file and add the file's name to the DynamoDB table.

You can then use an Event Notification from the S3 bucket to invoke the Lambda function whenever the file is uploaded.

For more information on Amazon S3 Event Notifications, please visit the following URL-

https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
Name Events Filter Type

{_] RRSObjectLost {_ | Delete

{_| Put {_| Delete Marker Created
{| Post {__| ObjectCreate (All)

{_| Copy {_] ObjectDelete (All)

[

To achieve this requirement, we need to capture the events that occur when a file is uploaded to the S3 bucket and store the filename in a DynamoDB table. There are different ways to achieve this, but two possible solutions are:

  1. Create an AWS Lambda function to insert the required entry for each uploaded file, and configure S3 to trigger the Lambda function whenever a new object is created in the S3 bucket. To do this, follow these steps:
  • Create a new DynamoDB table with a primary key.
  • Create a new Lambda function that will insert a new item in the DynamoDB table with the filename of the uploaded object.
  • Add an S3 trigger to the Lambda function. To do this, go to the S3 bucket, select the Properties tab, then select the Events pane. Add a new event for the ObjectCreated event type and select the Lambda function as the target.
  • Test the solution by uploading a file to the S3 bucket and verifying that a new item with the filename was inserted in the DynamoDB table.
  1. Use AWS CloudWatch to probe for any S3 event and trigger a Lambda function that will insert the filename in a DynamoDB table. To do this, follow these steps:
  • Create a new DynamoDB table with a primary key.
  • Create a new Lambda function that will insert a new item in the DynamoDB table with the filename of the uploaded object.
  • Create a new CloudWatch event rule that will match any S3 event and trigger the Lambda function. To do this, go to the CloudWatch console, select Rules, then Create Rule. Select the S3 service as the event source and configure the rule to match any S3 event. Then select the Lambda function as the target.
  • Test the solution by uploading a file to the S3 bucket and verifying that a new item with the filename was inserted in the DynamoDB table.

Both solutions will achieve the requirement of storing the filename for each uploaded file in a DynamoDB table. The choice of solution will depend on the specific requirements and constraints of the application.