In which we build a Expense Service using:
- Java (11)
- AWS Lambda, DynamoDB, API GateWay, SQS, using the AWS SDK for Java v2.x
- Serverless.com for deployment
This project aims to show how to deploy a basic API using AWS serverless services, and Serverless Framework to deploy it.
This tutorial still make use of Serverless.com for deployment, but you can view the CDK tutorial for information on using AWS CDK to even implement your infrastructure as code in Java.
In order to do this tutorial, you need to install a few things:
- Install node and npm
- Install the Serverless Framework installed with an AWS account set up.
- Install Java 11 JDK (OpenJDK is good)
- Install Gradle (You can use Maven as well to build your Java artifact.)
- Create and AWS account and do the necessary setup (you can follow the
Setting Up
steps in the AWS SDK for Java 2.x Quick Start guide) - Now setup credentials for Serverless using this great article on how to setup Serverless to work with AWS.
A basic API for tracking expenses.
- We will start with an API that allows to retrieve, create, update and delete expenses.
- We will then create a second service that listens to these expense events, and keep a list of expense totals per person.
- Define some domain classes with tests
- Implement a basic AWS Lambda function
- Implement lambda functions for retrieving expenses
- Add an AWS API Gateway endpoint to call the Lambda function and test that via Postman
- Create a new API endpoint with Lambda function for creating expenses
- Persist the expenses to DynamoDB and change Lambdas to use the persisted data
- Create a Lambda function that listens to expense events via AWS Simple Queue Service
- (Later) hook up API Gateway endpoint to expense totals lambda