A very common use case is solved with the power of AWS SAM.Add to Pieces
Setup log for a production-grade NodeJS application using S3 and AWS Lambda.
Tags: typescript, S3, utility
Tags: typescript, lambda, src, handler
In this lambda, the event object will be an S3CreateEvent because we want this function to get triggered when a new file is uploaded to a particular S3 bucket.
Note: We are using this function to read .xlsx and .csv files. If you want other files to support you will have to add those in the supportedFormats array.
Tags: amazon-web-services, handler, lambda, amazon-cloudformation
We added three things: an S3 bucket for file upload, a Lambda that will be triggered when a new file is uploaded, and a policy that will allow the lambda to read the contents of the S3 bucket. We will also attach the policy with the role of the function.
Tags: aws-lambda, aws-sam, shell, amazzon-webservices, aws-sam-cli
We added the Extra policy to avoid the circular dependency problem. And that’s it. Now you will deploy the code depending on your region.
To deploy your application, you first configure your environment. You can find the details here.
Tags: logs, lambda, upload
To test whether it works, go to the aws s3 console, upload a file, and check the logs.
To check the logs from the local machine use this.