Skip to content

Lambda to search S3 and make changes

0

Hello, I have a minimal experience with Python, and I'd appreciate if someone can help. Here's what I'd need to do:

  • search a S3 bucket (based on an event) for CSV files once uploaded, and move them to a different folder/prefix. The reason is that an end application cannot read the files with the uploaded prefix, the prefix is mandatory to have by Salesforce, so we cannot amend this I'm afraid. I'd need Lambda to scan for newly added CSV files, and move them to a path that I can define. is this easily doable with Python and Lambda please?

Best Regards, Mo

asked 2 years ago185 views

1 Answer
2

Hello.

Yes, I think the setup itself is easy.
You can use the configuration described in the following document to run Lambda when a file is uploaded to S3.
As a note, we recommend that you limit the prefixes that respond to event notifications so that Lambda will not be executed when copying files to another folder in the same S3.
https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

  • Thanks for the answer, but this is not what I needed. I already have a code in place. I need to grab a file(s) fropm a specific folder (prefix) and copy it somewhere else, but I don't know how to filtery by - for instance - CSV files because the directory tree is deep, the files dont land directly on the root of the buccket.

    For example,

    Salesforce pushes the data to S3 bucket A at: /data/14-03-2024/exports/metadata.csv.

    I cannot change the path where the data lands, and I need to grab the "metadata.csv" file and : copy it to /resources/metadata-files/metadata.csv

    I hope my request is clearer now :) Thank you in advance!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.