'Copy data from one folder to another inside a AWS bucket automatically

I want to copy files from one folder to another inside the same bucket.

  • I have two folders Actual and Backup
  • As soon as new files comes to actual folder i want a way so that it immediately gets copied to Backup folder.


Solution 1:[1]

What you need are S3 Event Notifications. With these you can trigger a lambda function when a new item is put, then if it is put with one prefix, write the same object to the other prefix.

It is also worth noting that, though it is functionally as it seems, S3 doesn't really have directories; just objects. So you are just creating the same object as /Actual/some-file with key /Backup/some-file . It just looks like there is a directory because files /Actual/some-file and /Actual/other-file share a prefix /Actual/.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 theherk