gpt4 book ai didi

amazon-web-services - 如何触发lambda函数事件类型: ObjectCreatedByPut

转载 作者:行者123 更新时间:2023-12-03 07:27:03 25 4
gpt4 key购买 nike

我有下面的 CF 模板

我需要触发 s3 PUT 事件的 lambda 函数

事件类型:ObjectCreatedByPut

https://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-s3-notification-config/

AWSTemplateFormatVersion: "2010-09-09"
Transform: 'AWS::Serverless-2016-10-31'

rData:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/load_data
FunctionName: sample-function
Handler: lambda_function.lambda_handler
Runtime: python3.8
MemorySize: 3008
Timeout: 100
Role: !Sub arn:aws:iam::${AWS::AccountId}:role/main_service_role
Environment:
Variables:
bucket_name: sample-bucket
file_name: config/test.csv

最佳答案

您可以添加Events到你的模板。但对于S3 event :

S3 bucket name. This bucket must exist in the same template.

因此您的模板可以修改如下:

AWSTemplateFormatVersion: "2010-09-09"
Transform: 'AWS::Serverless-2016-10-31'
Resources:

MyBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: test-bucket-3422344

rData:
Type: AWS::Serverless::Function
Properties:
CodeUri: functions/load_data
FunctionName: sample-function
Handler: lambda_function.lambda_handler
Runtime: python3.8
MemorySize: 3008
Timeout: 100
Role: !Sub arn:aws:iam::${AWS::AccountId}:role/main_service_role
Environment:
Variables:
bucket_name: sample-bucket
file_name: config/test.csv
Events:
S3Event:
Type: S3
Properties:
Bucket: !Ref MyBucket
Events: s3:ObjectCreated:Put

关于amazon-web-services - 如何触发lambda函数事件类型: ObjectCreatedByPut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66320315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com