Beruflich Dokumente
Kultur Dokumente
1. Introduction
AWS Lambda is a serverless computing service provided by Amazon to
reduce the con guration of servers, OS, Scalability, etc. AWS Lambda is
capable of executing code on AWS Cloud. It runs in response to events
on di erent AWS resources, which triggers AWS Lambda functions.
Pricing is pay-as-you-go which means we won’t shell our money on idle
lambda functions.
When you write code designed to run in AWS Lambda, you are writing
functions. The term functions comes from functional programming,
which originated in lambda calculus. The basic idea is to compose an
application as a collection of functions, which are methods that accept
arguments, compute a result, and have no unwanted side-e ects.
2. Maven Dependencies
To enable AWS lambda, we need the following dependency in our
project:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
</dependency>
We also need the Maven Shade Plugin to build the lambda application:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPo
m>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
3. Create Handler
Simply put, to invoke a lambda function, we need to specify a handler;
there are 3 ways of creating a handler:
We can also implement the RequestHandler into our class and override
the handleRequest method which will be our entry point for requests:
In this case, the input will be the same as in the rst example.
2. “Con gure triggers” (in our case we don’t have any triggers or
events)
• Code Entry Type and Function Package: Select “Upload a .ZIP and
Jar le” and click on “Upload” button. Select the le which
contains lambda code.
1. Once you are done with all inputs, click “Next” which will show
you to review the con guration.
• Click on your lambda function from lists and then click on “Test”
button
On the screen, you can see the Execution result section with
successfully returned output as:
7. Conclusion
In this quick intro article, we’ve created a simple AWS Lambda app
using Java 8, deployed that to AWS and tested it.