AppSync + DynamoDB Instead of Lambda and RDS
Most of a $38 monthly AWS bill was idle database and network lines, not compute. I rebuilt the backend on AppSync and DynamoDB. What worked, what did not.
Most of the $37.89 this app’s old backend cost in November so far went to a database and network add-ons, not to the code that ran. I rebuilt the backend on AWS AppSync, DynamoDB and Cognito. It works on test traffic. The website and the switch-over are not done, and the saving is a projection because the old backend is still running.
I’m Shubham More. The app is SiteBook, which tracks workers, attendance, materials and payments for construction sites. It is a client project, and I also used the rebuild as a personal study of AppSync and DynamoDB. The repository is private, so this post describes the design and does not link code.
In plain terms
- Problem: a small app with little traffic cost about $39 a month to keep running, and none of it scaled down.
- Decision: replace servers and a SQL database with a managed GraphQL API (AppSync) and one pay-per-request database table (DynamoDB).
- Built: 49 operations, login, role-based access and a data import, in 43 commits over about eight hours on 2026-11-29. Earlier groundwork (a table and user pool on 11-26, abandoned attempts from 11-21) is not counted.
- Not done: the website, the cut-over, tests, infrastructure as code and security hardening.
- My role: I did all of it, alone. There is no team, and there has been no real user traffic yet.
The old backend and the new one. Costs are pre-tax, November to date; the saving is projected, not realised.
Situation: where the money went
The old backend had little traffic: about 16,500 website requests in 14 days, and only one of its nine Go functions ran at all. It used those functions, one small server and a small Postgres database.
| November to date, pre-tax | USD |
|---|---|
| Database (RDS) | 17.61 |
| Network add-ons (a private endpoint 8.64, public IP addresses 6.91) | 15.55 |
| Server (compute 3.86, disk 0.87) | 4.73 |
| Old backend total | 37.89 |
| New backend (AppSync and DynamoDB; login is free-tier) | about 0.0025 |
That is $1.31 a day, about $39 a month. The last row is not a fair comparison: the new backend has existed for four days and served about 700 test requests, and each request does extra reads for access checks. The $39 also assumes the database, named “shared”, has no other users. I did not measure function cold starts, and I tried Aurora Serverless for only five hours (about $0.90), so I have no cost conclusion about it.
Task: what the replacement had to do
- Many customers in one system. Every request belongs to one business, and one user can belong to several.
- Role-based access, with 46 fields guarded by permission rules.
- Phone and PIN login.
- Soft deletes, so removing a record only marks it deleted, including removing a whole business.
- No servers to run, and pay only per request.
The price: no ad hoc queries, no joins, harder reporting, hard limits (100 writes per transaction, 1 MB per read) and access control I had to build myself.
Action: how I built it
Several commits share a timestamp, so the order inside a phase is approximate.
One table, designed around how the app reads
I listed the reads first, then chose keys. Everything lives in one table with a partition key (PK) and a sort key (SK):
| Item | PK | SK |
|---|---|---|
| User profile | USER#<id> | PROFILE |
| User belongs to business | USER#<id> | MEMBERSHIP#<business>#<role> |
| Business has user (copy) | MERCHANT#<id> | MEMBER#<user>#<role> |
| Attendance | MERCHANT#<id> | ATTENDANCE#<yyyy-mm>#<worker>#<dd>#<site>#<entry> |
The change that mattered most was the copy. “Who is in this business” would otherwise scan the whole table, so each membership is stored twice in one transaction. Both rows are saved or neither is, and listing a business’s users is one lookup. Rows from before I added the copy needed a backfill script.
Attendance changed too. Most reads are “a month for a site or a worker”, so I put the month first in the key and made the site a filter. A range that does not fit in one page of results fails with an error instead of returning partial data.
Access control I built by hand
The built-in group directives (@aws_auth) deployed without error in my setup but did not stop an admin from calling an owner-only action. I did not diagnose why. I replaced them with permission scopes.
That code changed shape for almost seven hours: multi-step functions (AppSync “pipeline resolvers”) went in, out and back in, and scopes were added, cut, removed and reinstated at 22:41. What stayed is a file with one line per field, for example Mutation.createMerchant = merchant:create @global. A deploy script turns each line into two checks that run before the field: one finds the caller’s membership, the other loads the role’s scopes. Both read the latest data, so a role change applies on the next request.
Risk: a field missing from that file is unprotected.
Creating a user without a Lambda function
createUser is a four-step pipeline: check the business exists, create the login in Cognito, set the PIN, then write the profile and both membership rows. It has a gap: Cognito and DynamoDB cannot be saved together, so a failure after the login is created leaves a login with no profile.
Moving the data
The data came from a Postgres export. Every script is a dry run unless given --apply, and the attendance move can be re-run safely because each new id is derived from the old key. I have not reconciled the 90 migrated items against Postgres.
Result: what shipped and what is open
- 49 operations (18 reads, 31 writes) with no Lambda in the request path, one on-demand table, 90 items.
- Latency on 732 test requests: median 56 ms, 90th percentile 110 ms. This is one developer’s traffic, not a benchmark.
- Not claimed: real savings, or any cold-start comparison.
What I would do differently
- Write the access patterns down first. Functions, scopes and roles each went in and out within hours because the model was undecided.
- Store the business-to-user copy from the start.
- Fail loudly, and check that I do. Reads that overflow a page raise an error, but two list queries would silently return partial results past 1 MB. The table is 13.6 KB today, so it has not mattered yet.
- Test that access control is enforced before trusting a directive.
When not to do this
- You need ad hoc queries, joins or reporting.
- One operation touches more than about 100 items: deleting a large business fails, and so does a read over 1 MB.
- A workflow that spans Cognito and DynamoDB must be all-or-nothing.
- You need declarative auth, tests and infrastructure as code from day one.
What is still open
- Deleting a large business needs batching.
- Some list queries fail above 100 keys, and role deletion fails past 1 MB.
- User creation needs a clean-up step, and role ids are not validated.
- No infrastructure as code and no tests. Security hardening and monitoring are unfinished.
Next: a static website on the same API
The plan is a static website on S3 behind CloudFront that calls AppSync directly, with DynamoDB as the only database. The backend is built. The website and cut-over are not started and I have not sized them. Removing the server saves about $4.70 plus part of the $6.91 address charge. Most of the saving comes when the old database and functions are shut down. I have not confirmed what the server serves today, so I would check that first.
Work with me
I’m open to remote senior engineering roles and a few focused projects. If your AWS bill is mostly idle database and network lines, or you need a multi-tenant data model on DynamoDB, I report what a change saves, what it costs and what I did not measure. hi@shubham-more.me or LinkedIn, or see the projects page.
Frequently asked questions
Short answers to the questions this post gets asked most.
Can AppSync replace Lambda?
For the small multi-tenant API I built, yes. It runs 49 operations on 47 pipeline resolvers and 2 unit resolvers in APPSYNC_JS, with DynamoDB, Cognito over HTTP and a none source, and no Lambda in the request path. It stops fitting when one operation needs more than 100 transactional actions or a result larger than a 1 MB page.
How do you model a multi-tenant app in one DynamoDB table?
Every item uses PK and SK with a type prefix such as USER# or MERCHANT#, with no id or entityType attribute and no secondary indexes. Each membership is written twice in one conditional transaction, once under the user and once under the merchant, so listing a merchant's users is a single-partition Query.
What did moving from RDS Postgres to DynamoDB cost you?
Ad hoc queries, joins and easy reporting. Attendance is filtered by site after the read, and a range that needs more than one page fails with a TooLarge error. Creating a user also spans Cognito and DynamoDB with no rollback, so a late failure can leave a Cognito login without a profile.
How much does it save?
Projected, not realised: about $39 a month, from the legacy RDS, VPC and EC2 lines. The new stack has run for four days on test traffic and cost about $0.0025 for AppSync and DynamoDB, so the two figures are not the same workload. Treat $39 as the ceiling of a possible saving.
When should I not use AppSync and DynamoDB?
When you need ad hoc queries or reporting, when one operation touches more than about 100 items, when a workflow spanning Cognito and DynamoDB must be atomic, or when you need declarative auth, tests and infrastructure as code from day one.