For Example S3 Creates Events When Objects Are Created And Removed
Now, let’s test it again, but this time, change the sample event object to:
"username" : "Sally"
|
Your test output should now read “Hello, Sally.”
AWS Events
You are probably wondering how an event is created outside of the test dialog. In most cases, the event object is created by AWS when an event occurs. For example, S3 creates events when objects are created and removed. If you’ve configured your Lambda function to act in response to such an event, the event object will contain information from S3 such as the bucket, key, request ID, time information, and much more. To properly create a Lambda function, you will need to look at the format of these events and process them accordingly.
At the time of this book’s publication, AWS supports triggering Lambda functions from: S3 create and remove events, DynamoDB row updates, CloudWatch Logs “put” events, SNS notifications, Kinesis events, and Alexa voice commands. Exploring each of these services is beyond the scope of this book, but I will be using S3 events frequently in my examples. As of now, they are relatively easy to test and don’t require setting up additional, costly resources.
The following sample event comes from an S3 “put object” request: