简体   繁体   English

使用 python 在 s3:Objectcreated.* 上启用/禁用或删除 aws lambda 触发器

[英]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.我有一个 lambda function,当 Bucket A-prod 中的任何新对象创建(s3:Objectcreated.*)时触发,这个 lambda 处理文件将结果保存在 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.现在我想在 QA 上恢复这些数据,我正在为此编写一个脚本,我不想再次处理文件。 For my case I will copy B-prod to B-qa and A-prod to A-qa via a python script.对于我的情况,我将通过 python 脚本将 B-prod 复制到 B-qa,将 A-prod 复制到 A-qa。

  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).如果我可以暂时禁用 lambda 触发器,那就太好了,但是这是不可能的,因为 aws 不允许再禁用(在 aws 控制台上它是灰色的)。
  2. I can delete trigger from aws console but can't find how to do it from python or cli.我可以从 aws 控制台删除触发器,但无法从 python 或 cli 找到如何执行此操作。 AWS Console Screenshot Lambda Function Trigger AWS 控制台截图 Lambda Function 触发器

can't find how to do it from python or cli.无法从 python 或 cli 找到如何执行此操作。

In boto3 you use put_bucket_notification_configuration to provide empty notifications.在 boto3 中,您使用put_bucket_notification_configuration来提供空通知。

For anyone looking for a temporary disable from AWS console without deleting the trigger, here's a work-around.对于希望在不删除触发器的情况下从 AWS 控制台临时禁用的任何人,这里有一个解决方法。 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 Go 到 S3 > 桶 > 你的桶 > 属性

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.您应该在目标中看到您的 Lambda Function,选择编辑,取消选中“所有 Object 创建事件”,选中另一个不会在您的过程中发生的事件类型,例如“对象标记”,保存。

When finished, enable by checking the "Object Create Events" and unchecking the other event.完成后,通过选中“对象创建事件”并取消选中其他事件来启用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS Lambda 使用 python 读取 S3 存储桶中的文件 - AWS Lambda read a file in the S3 bucket using python 在 python 中删除 AWS Lambda function 上的触发器 - Delete trigger on a AWS Lambda function in python aws lambda 函数禁用和删除 python boto3 中的 CloudFront 分布 - aws lambda function to disable and delete CloudFront distribution in python boto3 从 AWS lambda function 中的 s3 存储桶中读取 .mdb 或 .accdb 文件并使用 python 将其转换为 excel 或 csv - Reading .mdb or .accdb file from s3 bucket in AWS lambda function and converting it into excel or csv using python AWS Lambda function 在 S3 中创建 object 触发器不起作用 - AWS Lambda function trigger on object creation in S3 does not work 使用 AWS S3/Lambda 动态调整图像大小 - Dynamically resizing images using AWS S3/Lambda 无法使用在 Greengrass 上运行的 aws lambda 将 object 放入 S3 - Cannot put object to S3 using aws lambda running on Greengrass 在 s3 控制台上传文件夹时触发 Aws Lambda - Trigger Aws Lambda when a folder is uploaded on s3 console AWS Lambda 从 S3 存储桶中的特定文件夹中删除所有内容 - AWS Lambda to delete everything from a specific folder in an S3 bucket 如何使用 python 中的 AWS lambda function 将 excel 文件上传到 AWS S3 - How to upload excel file to AWS S3 using an AWS lambda function in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM