What event does AWS s3 CLI "cp" and "sync" trigger?

Viewed 666

I have lambda functions that run off of s3 events. I'm using aws-cli to move items into s3. I'm not sure what triggers when you perform a 'sync' and a file is actually added by the sync.

I think that s3 cp triggers a "put" event (ObjectCreatedByPut), and if the file is large enough it triggers a "multipart upload" event (ObjectCreatedByCompleteMultipartUpload). I don't believe it triggers a "copy" event, even though cp is in the command.

I don't think s3 sync triggers either of these. But I'm not 100% sure. I've tried reading through their docs but I'm not finding specific answers. I'm trying to pick up each event by a specific lambda function, so I'm just having trouble with what the sync triggers, if it triggers anything at all.

Thanks!

1 Answers

aws s3 cp could trigger a s3:ObjectCreated:Copy if both of your src and dst are S3 buckets.

aws s3 sync will

  1. run a aws s3 cp when the Comparator determines that the file needs to be uploaded or downloaded. This will trigger a s3:ObjectCreated:Put or s3:ObjectCreated:Copy or s3:ObjectCreated:CompleteMultipartUpload depending on the file size, src and dst.

  2. run a aws s3 rm when the Comparator determines that the file needs to be removed from the S3 bucket. This will

    • trigger a s3:ObjectRemoved:DeleteMarkerCreated if the status of the S3 bucket versioning is Enabled or Suspended.
    • trigger a s3:ObjectRemoved:Delete if the status of the S3 bucket versioning is Disabled.

Let me know if you have any further questions :)

Related