无法在 cloudformation 中创建带有附加到 lamba 的事件的 s3 存储桶

Cannot create s3 bucket with event to lamba attached to it in cloudformation

我有一个非常困惑的问题。我正在尝试创建 s3 存储桶,并附加一个触发 lambda 的事件。这是我的代码:

#s3-test-bucket
 ---
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
project:
  Description: project
  Type: String
  ConstraintDescription: Any string
EnvironmentApp:
  Description: EnvironmentApp
  Type: String
  ConstraintDescription: Any string
S3BucketName:
  Description: EnvironmentApp
  Type: String
  ConstraintDescription: Any string
Resources:
  S3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Sub images-${EnvironmentApp}
      NotificationConfiguration:
        LambdaConfigurations:
          -
            Function: arn:aws:lambda:us-east-1:xxxxxxxxxxx:function:test-
trigger-cfn
          Event: "s3:ObjectCreated:*"
          Filter:
            S3Key:
              Rules:
                -
                  Name: suffix
                  Value: zip
DeletionPolicy: Delete

现在的问题是,当我 运行 时,出现以下错误:

    10:25:56 UTC-0300   CREATE_FAILED   AWS::S3::Bucket S3Bucket    Unable to validate the following destination configurations

我在 运行 堆栈之前创建了 lambda,那么问题的原因可能是什么?

更新:这解决了问题:

  LambdaPolicy:
DependsOn:
  - Lambda
Type: AWS::Lambda::Permission
Properties:
  FunctionName:
    "Fn::GetAtt": [ LambdaImageResizer, Arn ]
  Action: "lambda:InvokeFunction"
  Principal: "s3.amazonaws.com"
  SourceArn: arn:aws:s3:::xxxxx

请检查您是否允许对您的 lambda 函数调用 invokeFunction 权限。

这看起来与 AWS 论坛中所述的问题类似 https://forums.aws.amazon.com/thread.jspa?threadID=167470