简体   繁体   中英

Enable/Disable or delete aws lambda trigger on s3:Objectcreated.* using python

I have a lambda function that triggers when any new objectCreated(s3:Objectcreated.*) in a Bucket A-prod, This lambda process the file saves the result in B-prod.

Now I want to restore this data on QA, I am writing a script for same and I don't want to process file again. For my case I will copy B-prod to B-qa and A-prod to A-qa via a python script.

  1. It would be great if I can disable the lambda trigger temporarily, But It is not possible as aws do not allow disabling anymore(It is grey on aws console).
  2. I can delete trigger from aws console but can't find how to do it from python or cli. AWS Console Screenshot Lambda Function Trigger

can't find how to do it from python or cli.

In boto3 you use put_bucket_notification_configuration to provide empty notifications.

For anyone looking for a temporary disable from AWS console without deleting the trigger, here's a work-around. Note that this is not meant as a permanent solution. I had to disable temporarily and it works.

Go to S3 > Buckets > your-bucket > Properties

Scroll down to "Event Notifications"

You should see your Lambda Function in Destination, Choose Edit, Uncheck "All Object Create Events", Check another event type that will not occur in your process, such as "Object Tagging", Save.

When finished, enable by checking the "Object Create Events" and unchecking the other event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM