Skip to content

This is a sample application to demonstrate how to build an application on AWS Serverless Envinronment using the AWS SAM, Amazon API Gateway, AWS Lambda and Amazon DynamoDB. It also uses the DynamoDBMapper ORM structure to map Study items in a DynamoDB table to a RESTful API for managing Studies.

Notifications You must be signed in to change notification settings

lulumeisterr/study-datalake

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Serverless Cloud Native Java RESTful API

Develop an API following the best practices in the set of principles of REST (State Representation Transfer) architecture.

The travel entity must contain the attributes: Country, City, Date (YYYY / MM / DD) and Reason.

o Create a new trip record:

  • HTTP return code 201

o Get trips by period:

  • Via query / travel parameter? Start = X and end = Y
  • Return 200 containing the results in a list.
  • Even when nothing is found, return an empty list and HTTP code 200.
  • Returns all fields of the entity in the body.

o get trips by country:

  • Via parameter, inform the country / trips /
  • Return only one trip from the country.
  • HTTP Code 200 case found, body not found empty and HTTP Code 404.

enjoy city trips:

  • Via Consulta inform the city and via Path parameter inform the country / trips / /? city ​​=
  • The city search for being of type contains (like - LSI Sort Indexing key)
  • Return only one trip from the country.
  • HTTP Code 200 case found, body not found empty and HTTP Code 404.

• No API source code should contain a README file with instructions for running an API locally and also on AWS.

Requirements

Setup process

Installing dependencies

We use maven to install our dependencies and package our application into a JAR file:

mvn install

Local development

Invoking function locally through local API Gateway

  1. Update AWS credentials vi .aws/credentials

  2. Start DynamoDB Local in a Docker container. docker run -p 8000:8000 -v $(pwd)/local/dynamodb:/data/ amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb -dbPath /data

    • Use this command to list the table

         aws dynamodb list-tables --endpoint-url http://localhost:8000
      
  3. Create the DynamoDB table.

    Documentation: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html

    Execute this commands in the main folder:

      aws dynamodb create-table --cli-input-json file://dbDynamo.json --endpoint-url http://localhost:8000
    
  4. If You want to create the table using the (http://localhost:8000/shell/#)

    • past file dbDynamo.json and run

If the table already exist, you can delete: aws dynamodb delete-table --table-name study --endpoint-url http://localhost:8000

  1. Start the SAM local API.
  • On a Mac: sam local start-api --env-vars src/test/resources/test_environment_mac.json
  • On Windows: sam local start-api --env-vars src/test/resources/test_environment_windows.json
  • On Linux: sam local start-api --env-vars src/test/resources/test_environment_linux.json

OBS: If you already have the container locally (in your case the java8), then you can use --skip-pull-image to remove the download

About

This is a sample application to demonstrate how to build an application on AWS Serverless Envinronment using the AWS SAM, Amazon API Gateway, AWS Lambda and Amazon DynamoDB. It also uses the DynamoDBMapper ORM structure to map Study items in a DynamoDB table to a RESTful API for managing Studies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%