S3 trigger is not registered after deployment

I set my serverless.yml as below to trigger lambda function when an object is created at specified S3 bucket.

functions:
  hello:
    handler: handler.main
    events:
      - s3: 
        bucket: codepipeline-us-east-1-213458767560
        event: s3:ObjectCreated:*
        rules:
          - prefix: test/MyAppBuild

After successful deployment, I go to Lambda console’s Triggers tab, but I don’t see any trigger.
So, I added IAM role to yaml as below, but still cannot see any trigger.

  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - s3:*
      Resource: "*"

After adding a trigger manually via AWS console, my lambda function worked as expected.
If a trigger is added when I deploy with serverless framework, it would be nice.

1 Like

Nothing to extreme. Just a slight formatting problem.
Add 2 more spaces to the indent of bucket, event & rules.
Like so:

functions:
  hello:
    handler: handler.main
    events:
      - s3: 
          bucket: codepipeline-us-east-1-213458767560
          event: s3:ObjectCreated:*
          rules:
            - prefix: test/MyAppBuild

See Here in the Serverless docs for reference.

6 Likes

Succeeded by adding more spaces. Thank you so much.:smile:

1 Like

I still have issues with s3 trigger auto registering on aws console

plugins:
 - serverless-plugin-existing-s3
 
functions:
  ETL:
    handler: TP_S3_to_Redshift.lambda_handler
    package:
      artifact: ETL/artifacts/ETL.zip
    events:
      - existings3: 
          bucket: xyz-bi
          event: s3:ObjectCreated:*
          rules:
            - prefix: log/LAMBDA_INVOKE_TEST/
     
-----------------

 iamRoleStatements:
        - Effect: Allow
          Action:
          - 's3:*'
          - 's3:ListAllMyBuckets*'
          - 's3:HeadBucket*'
          - 'kinesis:PutRecord*'

any help is appreciated

rename:
- existings3:
to
- s3:

existings3 isn’t a valid event source.
see serverless docs for details

@bfieber He’s using serverless-plugin-existing-s3, to be able to use a an existing bucket.

I had the same issue, and I suspected it was the case but couldn’t see it. Thanks for this!

I’m having the same issue here, on the same bucket I have 3 functions with s3 events, but only 2 are registered. It happens randomly, I have had this issue a few times and the only way to fix was remove the stack completely (sls remove) and deploy again. Anyone else has the same odd behaviour?