Serverless Web Application with DynamoDB and S3 Integration

Serverless Web Application Design with DynamoDB and S3 Integration

Prev Question Next Question

Question

You have been asked to design a serverless web application with DynamoDB as its database.

The client wants to record each and every change in data in DynamoDB and store it individually as a file on S3

How can you achieve this?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: B.

You can enable DynamoDB streams to record both old and new image and send it to a Lambda function which can store the changes on S3.

Option A is incorrect: This is not an ideal choice because the same can be implemented using DynamoDB streams.

Option C is incorrect: DynamoDB stream only supports Lambda as a target as of writing this question.

Option D is incorrect: DynamoDB does not support binary logging.

This feature is only supported for SQL databases.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.Lambda.html

The correct answer for this scenario is option B, which is to enable DynamoDB streams and attach them to Lambda, which will read the data and store it on S3.

DynamoDB Streams is a feature of Amazon DynamoDB that captures a time-ordered sequence of item-level modifications in a DynamoDB table. When an item in a table is modified, DynamoDB Streams writes a stream record containing the modification data to a DynamoDB stream. The stream record contains information such as the modified item, the type of modification, and the time of the modification.

Lambda is a serverless compute service that lets you run code without provisioning or managing servers. You can use AWS Lambda to process stream records from DynamoDB Streams and perform any actions you want, such as writing to an Amazon S3 bucket. When you attach a Lambda function to a DynamoDB stream, the function is triggered whenever a new stream record is written.

Therefore, to achieve the client's requirement of recording each and every change in data in DynamoDB and storing it individually as a file on S3, you need to enable DynamoDB streams on the table and configure a Lambda function to process the stream records and write them to S3.

Option A, which is to write a script that will record each and every create or update request and store it on S3, is not a scalable solution, and it would require you to manage the infrastructure that runs the script.

Option C, which is to enable DynamoDB streams and set the destination to S3, is not valid since there is no direct integration of DynamoDB streams to store records on S3.

Option D, which is to use DynamoDB binary logging feature to record each and every change on S3, is not applicable to the requirement of the client since the binary logs are not in a file format that can be easily accessed or managed. Additionally, this feature is primarily designed for auditing and compliance purposes rather than real-time data analysis or processing.