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

4 minute read
0

I configured an Amazon Simple Storage Service (Amazon S3) event notification to invoke my AWS Lambda function. However, the function doesn't invoke when the Amazon S3 event occurs.

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.

Confirm that your Amazon S3 event type is configured correctly

When you configure 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 Amazon S3 bucket, then Amazon S3 doesn't send the notification.

For example, an Amazon S3 event notification is configured to invoke Lambda with the s3:ObjectCreated:Put event. If you upload a large file, the file is uploaded using multipart upload. The s3:ObjectCreated:CompleteMultipartUpload event must be selected with the s3:ObjectCreated:Put event. You can also use the s3:ObjectCreated:* event type to request notifications for any API that was used to create an object.

Confirm that your object key name filters include the uploaded file name

If your event notifications are configured to use object key name filtering, notifications are published only for objects with specific prefixes or suffixes. A wildcard character ("*") can't be used in filters as a prefix or suffix to represent any character. Make sure that the prefix or suffix filters specified in the event notification includes the uploaded object key name.

Confirm that your object key name filters are in URL-encoded (percent-encoded) format

If your event notifications are configured to use object key name filtering, notifications are published only for objects with specific prefixes or suffixes.

If you use any of the following special characters in your prefixes or suffixes, you must enter them in URL-encoded (percent-encoded) format:

  • Parenthesis ("( )")
  • 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.

Confirm that your Lambda function's AWS Identity and Access Management (IAM) policy has the required permissions

Check your Lambda function's resource-based policy to confirm that it allows your Amazon S3 bucket to invoke the function. If it doesn't, add the required permissions by following the instructions in Granting function access to AWS services.

For more information, see AWS Lambda permissions.

Note: When you add a new event notification using the Amazon S3 console, the required permissions are added to your function's policy automatically. If you use the put-bucket-notification-configuration action in the AWS CLI to add an event notification, your function's policy isn't updated automatically.

Confirm that your Lambda function is configured to handle concurrent invocations from Amazon S3 event notifications

Your Lambda function must be configured to handle concurrent invocations from Amazon S3 event notifications. If invocation requests arrive faster than your function can scale, or your function is at maximum concurrency, then Lambda throttles the requests.

For more information, see Asynchronous invocation and Lambda function scaling.


Related information

How do I troubleshoot issues with invoking a Lambda function with an Amazon S3 event notification using Systems Manager Automation?

Using AWS Lambda with Amazon S3 events

Walkthrough: Configuring a bucket for notifications (SNS topic or SQS queue)

Tutorial: Using an Amazon S3 trigger to invoke a Lambda function

Why do I get the error "Unable to validate the following destination configurations" when creating an Amazon S3 event notification to invoke my Lambda function?

AWS OFFICIAL
AWS OFFICIALUpdated a year ago