首页 > 解决方案 > 为什么 S3 不触发 Lambda 函数?

问题描述

当我将 .png 图像放入同一区域的组合文件存储桶时,应该触发一个事件,但是当我这样做时没有触发任何事件。我的代码有什么错误/遗漏吗?

请帮忙!我在这上面花了几个小时!非常感激!

处理程序.py:

import boto3

s3 = boto3.client('s3') 

def combine_files(event, context):
    print('start')
    print(event)

无服务器.yml:

service: combine-files

provider:
  name: aws
  runtime: python2.7
  region: us-west-2
  profile: serverless-admin
  iamRoleStatements:
    - Effect: "Allow"
      Action: 
        - "s3:*"
      Resource: "*"


custom:
  bucket: combine-files
  pythonRequirements:
    dockerizePip: true

functions:
  combine_files:
    handler: handler.combine_files
    events:
      - s3:
        bucket: ${self:custom.bucket}
        event: s3:ObjectCreated:*
        rules:
          - suffix: .png

日志在链接中:(我已经对其进行了几次测试,并将 .png 文件添加到名为 combine_files 的存储桶中几次)。

标签: amazon-web-servicesdebuggingamazon-s3aws-lambda

解决方案


推荐阅读