Why doesn't my Amazon S3 event notification trigger my Lambda function?

Last updated: 2020-12-28

Short description

Confirm that all of the following are correctly configured:

Resolution

Note: If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.

Amazon S3 event type

When configuring an Amazon S3 event notification, you must specify which supported Amazon S3 event types cause Amazon S3 to send the notification. If an event type that you didn't specify occurs in your S3 bucket, Amazon S3 doesn't send the notification.

Object key name filters

If an Amazon S3 event notification is configured to use object key name filtering, notifications are published only for objects with a certain key name prefix or suffix.

If you use any of the following special characters in the value of the prefix or suffix, you must enter them in URL-encoded (percent-encoded) format:

  • ASCII character ranges 00–1F hex (0–31 decimal) and 7F (127 decimal)
  • Dollar ("$")
  • Ampersand ("&")
  • Plus sign ("+")
  • Comma (",")
  • Colon (":")
  • Semicolon (";")
  • Equals sign ("=")
  • Question mark ("?")
  • At sign ("@")
  • Space (" ")

For example, to define the value of a prefix as "test=abc/", enter "test%3Dabc/" for its value.

Note: A wildcard character ("*") can't be used in filters as a prefix or suffix to represent any character.

For more information, see Object Key Naming Guidelines.

Lambda permissions

Your Lambda function's resource-based policy must allow the Amazon S3 bucket to invoke your function. When you add a new event notification using the Amazon S3 console, these permissions are added to that policy automatically.

Note: Adding a new event notification using put-bucket-notification-configuration in the AWS CLI doesn't update the Lambda function policy. However, Amazon S3 event notifications can still fail to invoke your function later if you remove the permissions.

Check the policy to confirm that it has the required permissions, and add them if needed. For more information, see Why do I get the error "Unable to validate the following destination configurations" when creating an Amazon S3 event notification to trigger my Lambda function?

Lambda concurrency

Your Lambda function must be configured to handle concurrent executions of incoming Amazon S3 event notifications. If requests arrive faster than your function can scale, or your function is at maximum concurrency, then Lambda throttles the requests and backs off before retrying.

For more information, see Asynchronous Invocation and AWS Lambda Function Scaling.