C# aws VS2017 serverless.template中的serverless应用程序语法,用于向s3通知添加筛选器

C# aws VS2017 serverless.template中的serverless应用程序语法,用于向s3通知添加筛选器,c#,aws-lambda,amazon-cloudformation,C#,Aws Lambda,Amazon Cloudformation,我使用AWS无服务器应用程序模板和简单的S3功能蓝图创建了一个VS2017 C应用程序。CloudFormation serverless.template文件包含my handler函数的规范,其中包含响应s3.ObjectCreated:*事件的事件规范。我正在尝试向该事件规范添加一个过滤器规范,以便只响应带有源/前缀的事件。这是我的密码: { "AWSTemplateFormatVersion" : "2010-09-09", "Transform" : "AWS::Serverl

我使用AWS无服务器应用程序模板和简单的S3功能蓝图创建了一个VS2017 C应用程序。CloudFormation serverless.template文件包含my handler函数的规范,其中包含响应s3.ObjectCreated:*事件的事件规范。我正在尝试向该事件规范添加一个过滤器规范,以便只响应带有源/前缀的事件。这是我的密码:

{
  "AWSTemplateFormatVersion" : "2010-09-09",
  "Transform" : "AWS::Serverless-2016-10-31",
  "Description" : "Template that creates a S3 bucket and a Lambda function that will be invoked when new objects are upload to the bucket.",
  "Parameters" : {
    "BucketName" : {
        "Type" : "String",
        "Description" : "Name of S3 bucket to be created. The Lambda function will be invoked when new objects are upload to the bucket. If left blank a name will be generated.",
        "MinLength" : "0"
    }
  },

  "Conditions" : {
    "BucketNameGenerated" : {"Fn::Equals" : [{"Ref" : "BucketName"}, ""]}
  },


  "Resources" : {

    "Bucket" : {
        "Type" : "AWS::S3::Bucket",
        "Properties" : {
            "BucketName" : { "Fn::If" : ["BucketNameGenerated", {"Ref" : "AWS::NoValue" }, { "Ref" : "BucketName" } ] }
        }
    },

    "S3Function" : {
      "Type" : "AWS::Serverless::Function",
      "Properties": {
        "Handler": "DCATInventory::DCATInventory.Function::FunctionHandler",
        "Runtime": "dotnetcore2.0",
        "CodeUri": "",
        "Description": "Default function",
        "MemorySize": 256,
        "Timeout": 30,
        "Role": null,
        "Policies": [ "AWSLambdaFullAccess", "AmazonRekognitionReadOnlyAccess" ],
        "Events": {
            "NewImagesBucket" : {
                "Type" : "S3",
                "Properties" : {
                    "Bucket" : { "Ref" : "Bucket" },
                    "Events" : [
                        "s3:ObjectCreated:*"
                    ],
                    "Filter" : {
                        "S3Key" : {
                            "Rules" : [{
                                "Name" : "prefix", 
                                "Value": "Source/"
                            }]
                        }
                    }
                }
            }
        }
      }
    }
  },
  "Outputs" : {
    "Bucket" : {
        "Value" : {"Ref":"Bucket"},
        "Description" : "Bucket that will invoke the lambda function when new objects are created."
    }
  }
}

这是模板生成的默认代码,仅将筛选器规范添加到事件属性中。我在第48行收到一个错误,说明规则密钥对此对象无效。我已经阅读了文档,在谷歌上搜索了一下,这似乎是正确的语法。我在这里指明了什么错误吗?提前感谢。

事实证明,尽管Visual Studio报告了一个错误,但上面显示的语法是正确的。即使有这个错误,我还是决定尝试将应用程序发布到AWS。我原以为CloudFront会出错,但它已成功发布。S3事件已发布,并包含带有源/前缀的“我的筛选规则”。

正确。始终与源进行验证。我在不同的情况下遇到了类似的问题。