1.8.0-CCP-333.0 • Published 4 years ago

web-hook-test-lambda v1.8.0-CCP-333.0

Weekly downloads
5
License
test2
Repository
bitbucket
Last release
4 years ago

Owner Insight

About

During the Covid19 Crisis, it became difficult for home inspections to occur due to shelter-in-place rules. It was decided that home owners would be allowed to take a series of images with their cell phone, answer basic questions and submit that data as a homeowner inspection. The was somewhat similar to the BACE service, so the FreBace project was used as a jumping off point for Owner Insight.

Design

The current design for OwnerInsight involves the use of various AWS services to provide a scalable, robust API for this processing. See a simplified overview below:

This system uses NodeJS for lambda implementations along with some python code in implement authorizations.

Workflow

alt text

Technical Stack

AWS Serverless Application Model (SAM)

To tackle serverless, we've made the decision to go with AWS's SAM which is a framework and translation layer on top of cloud formation for defining serverless applications. It has strong tie ins to API Gateway, S3 and DynamoDB, among other AWS services. This allows us to define the required infrastructure alongside the code that will be operating on it. Some of the key benefits we'll get by using SAM (not to say that other frameworks don't have similar or equivalent functionality):

  • single deployment configuration
  • local debugging and testing
  • tight integration with aws workflow

See this for a more detailed overview.

Local Development

Dependencies

The following dependencies will be necessary to work locally:

Running Locally

Through the use of AWS Sam's CLI, it's possible to run the defined endpoints locally.

First ensure you have all the node dependencies

$ npm install (or update)

Then, run

$ npm run local:sam

... 2019-05-20 11:46:36 Found credentials in shared credentials file: ~/.aws/credentials 2019-05-20 11:46:36 Mounting InspectionsImageSave at http://127.0.0.1:5000/v1/inspections/{inspectionId}/images POST 2019-05-20 11:46:36 Mounting InspectionsPDFSave at http://127.0.0.1:5000/v1/inspections/{inspectionId}/pdfs POST 2019-05-20 11:46:36 Mounting InspectionsCreate at http://127.0.0.1:5000/v1/inspections POST 2019-05-20 11:46:36 Mounting InspectionsDataSave at http://127.0.0.1:5000/v1/inspections/{inspectionId}/data PUT 2019-05-20 11:46:36 Mounting InspectionsImageRead at http://127.0.0.1:5000/v1/inspections/{inspectionId}/images GET 2019-05-20 11:46:36 Mounting InspectionsResults at http://127.0.0.1:5000/v1/inspections/{inspectionId}/results GET 2019-05-20 11:46:36 Mounting InspectionsDataRead at http://127.0.0.1:5000/v1/inspections/{inspectionId}/data GET 2019-05-20 11:46:36 Mounting InspectionsPDFRead at http://127.0.0.1:5000/v1/inspections/{inspectionId}/pdfs GET 2019-05-20 11:46:36 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template 2019-05-20 11:46:36 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

This will spin up an local API Gateway and execute your lambdas as requests come in. For example:

```bash
2019-04-09 11:07:02 127.0.0.1 - - [09/Apr/2019 11:07:02] "POST /inspections HTTP/1.1" 502 -
2019-04-09 11:20:00 Invoking com.clearcapital.bace.lambda.InspectionCreationHandler::handleRequest (java8)
2019-04-09 11:20:00 Decompressing /Users/mcarlin/code/ccp/frebace/target/bace-0.2.0-SNAPSHOT.jar

Fetching lambci/lambda:java8 Docker container image......
2019-04-09 11:20:06 Mounting /private/var/folders/tf/kz1nqgqd7j32w99vv66q6sdj9tbw6p/T/tmpnev_7js5 as /var/task:ro inside runtime container
START RequestId: 70e9afc5-f532-448a-abdf-9c056c2620a3 Version: $LATEST
END RequestId: 70e9afc5-f532-448a-abdf-9c056c2620a3
REPORT RequestId: 70e9afc5-f532-448a-abdf-9c056c2620a3	Duration: 100.07 ms	Billed Duration: 200 ms	Memory Size: 128 MB	Max Memory Used: 18 MB
2019-04-09 11:20:09 127.0.0.1 - - [09/Apr/2019 11:20:09] "POST /inspections HTTP/1.1" 200 -

Deploying to your developer-specific Stack

Dependencies

The following dependencies will be necessary to work locally:

You will need to have your credentials configured for the dev account. AWS-mfa is highly recommended.