Managing S3 Objects and DynamoDB Records

Record Object Sizes in DynamoDB Table | Ensure Ideal Triggering

Prev Question Next Question

Question

Your team is currently publishing items to an S3 bucket.

You need to record the size of the objects in a separate DynamoDB table.

How can you ensure that each uploaded object triggers a record in the DynamoDB table in an ideal manner? Choose 2 answers from the options given below.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - B and D.

This is given in the AWS Documentation.

Amazon S3 can publish events (for example, when an object is created in a bucket) to AWS Lambda and invoke your Lambda function by passing the event data as a parameter.

This integration enables you to write Lambda functions that process Amazon S3 events.

In Amazon S3, you add a bucket notification configuration that identifies the type of event that you want Amazon S3 to publish and the Lambda function that you want to invoke.

Options A and C are incorrect since the ideal option would be to create a Lambda function that could be used to automatically record the data size and then place a record in the DynamoDB table.

For more information on S3 with Lambda, please refer to the below URL-

https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html

To record the size of the objects in a separate DynamoDB table each time an object is uploaded to the S3 bucket, we need to create a Lambda function that will be triggered by S3 bucket events.

Therefore, the correct answers are B and D.

Here is how it works:

B. Create a new Lambda function To create the Lambda function, we will need to follow these steps:

  1. Log in to the AWS Management Console and navigate to the AWS Lambda console.
  2. Click on the "Create function" button.
  3. Choose "Author from scratch".
  4. Give your function a name, choose your preferred runtime, and select "Create a new role with basic Lambda permissions" in the "Permissions" section.
  5. Click on "Create function".

D. Add the Lambda function to the source event for the S3 bucket After creating the Lambda function, we need to configure it to be triggered by S3 bucket events. Here is how to do it:

  1. In the AWS Lambda console, select the function you just created.
  2. Click on the "Add trigger" button.
  3. Choose "S3" from the list of triggers.
  4. Select the S3 bucket from the dropdown menu.
  5. Choose "All object create events" for the Event type.
  6. Click on "Add".

Now every time an object is uploaded to the S3 bucket, the Lambda function will be triggered and will record the size of the object in the DynamoDB table.