AWS SAM YAML文件无法引用S3事件的现有存储桶 [英] AWS SAM YAML File not able to refer to an existing bucket for S3 event
问题描述
用例:在SAM YAML文件中为Lambda函数创建S3事件时,请参考现有存储桶
Use Case : Refer to an existing bucket while creating a S3 event for the Lambda function in SAM YAML file
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Sample SAM Template for sam-app
Globals:
Function:
Timeout: 900
MemorySize: 2048
Environment:
Variables:
TABLE_NAME: "111"
ENDPOINT_OVERRIDE: "222"
Resources:
SomePull:
Type: AWS::Serverless::Function
Properties:
CodeUri: target/demo-1.0.0.jar
Handler: com.xxxx.run.LambdaFunctionHandler::handleRequest
Runtime: java8
Role: arn:aws:iam::aaaa:roaaaale/aaaa/lambdaExecution
events:
bucket: codedeploytestxxx
event: s3:ObjectCreated:*
rules:
- prefix: uploads
- suffix: .jpg
existing: true
参考资料: https://github.com/serverless/serverless/pull/6290
我尝试了几种方法,但是在创建事件时,仍然无法引用现有存储桶,因此上面缺少了什么配置.
I tried couple of approaches , but still I am not able to refer to an existing bucket while creating an event , what configuration(s) I am missing from the above.
执行上述脚本后出现错误:
Error I get after executing the above script :
Invalid. property events not defined for resource of type AWS::Serverless::Function
推荐答案
AWS::Serverless :: Function
文档
AWS :: Serverless :: Function.Events
文档
AWS :: Serverless :: Function S3 Event
文档
将该部分转换为 AWS无服务器应用程序模型(SAM)语法会导致此问题错误:
Converting that section to AWS Serverless Application Model (SAM) syntax leads to this error:
Resources:
SomePull:
Type: AWS::Serverless::Function
Properties:
CodeUri: target/demo-1.0.0.jar
Handler: com.xxxx.run.LambdaFunctionHandler::handleRequest
Runtime: java8
Role: arn:aws:iam::aaaa:roaaaale/aaaa/lambdaExecution
Events:
Event1:
Type: S3
Properties:
Bucket: codedeploytestxxx
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: uploads
- Name: suffix
Value: .jpg
[cfn-lint] E0001: Error transforming template: Resource with id [SomePull] is invalid. Event with id [Event1] is invalid. S3 events must reference an S3 bucket in the same template.
AWS无服务器应用程序模型(SAM)有一个关于引用现有S3的问题在这里桶
这篇关于AWS SAM YAML文件无法引用S3事件的现有存储桶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!