Creating a sample Lambda function in AWS
In this step, we are going to create a Lambda function that reads and prints a file from S3. In the previous chapter, we learned how to create the S3 bucket and Lambda function. Hence, we keep the explanation short here:
- We are going to copy a sample file to the S3 bucket:
Figure 5.11 – File in S3
- Create a Lambda function that reads the file from S3. I’ve called the Lambda function
FileProcessing
; however, you can give it any name that you prefer:
Figure 5.12 – Lambda function
- Once the Lambda is created, we paste the code to Lambda from the GitHub link under the image. In the code block, we are going to implement a simple function to read the content of the S3 bucket and print it. You can retrieve the code block from the GitHub page that I have shared after Figure 5.13. Broadly speaking, the
s3.get_object
method reads the file with the...