Paco
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
If you want to treat those lambdas like a 3rd party dependency to your sst app then you can go about it that way, but as far as sst is concerned updating/creating are the same thing. It’s got a set of resources it controls (in a cloudformation stack)
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
You should just recreate them tbh, there are ways to import them by arn but it’s unnecessary complexity.
Deploying to aws especially once you’re using a tool like sst is essentially free
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
It basically just creates a cloudformation changeset
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
If you’re using sst you don’t need terraform at all. You just call sst deploy and it will deploy to aws, creating or deleting resources if necessary.
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
I prefer strictly using cdk over Sst, but I can see why Sst makes things simpler. Defining everything in typescript just works better in the long run imo. Right now at work we use a mixture of them and I don’t really like it. The types for api gateway on cdk are pretty mid but you could write a higher level construct to make it easier
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
I’ve used code between my cdk infra and my lambdas before
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
Nah keep your infra and source in the same repo, it’s like half the reason. Plus you want to keep them in sync
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
Best of luck! If you run into any walls drop another question and ping me so I see!
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
I'm happy to help! It's nice to help someone out that is genuinely interested in learning and making something. Oftentimes people just ask questions for the answer and don't care too much about figuring out how to get to the answer themselves, so when I get the opportunity to help someone that cares it makes it really rewarding!
Supabase should work fine for your purposes here!
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
I would recommend just leveraging SST to create the api gateway and lambdas. It should do all of what you need.
Where are you hosting the DB? RDS? I haven't used SST for much other than the api gateway, but i know it can configure other services.
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
Hmm, I think it will still deploy the other ones due to how sst bundles them, but i'd have to check. If you don't materially change the other 7 lambdas I wouldn't worry about it.
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
That way, everyone works on their changes individually on a local environment, then pushes a branch for others to review. When everyone agrees to merge it into develop, you do that. When you're ready to ship to production, you just need to merge develop into main.
It's good practice to even do this on your solo projects. Do a self review on your feature branches. It builds a lot of skill and you can show it off to people during interviews etc. It goes a long way to have those habits and manner of working because any good development team will be using those practices. Your code isn't just what the code is, its the infrastructure & working practices around how you write software.
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
That's the advisable way to do things. You don't really want to be deploying to aws every time. If you were working with other people, you'd set up a development environment and an action to deploy to it when branches get merged into the "develop" branch, and then your production environment would get deployed to when you merge the develop branch into main
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
So once you merge your feature branch into main, then it would run
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please

65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
That’s where sls offline comes in, you wouldn’t need to deploy every time. You’d be running sls offline and hitting the endpoints that are running directly on your machine.
Regarding the gh action you posted: that’s a bad way to do it. Sst deploy will basically do that zip and upload, and do the updates to your lambdas to use that uploaded asset. It will handle everything in your functions section of the yml. You won’t have to call the aws cli yourself at all
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
I can see how serverless vs sst might be confusing, they dont make it easy.
sls offline
isn't an alternative to SST, its a tool for developing locally to mimic/emulate what your code will do if you deployed to AWS. This is important because imagine you were working with a few other people, you can't all be deploying changes to the same AWS resources willy-nilly at the same time, they'd overwrite and you'd have a bad time.
Prerequisites to the following example (i'm writing this part after i wrote the list below):
Your github actions are set up to call sst deploy
on new commits to develop
You followed the instructions to install serverless-offline
and add it as a plugin to your serverless.yml
file here: www.serverless.com/plugins/serverless-offline#installation
You don't actually need anything deployed to AWS to use sls offline. Lets say you wanted to add a new lambda for DeleteUser
1: Add the new function to serverless.yml
under your existing functions
2: Make a new file at lambdas/deleteUser.ts
3: Add a function named handler
in that file which calls your drizzle client to delete the user
4: run sls offline
in your terminal, it should have a new endpoint for DELETE /users
5: iterate on your function definition, call your handler to test it
6: once you're satisfied with the updates, make a git branch named something like feature/delete-user
and a commit your changes with a message like 'added user delete endpoint'
7: merge your branch into develop, github action will run and deploy to AWS
8: test your new endpoint using the API gateway url once the aws deploy has completed, your changes should be reflected
When your action runs sst deploy
its going to create a cloudformation deployment. It will bundle each lambda's code into a zip and create 'assets' in AWS S3 and tell aws/cloudformation "Create/update or delete each of these lambdas within this app to match this configuration i'm giving you and here's the location of the files in S3 that i want you to use for each one. also, please create/update an api gateway with these endpoints, each backed by one of those lambdas."
Sorry if that's not a good explanation. Its all backed by cloudformation so i'd recommend looking into how that works if you want to understand what's going on behind the scenes a little deeper. I'd also be happy to give your code a look this week if you publish publicly, but i have a dayjob so it won't be until at earliest tomorrow evening US time65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
Really on a production situation you'd want to only be deploying from a pipeline. Pushing it up from your machine directly is liable to get yourself into trouble. You can just set it to run the deploy when you push to develop or master/main, then make PRs to those branches (get into the habit of working your changes in a branch off of develop, merging in that branch to develop once you've got your feature working, then merging develop into master/main)
Sst handles deploying multiple lambdas. You just add them to your yml file as different endpoints under the functions like you screenshotted above.
The development flow with sls offline is you start the server in your cli, it spins up all of your "lambdas" on some localhost port (e.g. its running only on your computer, just mimicking what it will be like on AWS), then you can run your webapp or whatever with that url as your base api url (or postman or just running curl against your localhost endpoints), then in production that api url should be set to your api gateway url and it will work the same, except its running on aws lambda instead of your pc. It automatically watches your changes, so you can make updates and call the endpoints to test it out.
I haven't used live lambda so I can't help you there. Presumably it keeps the same aws gateway endpoints and just proxies your requests down to your machine.
The key benefit of these tools is that your code can be shared. you can make a single module (like your drizzle client) and import it into each of your lambdas to use it. It's not really a separate package (package has a special connotation in nodejs land, would refer to something you can npm install etc with a package.json file). Each lambda is essentially just a bundled up version of your whole application with the entry function set to the function you specify in your serverless.yml file. SST just handles that packaging and the cloudformation updates when you deploy to set up the api gateway, lambdas, and other aws resources
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
there's kinda 2 paths: live lambda or serverless offline, i'll direct you to the docs on the nuanced differences. Since you're just using api gateway, sls offline might make it conceptually a little easier to work with.
https://v2.sst.dev/live-lambda-development#how-live-lambda-is-different
https://www.serverless.com/plugins/serverless-offline
Sls offline will not deploy anything anywhere. it runs in a terminal on your machine. On the other hand running sst dev with live lambda is going to replace all of the lambdas up on aws with stubs which are essentially proxies to your machine. If you use that, you're going to want a different environment on AWS for each developer to use
65 replies
TTCTheo's Typesafe Cult
•Created by rNdom on 3/15/2025 in #questions
aws lambda + drizzle orm help me please
Your typescript code as written is not actually runnable on node. Its being compiled and minified. You can disable minification and enable sourcemaps in your SST configuration to make it more readable. I would also recommend developing locally with sls-offline or another tool instead of deploying to AWS every time.
65 replies