Blood Pressure Logger is a simple serverless web application that allows a user to upload their blood pressure data and view their previously submitted data.
- Submit blood pressure data to DynamoDB
- View blood pressure from DynamoDB
- Warn the user when their blood pressure is abnormally high
- Download (or clone) the code
- Create an AWS account (we should remain within free tier)
- From the AWS Management Console, find the service "DynamoDB"
- Create a new table:
- Table name:
BloodPressureLogger
- Primary key:
LogID
as String - Ensure that "Add sort key" is unchecked
- Ensure the "Use default settings" is checked
- Table name:
- From the AWS Management Console, find the service "Lambda"
- Create a new Lambda function:
- Function name:
GetBloodPressure
- Runtime:
Node.js 12.x
- Execution role: "Create a new role with basic Lambda permissions"
- Function name:
- Add the function code:
- Below the function, choose to edit the code inline
- Copy the code from 'functions/getData.js' in this repository
- Paste it into the code editor, replacing the existing code
- If you used a different DynamoDB table name other than
BloodPressureLogger
from Part 1, replace the name you used for the variable "DYNAMODB_TABLE_NAME" in the function code - Click "Save"
- Go to the "Permissions" tab of the function and select the autogenerated role name, which should look something like
GetBloodPressure-role-[something]
- From the new tab, select "Add inline policy" from the "Permission policies" subheading:
- Use the visual editor
- Service:
DynamoDB
- Actions: search for
Scan
or find it under theRead
dropdown and select it - Choose
All resources
- Click
Review policy
- Name:
DynamoDBScanPolicy
- Click
Create policy
- Return to the Lambda dashboard and create another Lambda function:
- Function name:
LogBloodPressure
- Runtime:
Node.js 12.x
- Execution role: "Create a new role with basic Lambda permissions"
- Function name:
- Add the function code:
- Below the function, choose to edit the code inline
- Copy the code from 'functions/logData.js' in this repository
- Paste it into the code editor, replacing the existing code
- If you used a different DynamoDB table name other than
BloodPressureLogger
from Part 1, replace the name you used for the variable "DYNAMODB_TABLE_NAME" in the function code - Click "Save"
- Go to the "Permissions" tab of the function and select the autogenerated role name, which should look something like
LogBloodPressure-role-[something]
- From the new tab, select "Add inline policy" from the "Permission policies" subheading:
- Use the visual editor
- Service:
DynamoDB
- Actions: search for
PutItem
or find it under theWrite
dropdown and select it - Resources: Choose
All resources
- Click
Review policy
- Name:
DynamoDBPutItemPolicy
- Click
Create policy
- From the AWS Management Console, find the service "API Gateway"
- Create a new REST API:
- Type:
REST
- Select
New API
- API name:
BloodPressureLogger
- Endpoint type:
Edge optimized
- Type:
- From the "Actions" dropdown, choose "Create Resource":
- Ensure that "Configure as proxy resource" is unchecked
- Resource name:
Log
- Resource path:
log
- Ensure that "Enable API Gateway CORS" is checked
- Click "Create Resource"
- With the new resource selected, choose "Create Method" from the "Actions" dropdown
- Select "GET" from the new dropdown below the resource and click the Check icon
- Configure the new method:
- Integration type:
Lambda function
- Use Lambda Proxy integration: checked
- Lambda function:
GetBloodPressure
(or the name you chose from part 2) - Click "Save" and allow permissions
- Integration type:
- With the resource selected, choose "Create Method" from the "Actions" dropdown
- Select "POST" from the new dropdown below the resource and click the Check icon
- Configure the new method:
- Integration type:
Lambda function
- Use Lambda Proxy integration: checked
- Lambda function:
LogBloodPressure
(or the name you chose from part 2) - Click "Save"
- Integration type:
- With the resource selected, choose "Deploy API" from the actions dropdown:
- Deployment stage:
[New Stage]
- Stage name:
prod
- Click "Create"
- Deployment stage:
- From the "prod Stage Editor", click the down arrow next to "prod" to expand the options and click "GET"
- Find the Invoke URL and save it for later (it should be something like:
https://[something].execute-api.[region].amazonaws.com/prod/log
)
- From the AWS Management Console, find the service "S3"
- Create a new bucket:
- Name:
blood-pressure-logger-[your-last-name]
(if that already exists, append a number to the end) - Ensure that "Block all public access" is unchecked
- Check "I acknowledge that the current settings might result in this bucket and the objects within becoming public."
- Click "Create bucket"
- Name:
- From your code editor of choice (on your machine), open
index.html
from this repository- Scroll down until you find "
{{INVOKE_URL}}
" and replace it with the URL found from the previous part
- Scroll down until you find "
- From your code editor of choice (on your machine), open
show.html
from this repository- Scroll down until you find "
{{INVOKE_URL}}
" and replace it with the URL found from the previous part
- Scroll down until you find "
- Select the newly created bucket from the AWS console
- Select "Upload" and upload the modified files:
index.html
andshow.html
- Select "Next"
- Under "Manage Public Permissions", choose "Grant public read access to this object(s)"
- Go to the "Properties" tab
- Select "Static website hosting"
- Choose "Use this bucket to host a website"
- Index document:
index.html
- Copy the Endpoint URL shown
- Click "Save"
- Index document:
- Open the Endpoint URL shown from the previous step to see the Blood Pressure Logger in action
- Try it out!
- This should not be used in a production environment and is provided for informational purposes only
- This comes with no warranty
- I am not liable for any costs incurred on your AWS account as a result of following this tutorial