Get start with S3 + Lambda + DynamoDB



 

Goal: Whenever a file is uploaded to AWS S3 bucket, that file's details will automatically saved to DynamoDB table using AWS Lambda

 

Step1: Create your S3 bucket, where file is to be uploaded

 

Step2: Create your Lambda function using available Runtime options

  [Ways to write Lambda function:

    a) Using Cloud9 Editor or the Web-based Editor integrated intop the Lambda Console

    b) Write the function locally & then upload them to Lambda]

 

Step3: Create an IAM Role

    i. Select the Lambda on that Role (Now Lambda is attached to this Role)

    ii. Attach the policy, named "Full access to DynamoDB"(Now DynamoDB is available for that Role)

    iii. Select the Lambda function you created on Step2

  

  Hence, we end up establishing a connection that declares - Lambda should have full access to DynamoDB and viceversa.

 

Step4: Now add a Trigger

  Here select your S3 bucket, you created on Step1.

 

How it works actually:

  - Whenever any file gets uploaded to that particular S3 bucket,

  - My Lambda will be triggered, to inform, that look one file is uploaded

  - Now Lambda will invoke the function(we wrote on Step2). That code is all about capture the file details(file name, type, size etc).

  - Now Lambda will take that details info regardig that file and insert into DynamoDB table.

 

[Note: We can even create another Lambda to Trigger another Lambda function, whenever file gets inserted into the DynamoDB table as well]

To view or add a comment, sign in

More articles by Ipsita R.

Insights from the community

Others also viewed

Explore topics