我在 s3 存储桶上设置了一个事件桥触发器,每次我们上传对象时,它都会触发 Cloud Trail 中的 NotifyEvent。我正在尝试从有效负载中提取存储桶名称和密钥
您可以为此设置 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 胶水?
尝试检查存储桶名称,确认其合法性。