从云跟踪中的 AWS 事件触发的 NotifyEvent 负载中提取存储桶名称和密钥

问题描述 投票:0回答:2

我在 s3 存储桶上设置了一个事件桥触发器,每次我们上传对象时,它都会触发 Cloud Trail 中的 NotifyEvent。我正在尝试从有效负载中提取存储桶名称和密钥

amazon-web-services aws-glue
2个回答
0
投票

您可以为此设置 lambda:

import json

def lambda_handler(event, context):
    # Extract bucket name and object key from the event payload
    for record in event['Records']:
        bucket_name = record['s3']['bucket']['name']
        object_key = record['s3']['object']['key']
                    
        print(f'Bucket: {bucket_name}, Key: {object_key}')
        
        # Add your custom processing logic here

为什么要使用 AWS 胶水?


0
投票

尝试检查存储桶名称,确认其合法性。

© www.soinside.com 2019 - 2024. All rights reserved.