我正在尝试使用CloudFormation将S3触发器添加到lambda函数。根据我对循环引用的了解,首先需要创建lambda函数和S3存储桶,我已经使用模板完成了此操作,并成功创建了它们。
然后我进入“更新堆栈”并输入模板:
"Resources": {
"MyBucket": {
"Type": "AWS::S3::Bucket",
"NotificationConfiguration": {
"LambdaConfigurations": [
{
"Event": "s3:ObjectCreated:*",
"Function": "arn:aws:lambda:ap-southeast-2:newlyCreatedLambda"
}
]
},
"Properties": {
"BucketName": "MyBucket"
....
....
但是当我尝试部署它时会出现错误:
Template is not valid: Invalid template resource property 'NotificationConfiguration'
是否知道如何添加触发器或我做错了什么?
答案 0 :(得分:1)
这是我们使用的:
"BucketForFunctionsAcesImportNewFileUploaded": {
"Type": "AWS::S3::Bucket",
"Properties": {
"NotificationConfiguration": {
"TopicConfigurations": [],
"QueueConfigurations": [],
"LambdaConfigurations": [
{
"Function": {
"Fn::GetAtt": [
"FunctionsAcesImportNewFileUploaded",
"Arn"
]
},
"Event": "s3:ObjectCreated:*"
}
]
},
"VersioningConfiguration": {
"Status": "Suspended"
}
},
"DeletionPolicy": "Delete"
}