简体   繁体   English

通过CloudFormation的AWS Lambda S3存储桶通知

[英]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"}]]
        }
    }
}

From the docs : 来自文档

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.

相关问题 aws lambda - 如果手动创建 s3 存储桶,如何使用 cloudformation 添加 s3 触发器 - aws lambda - How to add s3 trigger using cloudformation if the s3 bucket is created manually CloudFormation Lambda S3存储桶访问被拒绝 - CloudFormation Lambda S3 bucket access denied AWS:通过 Lambda 将文件上传到 S3 存储桶不起作用(阅读是) - AWS: Uploading Files via Lambda to S3 Bucket not working ( Reading is ) 无法在现有 S3 存储桶中放置通知事件以触发 CloudFormation Lambda - Unable to put notification event to trigger CloudFormation Lambda in existing S3 bucket AWS 云形成 | 如何配置 Lambda 以使用 S3 存储桶中的最新代码 - AWS Cloudformation | How to Configure Lambda to Use Latest Code in S3 Bucket 如何将参数从CloudFormation传递到S3存储桶中存储的AWS Lambda函数 - How to pass a parameter from CloudFormation to an AWS Lambda function stored in an S3 bucket AWS 云形成 | 配置 Lambda 以在 S3 存储桶中使用最新版本的代码 - AWS Cloudformation | Configure Lambda to Use Latest Version of Code in S3 Bucket AWS Cloudformation Lambda S3 - 循环依赖 - AWS Cloudformation Lambda S3 - Circular Dependency 需要有关 CloudFormation 模板和 AWS lambda 的帮助,以便通过 lambda 将事件从 SQS 拉到 S3 - Need help on CloudFormation template and AWS lambda for pulling events from SQS to S3 via lambda 我可以使用现有的AWS IAM角色通过Cloudformation模板创建S3存储桶吗? - Can I use existing AWS IAM role to create S3 bucket via Cloudformation template?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM