This repo contains server and infrastructure code for deploying and running CoEpi Cloud API on AWS.
- Compute: AWS Lambda
- Data Store: DynamoDB
- Routing and Load Balancing: API Gateway
- Permissions Management: IAM
JDK 11 or newer required
gradle build
Then, run:
./gradlew shadowJar
- Ensure you have the AWS CLI configured, working, and pointing to the default AWS account you wish to deploy to.
- Install Terraform 0.12 or newer (Recommendation is to install via Choco for Windows/Homebrew for macOS/package managers for *nix)
- Run the Build step above
cd
to theterraform
folder in this repo- Create an S3 bucket to store Terraform's statefile:
aws s3api create-bucket --bucket tf-coepi-backend-bucket --region us-east-1
- Run
terraform init -backend-config="region=us-east-1"
to tell Terraform to use the state bucket you created inus-east-1
- Run
terraform plan
to see what changes will be applied to your AWS account - Run
terraform apply -auto-approve
to make the changes and deploy the server. - When the Terraform scripts are updated or you wish to redeploy, repeat steps 7 and 8.
The API Gateway root URL will be echoed to the shell, and you can CURL the deployed API:
curl -X POST https://e6f2c4llfk.execute-api.us-west-1.amazonaws.com/v4/tcnreport -d "ZXlKMFpYTjBJam9pWW05a2VTSjk="
curl -X GET https://e6f2c4llfk.execute-api.us-west-1.amazonaws.com/v4/tcnreport
curl -X POST https://q69c4m2myb.execute-api.us-west-2.amazonaws.com/v3/cenreport -d '{ "report": "dWlyZSBhdXRob3JgdsF0aW9uLgo=", "cenKeys": [ "baz", "das" ]}'
curl -X GET https://q69c4m2myb.execute-api.us-west-2.amazonaws.com/v3/cenreport
[{"did":"2020-04-06","reportTimestamp":1586157667433,"report":"dWlyZSBhdXRob3JpemF0aW9uLgo=","cenKeys":["bar","foo"]},{"did":"2020-04-06","reportTimestamp":1586158348099,"report":"dWlyZSBhdXRob3JpemF0aW9uLgo=","cenKeys":["bar","foo"]},{"did":"2020-04-06","reportTimestamp":1586158404001,"report":"dWlyZSBhdXRob3JgdsF0aW9uLgo=","cenKeys":["baz","das"]}]
For running the server on your developer AWS account, follow the steps below under AWS Insfrastructure Setup section.
For testing the lambda function and API locally, you can use SAM CLI. Below docs should be helpful.
Swagger Definition and API documentation is located under api_definition folder:
The API can be tested by pasting the definition on Swagger Editor
Method | HTTP request | Description |
---|---|---|
tcnreportPost | POST /tcnreport | Submit symptom or infection report following TCN 0.4.0 protocol |
tcnreportGet | GET /tcnreport?date={report_date}?intervalNumber={interval}?intervalLengthMs={interval_length_ms} | Returns a list of reports generated on the specified date and interval |
Method | HTTP request | Description |
---|---|---|
cenreportPost | POST /cenreport | Submit symptom or infection report |
cenreportTimestampLowerTimestampUpperGet | GET /cenreport?timestampLower={tsLower}×tampUpper={tsUpper} | Returns a list of reports generated between a timestamp range |