K.P*_*Pil 3 amazon-web-services aws-cloudformation aws-sam-cli aws-sam
使用案例:在 SAM YAML 文件中为 Lambda 函数创建 S3 事件时引用现有存储桶
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
Run Code Online (Sandbox Code Playgroud)
参考: https: //github.com/serverless/serverless/pull/6290
我尝试了几种方法,但在创建事件时仍然无法引用现有存储桶,我在上面缺少什么配置。
执行上述脚本后出现错误:
Invalid. property events not defined for resource of type AWS::Serverless::Function
Run Code Online (Sandbox Code Playgroud)
当您使用AWS 无服务器应用程序模型 (SAM)时,该拉取请求来自第三方无服务器框架
属性区分大小写:
AWS::Serverless::Function.Events文档
AWS::Serverless::Function S3 Event文档
将该部分转换为AWS 无服务器应用程序模型 (SAM)语法会导致此错误:
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
Run Code Online (Sandbox Code Playgroud)
[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.
Run Code Online (Sandbox Code Playgroud)
AWS 无服务器应用程序模型 (SAM) 存在有关引用现有 S3 存储桶的问题
| 归档时间: |
|
| 查看次数: |
3967 次 |
| 最近记录: |