Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3/Lambda Copy object upon upload automagically?

We have multiple buckets that are used by our clients. A client uploads a single file (random filename) to their bucket, and we then visit that bucket and copy it to our own bucket for processing. Basically, this: https://stackoverflow.com/a/10418427/2868238

How could I automate this? I note lambda has s3 object event support so wonder if I can use this somehow?

Paul.

like image 400
Paul Avatar asked Apr 29 '26 08:04

Paul


2 Answers

This use case is almost the textbook example for AWS Lambda. If you look at the AWS Lambda image resize example, all you need to do is remove code that tests for the image type and actually does the resize- it's designed to download, transform, then upload the object to a new S3 bucket.

Also, you may be able to do this even more easily (and cheaply) with S3 cross-region replication, but that requires the buckets be in different regions (thanks @William-Gaul).

So, it depends on your precise use case.

like image 131
tedder42 Avatar answered May 01 '26 02:05

tedder42


This should help you out , it is written in detail on how to do replication between two buckets based on events. http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-prepare.html

like image 20
Joel Nishanth Ponukumatla Avatar answered May 01 '26 01:05

Joel Nishanth Ponukumatla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!