Writing the foundation of a Lambda function
We can start our task with writing a Lambda function, which responds to S3 events and will resize the image. At this stage, the code will not resize the image, but it will only log the request, so first, we can see that the function is really triggered by S3.
As usual, we can create our new module with the name lambda-imageresizer
:
$ mkdir -p lambda-imageresize/src/main/java/com/
serverlessbook/lambda/imageresize
Then, let's add this new module to our settings.gradle
file:
$ echo "include 'lambda-imageresizer'" >> settings.gradle
We can now create our Handler
class in the com.serverlessbook.lambda.imageresize
package:
$ touch lambda-imageresizer/src/main/java/com/serverlessbook/lambda/
imageresizer/Handler.java
In this Lambda function, we will consume standardized events prepared by S3. AWS provides a Java package that includes POJOs for this type of event, including S3. This package can be found in the Maven repository by the name com...