Coder Social home page Coder Social logo

pshashipreetham / serverless-api-using-aws-lambda-and-dynamodb-java Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 2.0 8.3 MB

Serverless API using AWS Lambda and DynamoDB in JAVA

Java 100.00%
java java11 maven dynamodb aws aws-lambda lambda lambda-functions api serverless

serverless-api-using-aws-lambda-and-dynamodb-java's Introduction

Serverless API using AWS Lambda (JAVA) and DynamoDB

This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders.

Tool Required before start of this project:

  1. Maven
  2. Java 11
  3. SAM CLI (install)
  4. AWS CLI (install)
  5. POSTMAN Tool
  6. OS: Windows 10 (can also be done on other Platforms if the Installation of AWS and SAM CLI's is done properly)

Note: Don't Forget to setup the AWS CLI using the AccessKey and SecretKey which you will get when an IAM USER is created in the AWS

Steps to make it run:

Step 1: Open the Powershell in the particular respective folder ordersapi
Step 2: Use the following build command

sam build

Step 3: Use the following deploy command to package and deploy your application to AWS

sam deploy

Note: Here we are not using the --guided in the command since the repo files already built and deployed.

Testing(If Deployed Successfully):

  • Go to --> API Gateway in AWS --> ordersapi--> select Stages on the left side panel menu --> press on stages--> Copy the URL
  • If Deployed Successfully you should see an GET and POST names in the Resources panel, as shown below:
 /orders
GET
POST
  • Open PostMan Tool

For Post Method:

  • Select the POST method
  • Paste the URL
  • Select Body --> raw-->JSON and paste the following JSON data
{
    "id": "1",
    "itemName": "dog",
    "quantity": 100
}
  • Press Send

Output:

Order ID: 123

Note: Make sure in Authorization select TYPE as AWS Signature in the drop-down menu and don't forget to put the AccessKey and SecretKey which you will get when an IAM USER is created in the AWS which is also required to setup the AWS CLI.

For GET Method:

  • Select the GET method
  • Paste the URL
  • Body --> None
  • Press Send

Output:

{
    "id": "1",
    "itemName": "dog",
    "quantity": 100
}

Note: If more than one POST method is submitted using differnt id, itemName and quantity in the JSON, after that you use the GET Method then the output will be more than one JSON. For Example, the OUTPUT of GET method, after two many POST methods

[
    {
        "id": 79,
        "itemName": "CAT",
        "quantity": 121
    },
    {
        "id": 78,
        "itemName": "dog",
        "quantity": 100
    }
]

Resources:

See the AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.

serverless-api-using-aws-lambda-and-dynamodb-java's People

Contributors

pshashipreetham avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.