2

我部署了一个 AWS Lambda 函数,该函数在使用 Chalice 创建 S3 存储桶事件时触发,但是当我将对象上传到 S3 存储桶时,不会触发 lambda 函数。Cloudwatch 日志和指标不显示任何数据。

代码如下:

from chalice import Chalice
import boto3

app = Chalice(app_name='ChaliceLambdaTest1')
app.debug = True    #Set the debug mode

s3 = boto3.client('s3')

@app.on_s3_event(bucket='chalicetestbucket1', events=['s3:ObjectCreated:*']) #Sample S3 bucket name

def handler(event):
    print("Object uploaded for bucket: %s, key: %s"
          % (event.bucket, event.key))
    print("Lamba triggered due to S3 event")
    app.log.debug("Lambda function triggered due to S3 event")

requirements.txt 文件如下:

boto3

我还观察到代码不在Lambda 函数管理控制台的配置选项卡下的函数代码部分中。

4

0 回答 0