'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


Solution 1:[1]

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

In boto3 you use put_bucket_notification_configuration to provide empty notifications.

Solution 2:[2]

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.

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 Marcin
Solution 2 can.do