Giter Site home page Giter Site logo

aws-samples / aws-serverless-crud-sample Goto Github PK

View Code? Open in Web Editor NEW
78.0 27.0 31.0 1004 KB

An example implementation of a mobile backend for a movies database using AWS Lambda, API Gateway and DynamoDb

License: Apache License 2.0

Shell 2.26% JavaScript 97.74%

aws-serverless-crud-sample's Introduction

README for movies-dynamodb

This project shows how to use a single lambda function (written in nodejs) to respond to multiple API gateway calls to manipulate data in DynamoDB. We show how to send the data from the API gateway to a lambda function, which checks to see which API call was invoked by the user. It then performs the intended action using CRUD methods in DynamoDB.

			Mobile Backend for Lambda.

Pre-requisite: • Create a IAM role called “Lambda-role” and assign it AWSLambdaFullAccess and AmazonDynamoDBFullAccess • Create a user and assign it AWSLambdaFullAccess and AmazonDynamoDBFullAccess policies.

Detailed Steps.

  1. Download code.

  2. Edit app_config.json to include your access key and secret , change region and dynamodb endpoint

create a table in DynamoDB. Follow the instructions here: http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.NodeJs.01.html (run the file createMoviesTable.js OR use the cli with this input: aaws dynamodb create-table --cli-input-json file://movies-table.json --region us-west-2 --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

The file movies-table.json is in the code archive.

The table must be created before completing the rest of the tutorial.

If using cli, then the user must be the one with the role for ddb & lambda.

  1. Zip the file.
  2. Create a new lambda function a. Select NodeJs4.3 as platform b. Input a name for your function c. Upload zip for code entry type. d. Change Handler to – movies-dynamodb.handler e. For role – Choose existing role f. Existing role – select the role “Lambda-role”created in Pre-req step (1) g. Review and Create Function

h. Test function by clicking “test” button and input the following as body

{   "method": "POST",   "body" : { "title": "Godzilla vs. Dynamo", "year": "2016", "info": "New from AWS Films, starring Andy Jassy."},   "headers": {       },   "queryParams": {       },   "pathParams": {       },    "resourcePath": "/add-movie" }

  1. Create endpoints on API gateway a. Add resources - /movies b. Create method – Get i. setContent Type – application/json ii. copy the requestTeamplate.vel file and paste into generate template section iii. Test c. Add resource /add-movie d. Create method – POST i. setContent Type – application/json ii. copy the requestTeamplate.vel file and paste into generate template section e. Test

  2. You can see logs on Test page of your lambda function.

aws-serverless-crud-sample's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-serverless-crud-sample's Issues

Package feedback

Package lacks a NOTICE file and the .js files lack Apache 2.0 source headers.

Additionally Asif, your commits are coming through as 'Unknown', and including the node_modules seems unnecessary when you could have used a package.json.

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.