I'm working on a web app using Supabase, Node.js, and React, and I've been managing just fine with my local development setup for the backend, frontend, and Supabase database. Since this is still in the pre-release stage, I've kept things simple without a staging environment. Recently, I need to add an AWS Lambda function and API Gateway endpoints to my project, and I'm wondering about the feasibility of developing them completely locally using AWS SAM. I've come across mixed opinions about whether this is practical given the challenges of replicating a true serverless environment without an intermediate staging setup. I'd love to know from your experiences:
* Is it practical to develop AWS Lambda functions solely on a local setup without deploying to a staging environment?
* What challenges should I look out for if I choose to do local-only development with Lambda and API Gateway?
* Would you recommend setting up a staging environment even before launching the first version of my product?
5 Answers
Using a beta AWS environment or creating a throwaway staging account can make things easier for testing your Lambda functions. It's a good approach to ensure that your workflows are smooth without getting stuck in local-only setups.
Check out LocalStack and AWS SAM for local development. However, I recommend setting up a dev environment instead for convenience—plus, you get a million free requests per month! Creating a staging environment can be set up quickly, and I've written a guide on how to do it if you’re interested.
I often develop locally with a PostgreSQL instance, and LocalStack works well for simulating AWS services. But be aware that IAMs aren’t handled well with it and connecting Lambda to a PostgreSQL RDS can be cumbersome. For basic development, you might start locally, then move to a staging environment for integration testing.
SAM local is quite handy; just use 'sam local invoke' to test your Lambdas. I find it's usually the best tool for the job because it interprets CDK/CloudFormation well. Just keep in mind that SAM local isn’t perfect—like environment variables need to be set for each function. Experimenting with setups will help you find what works best for you!
Why stress too much over testing Lambda functions? Focus on solid unit testing, as they are designed to be simple functions. Good unit tests can alleviate concerns about whether it runs locally or on AWS. Still, having multiple environments is generally good practice to avoid surprises later.
Totally agree! A stable API with good documentation can make life a lot easier.
That's actually what I thought initially. But since I’m working directly with my local PostgreSQL database, I ran into issues. I need the API Gateway's functionality to check against the local Supabase database to verify user payments.