def remove_s3_bucket_lambda_event(bucket_name, lambda_function_arn):
s3 = boto3.resource('s3')
s3_client = boto3.client('s3')
try:
new_conf = {}
notification_conf = s3_client.get_bucket_notification_configuration(Bucket=bucket_name)
if 'TopicConfigurations' in notification_conf:
new_conf['TopicConfigurations'] = notification_conf['TopicConfigurations']
if 'QueueConfigurations' in notification_conf:
new_conf['QueueConfigurations'] = notification_conf['QueueConfigurations']
if 'LambdaFunctionConfigurations' in notification_conf:
new_conf['LambdaFunctionConfigurations'] = []
for lfc in notification_conf['LambdaFunctionConfigurations']:
if lfc['LambdaFunctionArn'] == lambda_function_arn:
continue #remove all references for Log Parser event
else:
new_conf['LambdaFunctionConfigurations'].append(lfc)
response = s3_client.put_bucket_notification_configuration(Bucket=bucket_name, NotificationConfiguration=new_conf)
except Exception, e:
print(e)
print("[ERROR] Error to remove S3 Bucket lambda event")
custom-resource.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录