使用CloudFormation将S3触发器添加到Lambda函数 [英] Adding S3 trigger to Lambda function using CloudFormation
本文介绍了使用CloudFormation将S3触发器添加到Lambda函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用CloudFormation将S3触发器添加到lambda函数.根据我对循环引用的了解,首先需要创建lambda函数和S3存储桶,我已经使用模板完成了此操作,并成功创建了它们.
I'm trying to add an S3 trigger to a lambda function using CloudFormation. From what I've read about circular references the lambda function and S3 bucket needs to be created first, which I've done with a template and they get created successfully.
然后我进入更新堆栈"并输入模板:
Then I go into "Update Stack" and enter the template:
"Resources": {
"MyBucket": {
"Type": "AWS::S3::Bucket",
"NotificationConfiguration": {
"LambdaConfigurations": [
{
"Event": "s3:ObjectCreated:*",
"Function": "arn:aws:lambda:ap-southeast-2:newlyCreatedLambda"
}
]
},
"Properties": {
"BucketName": "MyBucket"
....
....
但是当我尝试部署它时,会出现错误:
But when I try to deploy it gives the error:
Template is not valid: Invalid template resource property 'NotificationConfiguration'
您知道如何添加触发器或我做错了什么吗?
Any idea how to get the trigger added or what I'm doing wrong?
推荐答案
我们在这里使用:
"BucketForFunctionsAcesImportNewFileUploaded": {
"Type": "AWS::S3::Bucket",
"Properties": {
"NotificationConfiguration": {
"TopicConfigurations": [],
"QueueConfigurations": [],
"LambdaConfigurations": [
{
"Function": {
"Fn::GetAtt": [
"FunctionsAcesImportNewFileUploaded",
"Arn"
]
},
"Event": "s3:ObjectCreated:*"
}
]
},
"VersioningConfiguration": {
"Status": "Suspended"
}
},
"DeletionPolicy": "Delete"
}
这篇关于使用CloudFormation将S3触发器添加到Lambda函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文