【发布时间】:2021-04-18 17:28:00
【问题描述】:
我在我的 sam.yaml 文件中添加一个 S3 事件,以在存储桶中添加文件时触发 lambda 函数。
我将为现有的 S3 存储桶创建这些功能的触发器。我能否使用 SAM 为现有存储桶创建触发器,还是需要手动创建触发器?
但是,我收到以下错误
Resource with id [ApiGatewayLambdaS3Event] is invalid. property BucketName not defined for resource of type S3
这是我使用我尝试创建的所有 lambda 函数和触发器创建的 template.yaml 文件。
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: CD Demo Lambda
Resources:
CDDemoLambda:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lambda_function.lambda_handler
Runtime: python3.6
CodeUri: ./FunctionOne
FunctionName: CDDemoLambda
Description: 'Lambda function for CD Demo Test'
MemorySize: 128
Timeout: 30
Events:
getAZsAPI:
Type: Api
Properties:
Path: /getazs
Method: get
HelloWorld:
Type: 'AWS::Serverless::Function'
Properties:
AutoPublishAlias: qaTest
Handler: qa-hello-world.lambda_handler
Runtime: python3.6
CodeUri: ./FunctionTwo
FunctionName: HelloWorld
Description: 'Hello WOrld'
ApiGatewayLambda:
Type: 'AWS::Serverless::Function'
Properties:
AutoPublishAlias: apigateway
Handler: lambdafunctionthree.lambda_handler
Runtime: python3.6
FunctionName: ApiGatewayLambda
CodeUri: ./FunctionThree
Description: 'Hello WOrld'
我需要进行哪些更改才能添加要与我的 lambda 函数一起创建的 S3 事件触发器。
【问题讨论】:
标签: python-3.x amazon-web-services amazon-s3 aws-sam