Run convex from AWS lambda
I have next JS application with convex back-end. I want to run my scalable code on AWS lambdas.
At first I wanted to use queues and pass data to the lambdas like that. Then I thought it might be simpler to just let each lambda access convex directly.
My convex folder is generated on my next JS project (The lambda code is a sub-project of that project)
This is the structure of my project (think I could do it better?)
project-root/
├── src/
│ ├── app/
│ │ └── (Next.js app router structure)
│ └── lambda/ (the lambda project)
│ ├── src/
│ │ ├──lambda-code.ts
│ │ └── convex-client.ts (Needs to access convex prefarably also in dev)
│ ├── deploy.js
│ ├── package.json
│ └── .env
├── convex/
│ └── (convex files and folders)
└── package.json
So, what I am really asking is what's the best way to re-use the entire convex generated folder on the lambda project? (lambda code is writing in typescript and bundled to javascript).
PS: also wondering if that's better than my original solution using queues which involves more calls to pass data. (And might be cheaper???).5 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Okay I got it to work for now by copying the entire convex folder over to the lambda. Not sure if necessary but it's working, doubled my lambda size to ~40mb heh.
Still wonder if it's a good practice or not.
so, verifying here -- you want to be able to call convex from lambda?
if so, you probably want a lightweight version of the api folder. there's a new solution for that: https://docs.convex.dev/production/multiple-repos?ref=news.convex.dev
Multiple Repositories | Convex Developer Hub
Use Convex in multiple repositories
see the tool
ts-api-spec
that will generate a really lightweight version of the api
object you can embed in another environment to use with the HTTP client