This document discusses leveraging Micronaut, an open source Java framework, to build serverless applications on AWS Lambda. It demonstrates how to create a Micronaut function that converts temperatures between Celsius and Fahrenheit and deploy it to AWS Lambda. It also shows how to test the function locally and with unit tests using the Micronaut test support. The function can then be invoked remotely and from other applications using a generated client. Micronaut provides features like dependency injection that reduce overhead compared to traditional Lambda applications.
9. ➜ ~ mn
| Starting interactive mode...
| Enter a command name to run. Use TAB for completion:
mn>
10. ➜ ~ mn
| Starting interactive mode...
| Enter a command name to run. Use TAB for completion:
mn> create-function temperature-converter
11. ➜ ~ mn
| Starting interactive mode...
| Enter a command name to run. Use TAB for completion:
mn>create-function temperature-converter
| Generating Java project...
| Function created at /Users/naresha/practice/micronaut/
awsdaysblr/temperature-converter
| Initializing application. Please wait...
mn>
12.
13. @Getter
@Setter
@NoArgsConstructor
@Introspected
public class Temperature {
private double inCelcius;
private double inFahrenheit;
public static Temperature ofCelcius(double celcius) {
Temperature temperature = new Temperature();
temperature.setInCelcius(celcius);
return temperature;
}
public static Temperature ofFahrenheit(double fahrenheit) {
Temperature temperature = new Temperature();
temperature.setInFahrenheit(fahrenheit);
return temperature;
}
}