This project is a basic java app that will run in AWS.
- We don't need an entry point (
public static void main{...}
) for this application because when you upload your jar to aws lambda you have to set your entry point method. - Run
mvn clean package
this command will create ajar file
of your application in../target/hello-lambda-1.0-SNAPSHOT.jar
. - Go to:
- AWS Lambda.
- Select
Create function
. - Fill the form (Function name: HelloLambda, Runtime: Java 17, Architecture: arm64).
- Click on
Create Function
button.
- In the HelloLambda windows:
- In the
Code source
section click onUpload from
button and select.zip or .jar file
. - Select your
hello-lambda-1.0-SNAPSHOT.jar
file. - In the
Runtime settings
section click onEdit
button. - Copy the path of our entry point application in the
Hendler
section, in our case this will be dev.santiagomedina.HelloLambda::handleRequest. - Click on
Save
button.
- In the
- In this point we are ready to test our function. Go to
Test
tab and click on theTest
button.
Modify the method handleRequest
in the HelloLambda
class to:
public class HelloLambda {
public String handleRequest(String name){
return "Hello, " + name + "!";
}
}
Follow the Key Points
steps until the step (5), before to click on the Test
button, scroll down in the Event JSON
section, delete the default data and write a random String
, scroll up and clikc on the Test
button.
Check the result. 😎