Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AWS Lambda Function to change ownership on each object created to the bucket owner. It accomplishes this by overwriting the key with itself. This is to be triggered by an S3 ObjectCreated (All) Event.

This comment has been minimized.

Copy link

@williamtsoi1 williamtsoi1 commented Mar 1, 2017


Thanks for this code. This was very useful for me as I needed something to do this.

However, I think there's a bug in here, because running the code as-is causes an infinite loop. Each time the file gets overwritten by the lambda, another instance of the lambda gets invoked due to the S3 ObjectCreated (All) event, and this repeats itself ad-infinitum.

Here's my version of the solution, which does a check on the ownership of the S3 object against the running AWS account before deciding on whether to go through with the s3.CopyObject() operation or not.

Thanks once again!


This comment has been minimized.

Copy link
Owner Author

@joech4n joech4n commented Mar 2, 2017

@williamtsoi1 thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.