Running S3-put-triggered Lambda function on existing S3 objects?

后端 未结 5 2101
青春惊慌失措
青春惊慌失措 2021-02-15 03:59

I have a Lambda function in Node.js that processes new images added to my bucket. I want to run the function for all existing objects. How can I do this? I figured the easiest w

5条回答
  •  不知归路
    2021-02-15 05:02

    well basically what you need is to use some api calls(boto for example if you use python)and list all new objects or all objects in your s3 bucket and then process these objects

    here is a snippet:

    from boto.s3.connection import S3Connection
    
    conn = S3Connection()
    source = conn.get_bucket(src_bucket)
    src_list = set([key.name for key in source.get_all_keys(headers=None, prefix=prefix)])
    //and then you can go over this src list
    for entry in src_list:
       do something
    

提交回复
热议问题