Serverless Computing: Implement an AWS Lambda Function using the Management Console

In this part of the project, we will implement a Lambda function from the following specification:

Specification

  • The Lambda function will be triggered by creation of an object in an S3 Bucket.
  • The Lambda function will write information about the uploaded object to a DynamoDB table.
  • The function will capture the following fields for each uplodaded file: a) Timestamp of s3 file upload event, b) Fully-qualified path name of file (that is, the name includes the containing folder names), c) Content Type of uploaded object, d) Size of uploaded object in bytes, e) Source IP address.
  • The DynamoDB table must allow multiple uploads of the same fully qualified object path and capture information about each unique upload.
  • The function must capture information only about created files and not created folders.
  • The function will provide a log output for each file uploaded whether the write to DynamoDB is successful or not.

The naming of resources is up to you.

You must create and test your Lambda function using the AWS Management Console.

What You Will Need To Do

Among the things you will need to do are the following:

  • You will need to create resources necessary to run the Lambda function.
  • You will need to set up IAM objects to authorize the lambda function to run successfully.
  • You will need to locate and use API documentation to choose and use an appropriate Python API.
  • You will need to figure out a way to distinguish folders from files.

Some Advice

Just a few things that are worth mentioning:

  • Remember that your S3 bucket name needs to be globally unique and choose a name accordingly.
  • When creating your Lambda function, use “Create a new role from AWS policy templates”. This will enable you to control the name of the role name rather than having it automatically generated.
  • For your DynamoDB table, customize the table settings and select capacity mode = on-demand. With such a low-volume function, this will likely be less expensive than provisioned.
  • It might be useful to work incrementally and do trial uploads to explore what the event provided to the function looks like.
  • Consider whether your function needs a loop or not based on what the input event might contain.

References

The following links might be useful:

https://www.youtube.com/watch?v=2k2GINpO308

https://docs.aws.amazon.com/code-library/latest/ug/python_3_code_examples_categorized.html