- What is the root URL to your API?
- What are the routes?
- /people
- /people/id
- What inputs do they require?
- GET: no input for get all, input of id number for get one
- CREATE: input of new json data
- UPDATE: input of id number and updated json data
- DELETE: input of id number
- What output do they return?
- GET: get all returns an array of objects, get one returns an object representing one record, by its id number
- CREATE: inserts a record into the database
- UPDATE: updates a record in the database and returns an object representing on record by its id number
- DELETE: returns an empty object
- Create table
- Partition key (primary key). Call it ID
- Default table settings
-
Build non private REST API
-
Rest, New API
-
Name
-
Create a resource
-
/people route
-
Add all methods by highlighting route, clicking actions, method and selecting the method
-
Lambda Function
-
Use lambda proxy integration
-
Select handler after its been created
-
After Lambda function is built and works, do method test by clicking on method file and selecting test
-
Add JSON data to the request body for create and update handlers
-
In /people route, create a new resource with {id} to create the delete method
-
For delete handler test, include the {id} of object
- Add DynamoDBFullAccess to each handler role after the handlers have been created, found in roles in access management
- Create new function
- Handlers
- Node.js 18 and x86_64
- In function code, change handler to exports.handler
- DynamoDB folder
- Add handlers as folders and add indexes to each
- Navigate to handler folder for each handler after its created to AWS
- Check node version
- Nvm use 18
- Npm init -y
- Npm i dynamoose
- Add start script to package.json node index.js
- Zip each handler folder with node modules, index, package lock and package json including node modules. Highlight all 4 files at the same time and compress
- Upload each handler folder
- In index.js, require dynamoose, get basic schema example from dynamoose documentation for all CRUD methods
- In people table, create an item
- Enter key value pairs and create item
- From dynamoose docs, get model.scan filter example code
- Configure test event
- Use API Gateway AWS Proxy template
- Keep private
- In body, take out string and make it an object
In resources, deploy API, stage name production and Deploy, submit deployed link in readme
Worked with Kenny Lino