AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume – there is no charge when your code is not running. With Lambda, you can run code for virtually any type of application or backend service – all with zero administration. Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.
You can use AWS Lambda to run your code in response to events, such as changes to data in an Amazon S3 bucket or an Amazon DynamoDB table; to run your code in response to HTTP requests using Amazon API Gateway; or invoke your code using API calls made using AWS SDKs. With these capabilities, you can use Lambda to easily build data processing triggers for AWS services like Amazon S3 and Amazon DynamoDB, process streaming data stored in Kinesis, or create your own back end that operates at AWS scale, performance, and security.
When to use Lambda?
GET
and PUT
, to specific Lambda functions. Alternatively, you could add a special method named ANY to map all supported methods (GET
, POST
, PATCH
, DELETE
) to your Lambda function. When you send an HTTPS request to the API endpoint, the Amazon API Gateway service invokes the corresponding Lambda function.DynamoDBManager
) and define one method (POST
) on it. The method is backed by a Lambda function (LambdaFunctionOverHttps
). That is, when you call the API through an HTTPS endpoint, Amazon API Gateway invokes the Lambda function.AWS_PROXY
integration type.ANY
catch-all method.{proxy+})
.outputType handler-name(inputType input, Context context) {
…
}
import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; public class HelloPojo implements RequestHandler<RequestClass, ResponseClass>{ public ResponseClass handleRequest(RequestClass request, Context context){ String greetingString = String.format("Hello %s, %s.", request.firstName, request.lastName); return new ResponseClass(greetingString); } }