aws-lambda aws-lambda triggered by S3

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • Deserialized JSON based object
  • "Records" key has one or more actual events
  • Each sub event object contains all information you need to determine what changed

Parameters

ParameterDetails
Records -> [] -> s3 -> bucket -> nameThe name of the S3 bucket
Records -> [] -> s3 -> object -> keyThe path and name of the file.

Remarks

File names

Unlike most file paths, the S3 key name (JSON Schema: $.Records[0].s3.object.key) does not include a leading slash. So, if you have a file in the path s3://mybucket/path/file.txt, the key will be path/file.txt

In Python at least, the key field value is UTF-8 URL encoded. This is noticeable when the filename contains spaces or non-ascii characters. The field needs to be URL decoded, then UTF-8 decoded - See Get non-ASCII filename from S3 notification event in Lambda

Records key

It is possible to have multiple of the same (or different) actions inside of the "Records" key of the event; however, in practice, you will usually see one event per invocation of your Lambda function.

More Examples & Testing

There are actually sample events in the Lambda console, if you choose Actions -> Configure Test Event. However, You can see the PUT operation in the examples above.

You can modify and submit test events from the AWS Lambda console to see how your function responds.



Got any aws-lambda Question?