- aws amplify
- nightscout
- postgres
- dexcom
Run a Nightscout-style follower on the new AWS Amplify: Postgres, sign-in and the app on one platform
Most people run Nightscout on a small VM with a MongoDB Atlas cluster. Here is how to run a streamlined follower on one new AWS Amplify app instead, what it costs, and how it behaves when the app sits idle.
On this page

Nightscout is the open-source follower app for blood glucose readings from the CGM (continuous glucose monitoring) devices that help millions of people with diabetes and pre-diabetes keep an eye on their sugar levels. The way the Nightscout community usually runs it on AWS is a small EC2 box with Docker Compose and a MongoDB Atlas cluster. That means a VM to patch, a container to restart and a database service to keep an eye on.
AWS launched Amplify (Gen 3) on November 30. It bundles a managed Postgres database, sign-in and hosting in one app. This post shows how to run a streamlined Nightscout follower on it. It deploys in about two minutes and costs $0 a month on the Basic plan.
There is one thing to know before you start: the app only works while someone is looking at it. Below is how it behaves, what it costs, and the one small habit that keeps your readings complete.
- 107sfrom a clean git clone to a live app
- $0a month on the Basic plan
- 1.1sextra on the first page load after the app has slept
What you get
It is a small Next.js app, not the complete Nightscout. The original Nightscout needs MongoDB, WebSockets and a process that never stops, and none of that currently fits on Amplify. So the app polls instead. It is not for medical decisions, and Dexcom Share is an unofficial API that Dexcom can change.

- A browser or a follower app calls the app. Browsers sign in with Amplify’s built-in sign-in. Uploaders and followers send an
api-secretheader. - The app reads and writes readings in the backend’s Postgres. Row level security decides what a browser can read.
- Every read starts a sync. If the last Dexcom call was more than 150 seconds ago, the app asks Dexcom Share for new readings.
- One conditional
UPDATEdecides which app instance may call Dexcom, so two instances never call at once. - The sync fills in everything since the last stored reading.
The Amplify backend is the database and the sign-in. The app, the schema and the users are deployed and deleted together. There is no Atlas connection string to copy, no IP allow-list, no VM, no Docker Compose file and no public IPv4 address to pay for.
Deploy it yourself
You need:
- an AWS account with permission to use Amplify
- AWS CLI v2, version 2.43.0 or later (it includes
aws amplifygen3, so check withaws amplifygen3 help) - Node 22.12 or later and pnpm
- the Dexcom login of the phone that carries the sensor, with Share switched on
git clone https://github.com/awsdataarchitect/nightscout-on-amplify
cd nightscout-on-amplify
pnpm install
# dry run: prints six steps and changes nothing
node scripts/setup.mjs --owner you@example.com --dexcom-user YOUR_DEXCOM_NAME --dexcom-server US
# the real thing
node scripts/setup.mjs --owner you@example.com --dexcom-user YOUR_DEXCOM_NAME --dexcom-server US --go--dexcom-server is US, JP, or EU for everywhere else. Add --region if your AWS CLI’s default Region is not where you want the app.
The script asks for your Dexcom password and a new dashboard password with hidden typing, so neither lands in your shell history. It then creates the app, stores the Dexcom password and an API secret as secret variables, deploys, creates your sign-in, adds it to the allowlist and runs the first sync. Running it again is safe.
In testing, a run took 107 seconds from --go to a fresh reading, and the first sync stored 288 readings (the 24 hours Dexcom keeps).
Let someone else sign in
Sign-up is closed, so nobody can make their own account. Two things make a person a dashboard user, and you need both:
- A sign-in account. You create it. The backend refuses public sign-up with
EMAIL_PASSWORD_SIGN_UP_DISABLED. The Manage users page in the docs has the commands. - A row in the
viewerstable. Row level security only shows readings to user ids on that list. An account without the row can sign in and sees nothing.
scripts/add-user.mjs does both:
node scripts/add-user.mjs --email person@example.com # asks for their password, hidden
node scripts/add-user.mjs --email person@example.com --generate # random password, saved under .secrets/users/
node scripts/add-user.mjs --email person@example.com --remove # off the list, account deletedThe app has no “forgot password” page, so the docs’ invite flow (create the account, then let the person reset their password by email) doesn’t work as it stands. To set a new password, run aws amplifygen3 backend user edit --email person@example.com --password.
What it costs on Amplify
The whole app runs on the free Basic plan: hosting, Postgres, sign-in and the Data API. The pricing page lists these allowances for Basic:
- 25 apps, with 2 environments each
- 2 backends per account, each with its own Postgres database
- 5 vCPU-hours and 400 GB-hours of server compute (builds count too)
- 1 million CDN requests
- 100 GB of data transfer
- 100 BCU-hours for each backend
- 2 GB-months of database storage for the account, 1 GB-month for each branch
Basic has no overage. Past the CDN or data-transfer limit the site stops serving until the month resets. Past the backend’s BCU-hours, Amplify pauses the backend until you resume it.
Will a follower app fit in the Free Basic Plan?
- Requests. A dashboard tab left open all month makes 86,400 sync calls. That is 8.6% of the million requests, if each call counts. Check how your account counts them.
- Storage. A year of readings is 105,120 rows. In a local Postgres that took 17 MB, under 1% of the 2 GB.
- Compute. Open the Monitoring page in the Amplify console. It shows requests, latency and data out for each environment, so you can see how close you are to the limits before you count on $0.
How that compares
Here is the same workload on other platforms. It is a Nightscout container measured over four months: about 100 MiB of memory (128 MiB at peak), under 1% of one CPU core, and about 6 GB of traffic a month.
AWS rows are list prices from the AWS Pricing API for US East (Ohio), for a 730-hour month, read on December 3. Other vendors’ prices come from their pricing pages, read the same week.
| Where it runs | Per month | Database | Catch |
|---|---|---|---|
| AWS Amplify, Basic | $0 | Built in: Postgres, sign-in and Data API. 2 databases included on Basic, 10 on Pro | One deploy for app, database and users. Runs the streamlined app. |
| Northflank Sandbox | $0 | Its own database add-on, 1 included | Needs a valid payment method. Always on. |
| Vercel Hobby | $0 | Third party: Postgres comes from a Marketplace provider such as Neon, not from Vercel | A second vendor to set up. Runs the streamlined app. |
| Fly.io | $3.72 | Third party: Atlas Free | 512 MB shared machine plus $0.03 of traffic. |
| Railway Hobby | $5 | Atlas Free (third party) or Railway’s own | Includes $5 of usage. This workload comes to about $1.11. |
| Heroku Eco / Basic | $5 / $7 | Third party: Atlas Free | Eco sleeps after 30 minutes without traffic. |
EC2 t4g.nano, 8 GB disk | $7.36 | Third party: Atlas Free | $3.07 instance, $0.64 disk, $3.65 public IPv4 address. Sized from the 128 MiB peak. |
EC2 t9g.nano, 8 GB disk | $8.09 | Third party: Atlas Free | $3.80 instance, $0.64 disk, $3.65 public IPv4 address. The newer generation costs a little more than t4g.nano. |
| ECS Fargate + HTTP API + Cloud Map, no load balancer | $11.96 | Third party: Atlas Free | $7.21 for a 0.25 vCPU, 0.5 GB task, $3.65 public IPv4 address, $0.10 Cloud Map, and about $1 for a million HTTP API requests. |
Amplify is the only row in the table above where hosting, database and sign-in come as one deploy on one bill, and on the Basic plan it costs $0. That is $7 to $12 a month less than the same workload on EC2 or Fargate, with no VM to patch and no Atlas cluster to run. On EC2, AWS also charges $0.005 an hour for each public IPv4 address, about half of the t4g.nano bill.
This is not like-for-like. Amplify and Vercel run the streamlined app, which has no treatments, profile, alarms or push. The other rows run the real Nightscout. Nothing was deployed on the other platforms: they are published prices applied to measured numbers. Azure, Google Cloud and Render are not priced.
The trade-off: Amplify sleeps when nobody visits
Amplify stops an idle app instance, and the sync timer inside it stops too. In testing that happened about five and a half minutes after the last request.
The dashboard catches up when you open it, because every read starts a sync. But there are no alarms and no push notifications. Dexcom only returns the last 24 hours, so if nobody opens the app for a day, the readings in between are lost.
Two ways to avoid holes:
- Open the dashboard, or have a follower app poll the API, at least once a day.
- Add a scheduled job: a Lambda function on Amazon EventBridge Scheduler that calls the backend. The Amplify docs show how. This app doesn’t use one, so it stays on the free Basic plan. Lambda and EventBridge Scheduler are billed separately.
How fast does an Amplify backend wake up?
Fast enough that you won’t notice. The backend sleeps after 5 minutes without traffic, and the docs say the next request wakes it “in seconds”. Measured:
| Backend idle for | First request | Next request |
|---|---|---|
| 7 minutes | 1.6 s | 0.27 s |
| About 17 hours | 5.0 s | 0.34 s |
Nothing failed, and the next request was back to normal speed. So there is no need for a keep-alive ping. AWS hasn’t published how the wake-up works, so these numbers are only what was measured, one test each.
The app itself sleeps too. Its first page load took about 1.3 seconds instead of 0.15.
Sleeping is not pausing. On the free plan, Amplify pauses a backend that no branch has used for 7 days, and a request will not wake a paused one. Run aws amplifygen3 backend resume --app NAME and wait until aws amplifygen3 app get --app NAME shows READY. Open the dashboard at least once a week.
Protect your Dexcom account
If several apps share one Dexcom account, rejected sign-ins can get it locked. The bridge guards against that:
- One Dexcom call every 150 seconds across all instances.
- A failed sign-in pauses it for 30, 60, 120, 240, then 360 minutes.
- It reserves 30 minutes before every sign-in, so a crash can’t cause a quick second try.
- Only changing the Dexcom credentials unlocks it.
Amplify feedback: rough edges to know about
These came up while building the app. Each one is something the Amplify team could make clearer, and each has a workaround.
Secret variables: var list and var get show plain values
Both commands print a plain variable’s value. Anything sensitive needs --secret, or --secrets A,B with var upload. The setup script does this for you. Set a secret again without --secret and it turns into a plain variable.
Backend address has no Region, so signing can fail
A backend address has no Region in it, so the SDK signs for AWS_REGION or AWS_DEFAULT_REGION. If yours differs from the app’s, the Data API answers 401 invalid_credential: The request signature is not valid for this backend. That looks like a bad key. Run export AWS_REGION=<your app's Region>. The docs say this under API keys and roles, but the error message doesn’t point there.
Database commands need Docker or Finch
aws amplifygen3 db query, backend seed and backend gen-types run psql inside a container, so Docker or Finch must be running. If you have neither, install PostgreSQL 16 or later and pass its path with --psql. Deploy, variable, app and user commands need none of this.
No WebSockets and no pg_cron
A WebSocket request to the app gets a 400 from CloudFront, and the docs don’t mention it. The dashboard polls every 30 seconds instead. A migration that creates pg_cron fails with permission denied to create extension. The docs list the 28 extensions you can use, such as vector and postgis.
migration list says nothing was applied
After a deploy, aws amplifygen3 migration list prints 0 applied, 2 pending and “No deployment in this environment has reported a migration run yet”. Both migrations had run: the tables exist and the app reads and writes them. The docs say the file should show applied. If you see this, check the tables, not the list.
app get doesn’t show usage
The console has a Monitoring page with requests, latency and data out, but aws amplifygen3 app get prints only the app, backend status, firewall and environments. From the command line there is no way to check how much of your Basic allowance you have used.
Results
A Nightscout-style follower no longer needs an EC2 box, a Docker Compose file or an Atlas cluster. It deploys in about two minutes, keeps the data and the app on one platform, and costs $0 a month on Basic as long as compute stays inside the allowance.
The part to plan around is the gap. Open the dashboard once a day, or add a scheduled Lambda function, and you can delete the VM and the Atlas cluster.
You can ship your own Amplify app today: paste “Set up Amplify for me by following these instructions: https://docs.aws.amazon.com/amplify/latest/userguide/deploy-with-ai-agents.md” into your coding agent, and if you don’t have an AWS account yet, the agent can open the new AWS sign-up experience for you. Most new customers don’t need a credit card, spend limits keep the bill predictable, and the agent gets back short-lived credentials.
Ready to build your own web app on the new AWS Amplify? Ship it live and compete for a share of $100,000 in cash prizes, plus AWS Promotional Credits and swag. Join the Amplify Your Ideas hackathon.
Now, go build!