A minimal serverless API implementation in Java
Features:
- Lambda + DynamoDB + HttpApi (a cheaper alternative to RestApi)
- Custom implemetation for ApiGateway request/response format to reduce the deployable artifact size (not recommended, import aws-lambda-java-events instead)
- reproducible builds, deploy using a ZIP file (no "Uberjar")
Please note:
- The DynamoDBMapper is recommended to simplify data-model binding in real-world applications
- Newer serverless applications may leverage new data-mapping capabilities available in the AWS SDK for Java v2. For example the new DynamoDbEnhancedClient
Build:
❯ mvn package
Deploy:
❯ sam deploy --guided
Invoke the remote endpoint:
❯ url=https://ae34eqcwlk.execute-api.eu-west-1.amazonaws.com/
# Add some data
❯ http $url/events < src/test/resources/oxford.json
❯ http POST $url/events < src/test/resources/brooklin.json
# Query data
❯ http GET $url/locations
This application is inspired by code examples from the great Programming AWS Lambda book.