[英]AWS Lambda S3 Bucket Notification via CloudFormation
I'm trying to create a Lambda notification via CloudFormation but getting an error about the ARN format being incorrect. 我正在尝试通过CloudFormation创建Lambda通知,但是收到有关ARN格式错误的错误。
Either my CloudFormation is wrong or it doesn't support the Lambda preview yet. 我的CloudFormation错误或者它还不支持Lambda预览。
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"LambdaArn": {
"Type": "String",
"Default": "arn:aws:lambda:{some-region}:{some-account-id}:function:{some-fn-name}"
}
},
"Resources": {
"EventArchive": {
"Type": "AWS::S3::Bucket",
"Properties": {
"NotificationConfiguration": {
"TopicConfigurations": [
{
"Event": "s3:ObjectCreated:Put",
"Topic": {
"Ref": "LambdaArn"
}
}
]
}
}
}
}
}
But when I push up this CloudFormation I get the message: 但是当我推动这个CloudFormation时,我收到了消息:
The ARN is not well formed
Does anyone have idea as to what this means? 有没有人知道这意味着什么? I know the example above has been modified so not to use my actual ARN, but in my actual code I've copied the ARN directly from the GUI. 我知道上面的例子已被修改,所以不使用我的实际 ARN,但在我的实际代码中,我直接从GUI复制了ARN。
Also, interestingly I was able to create the notification via the AWS console, and so I just assume that AWS CloudFormation doesn't yet support this feature (even though that's not quite clear I don't think when reading the documentation). 此外,有趣的是我能够通过AWS控制台创建通知,因此我只是假设AWS CloudFormation尚不支持此功能(即使这并不十分清楚我在阅读文档时没有想到)。
It looks like AWS has now released support for notifying lambda functions directly in CloudFormation. 看起来AWS现在已经发布了对在CloudFormation中直接通知lambda函数的支持。
The S3 NotificationConfiguration
definition used to only include TopicConfigurations but has been updated to include LambdaConfigurations
as well. S3 NotificationConfiguration
定义过去仅包含TopicConfigurations,但已更新为包括LambdaConfigurations
。
After adding the NoficationConfiguration, make sure you include a Lambda::Permission resource so that S3 is allowed to execute your lambda function. 添加NoficationConfiguration后,请确保包含Lambda :: Permission资源,以便允许S3执行lambda函数。 Here is an example permission that can be used as a template: 以下是可用作模板的示例权限:
"PhotoBucketExecuteProcessorPermission": {
"Type" : "AWS::Lambda::Permission",
"Properties" : {
"Action":"lambda:invokeFunction",
"FunctionName": { "Fn::GetAtt": [ "PhotoProcessor", "Arn" ]},
"Principal": "s3.amazonaws.com",
"SourceAccount": {"Ref" : "AWS::AccountId" },
"SourceArn": {
"Fn::Join": [":", [
"arn","aws","s3","", ""
,{"Ref" : "PhotoBucketName"}]]
}
}
}
The Amazon SNS topic to which Amazon S3 reports the specified events. Amazon S3报告指定事件的Amazon SNS主题。
It appears that although S3 supports sending events to Lambda , CloudFormation has not yet caught up. 看起来虽然S3支持向Lambda发送事件 ,但CloudFormation还没有赶上。 It expects an SNS ARN where you are providing a Lambda function ARN. 它期望您提供Lambda函数ARN的SNS ARN。
For now, it looks like you will have to hook up the event notification manually. 目前,您似乎必须手动连接事件通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.