Process S3 Located CSV files in Lambda

Serkan SAKINMAZ
3 min readSep 19, 2022

Lambda is a compute service that lets you run your code without provisioning or managing any server. Lambda is one of the most used services in AWS stack.The only thing you need to do is that develop and run your code

On the other hand, AWS S3 is a web service which is used to store every type of objects in a cloud such as video, picture, text. The main advantage of the S3 is to provide highly scalable, low latency, reliable and cheap storage system.

In this blog, we will implement a sample application via Python that reads CSV file from S3.

Step 1 -Download a sample CSV file from the following link

Just find the following sample while I was searching in google

Step 2-Create S3 bucket and upload the CSV file to S3

Step 3-Create a lambda function

  • Function name : FileProcessing
  • Runtime : Python x.x

Step 4- In the permissions, select ‘Create a new role from AWS policy templates’ since we need an S3 access

Select S3 read-only permission from dropdown

After than, click to ‘Create Function’, now you are able to see the Lambda in the Lambda function list

We are going to implement a simple Python application to process S3 file

This function is going to read a content from S3 bucket and print the content type.You can also find the file from Github by clicking to the link (view raw)

Open the Lambda function and paste the content into the Lambda

Once you paste the code, click to Deploy and it is ready for testing. After deploying your code, you are ready to test. Click to the ‘Test’ button

You will be able to see the logs

In this blog, we have implemented a sample application via Lambda that reads CSV file from S3. The point is to note that we haven’t provisioned any server which facilitates development and deployment

--

--