|
1 | | -# lambda-java8-dynamodb |
| 1 | +# lambda-java8-dynamodb |
| 2 | + |
| 3 | +This code base is an example API built with the Java 8 runtime for AWS Lambda, in |
| 4 | +the context of a common use case: an API backed by Amazon DynamoDB as its data store. |
| 5 | +By using Lambda together with DynamoDB, there is no need to deploy or manage servers |
| 6 | +for either the application tier or database tier. If the front end consists of mobile |
| 7 | +devices and a web app statically hosted on Amazon S3, the result is a completely serverless |
| 8 | +architecture with no need to deploy or manage servers anywhere in the system, in either |
| 9 | +the front end or back end. |
| 10 | + |
| 11 | +The example use case is a company which maintains a catalog of sports events, and has decided |
| 12 | +to build an API for that catalog backed by DynamoDB. For each event, the company needs to |
| 13 | +have a record that includes the name of the home team, the event date, the name of the other |
| 14 | +(away) team, the sport involved (e.g. basketball, baseball etc.), city, country, etc. The |
| 15 | +home page of the company’s application must display all local events for a user’s favorite |
| 16 | +home team, as well as all other sports events in the user’s home city. Other queries regarding |
| 17 | +events must be supported, but queries to support the home page are the most important. |
| 18 | + |
| 19 | +To keep this example simple, only a single Event table in DynamoDB is used to model the data, |
| 20 | +which essentially is a catalog of available events. Within this table, events are modeled using |
| 21 | +a composite key having the home team name as partition key, and event date as sort key, with |
| 22 | +the away team name as an ordinary attribute. This allows an event to be modeled as a single item |
| 23 | +in the table. |
| 24 | + |
| 25 | +The primary prerequisite for running the code for this example is to create a table in DynamoDB. |
| 26 | +The following attributes are required, with types indicated and whether the attribute functions |
| 27 | +as a partition or sort key for the table or a Global Secondary Index (GSI): |
| 28 | + |
| 29 | + homeTeam: String, Partition Key |
| 30 | + eventDate: Number, Sort Key |
| 31 | + awayTeam: String, GSI Partition Key |
| 32 | + city: String, GSI Partition Key |
| 33 | + eventId: Number |
| 34 | + sport: String |
| 35 | + country: String |
| 36 | + |
0 commit comments