通过无服务器使用插件serverless-plugin-existing-s3部署的lambda不会在S3上传事件上触发

时间:2019-02-01 16:35:39

标签: node.js amazon-s3 aws-lambda amazon-cloudformation serverless

我正在部署无服务器lambda环境,并使用serverless-plugin-existing-s3插件,一切都很好,但是当我上传文件时,S3事件不会触发lambda。

代码示例:

service: test-storage
package:
  individually: true

plugins:
  - serverless-plugin-existing-s3
  - serverless-plugin-include-dependencies

provider:
  name: aws
  runtime: nodejs8.10
  iamRoleStatements:
    - Effect: "Allow"
        Action:
          - "s3:PutBucketNotification"
        Resource:
          Fn::Join:
            - ""
            - - "arn:aws:s3:::TESTBUCKET"

functions:
  onPimImportTrigger:
    handler: testFunc/testFunc.handler
    name: testFunc
    description: Detect file(s) uploaded to Bucket-S3, and handle lambda
    events:
      - existingS3:
          bucket: S3_BUCKET_NAME
          events:
            - s3:ObjectCreated:*
          rules:
            - prefix: TEST/IN
            - suffix: .txt

我不明白,我关注了package documentation。 感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

只需在部署代码后运行命令

serverless s3deploy --stage yourstage