简体   繁体   中英

How to add s3 trigger to lambda function?

如何使用botot3将s3触发器(包括前缀,后缀,存储桶,事件类型)添加到特定的Lambda函数?

Something like this should do it:

s3 = boto3.resource('s3')
bucket_name = 'BUCKETNAME'
bucket_notification = s3.BucketNotification(bucket_name)
response = bucket_notification.put(
    NotificationConfiguration={'LambdaFunctionConfigurations': [
        {
            'LambdaFunctionArn': 'ARN_OF_LAMBDA_FUNCTION',
            'Events': [
                's3:ObjectCreated:*'
            ],

        },
    ]})

Obviously modify BUCKETNAME and ARN_OF_LAMBDA_FUNCTION to suit your needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM