I have this particular scenario where I am calling an external API which returns csv file as response, now my requirement is to send this CSV file to S3 bucket on the fly, this means without downloading the file to temporary storage, I want to send it to S3.
I am writing lambda using node JS.
Sample pieces of code to do this would be helpful
Thanks
2
Answers
The lambda function looks like follows:
NOTE: Remember to add IAM permission to the AWS Lambda Role under policies
PREREQUISITE: Since Axios is not present by default in Lambda, create a layer for it or add it to an existing layer. Check the link for more details.
You will need to download the CSV file to local storage. The S3 API supports copyObject() which is for copying from one s3 location to another s3 location. But if the location of the source CSV is not in s3, then you’ll need to download the CSV file to the local storage of the Lambda first.