Since my app is of a food tracking system, I eventually need to implement an Android app to show an overview of what is inside the fridge inventory.
I am planning for a HTTP API for (perhaps) an Android App to access. The request flow will be like this.
- Android app → HTTP Request → AWS API Gateway → AWS Lambda → AWS DynamoDB
I will try out AWS API Gateway today to retrieve contents in the AWS DynamoDB database.
(1) Create Lambda to be invoked by API Gateway.
Go to Lambda console
- Function > Create function
- Function name: CypressPsocApiLambda
After creating the lambda go to IAM console
- Access management > Roles > Permissions > (Click on the function name)
- Attach policy: AmazonDynamoDBFullAccess
(2) Create API Gateway and integrate it to Lambda
Navigate to the API Gateway service console, and choose Create API. In API name, type CommentsApi and type a short description. Finally, choose Create API.
- HTTP API > Build
- API name: CypressPsocApi
- Stage name (leave as default)
Create a route
- GET request: /retrieve
Create and attach and integration
- Integration with: Lambda function > Choose “CypressPsocApiLambda”
(3) Edit Lambda to parse DynamoDB items
I used the document client to scan for the table name. This retrieves all the items without any filters. Perhaps I'll add a filter parameter in if I need it in the future part of this project.
And now, I can go to the /retrieve page and I see all the test entry in my database.
For next time, I want to do up the android app and also the RFID portion of the PSoC device.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.