8

I am doing an upload like this:

curl -v -X PUT -T "test.xml" -H "Host: my-bucket-upload.s3-eu-central-1.amazonaws.com" -H "Content-Type: application/xml" https://my-bucket-upload.s3-eu-central-1.amazonaws.com/test.xml

The file gets uploaded and I can see it in my S3 bucket.

The trick is, when I try to create a lambda function to be triggered on creation, it never gets invoked. If I upload the file using the S3 web interface, it works fine. What am I doing wrong? Is there any clear recipe on how to do it?

1
  • 1
    There are various events for adding new objects. can you show the lambda trigger configuration? Commented May 23, 2017 at 13:55

6 Answers 6

3

Amazon S3 APIs such as PUT, POST, and COPY can create an object. Using these event types, you can enable notification when an object is created using a specific API, or you can use the s3:ObjectCreated:* event type to request notification regardless of the API that was used to create an object.

  • Check the notification event setup on the bucket
  • Go to bucket on AWS management console
  • Click the properties tab on the bucket
  • Click the Events to check the notification event setup

Case 1:

  • s3:ObjectCreated:* - Lambda should be invoked regardless of PUT, POST or COPY

Other case:-

  • If the event is setup for specific HTTP method, use that method on your CURL command to create the object on S3 bucket. This way it should trigger the Lambda function
Sign up to request clarification or add additional context in comments.

Comments

3

Make sure the prefix you're adding contains safe special characters mentioned here. As per AWS documentation, some characters require special handling. Please be mindful of that.

Also, I noticed modifying the trigger on lambda page doesn't get applied until you delete the trigger and new one (even if it is same). Learned hard way. AWS does behaves weird sometime.

Comments

1

Check the prefix in bucket/properties. If there is a world like foo/, that means that only the objects inside the foo folder will trigger the evert to lambda.

Comments

1

I faced the same issue, The problem was with the function name itself. Try to check the value of the prefix to see if that matches perfectly with the resource.

If the resource is: resource/ and prefix is /test

then the actual folder path becomes: resource//test

just remove the '/' before test and it should work fine.

Comments

0

Faced similar issues and figured our that the folder names should not have spaces.

Comments

-1

Currently Under S3 there is option to Send notifications to Amazon EventBridge for all events in this bucket. Turn on

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.