I'm having a tough time figuring out how to set up local development for my Node.js Lambda functions that utilize the Middy framework. I've attempted to configure Serverless with API Gateway on my local machine but haven't had much luck. I'm curious about your experiences with Middy and local development setups. Are there any specific configurations for the SAM CLI that pair well with Middy? Also, has anyone created any custom local testing environments for functions based on Middy? I'm seeking strategies and tips that have worked for you!
7 Answers
What are you specifically using Middy for? I've had mixed results with it in my projects. Normally, I find that local Jest tests suffice.
I've shifted towards using containerized Lambdas, which makes local testing much easier. By working with a container artifact instead of a zip file, you can test it locally by running the container directly.
For straightforward JSON manipulation, AWS offers Docker images that you can run locally with your JSON payload. They’re quite faithful to the actual runtimes, though the setup can depend on your specific context.
It's often best to go for unit tests and set up a staging environment. If you utilize Infrastructure as Code (IaC), organizing this shouldn't be too complex.
If you're just testing a simple Lambda that doesn't rely on any external dependencies, you can call it directly like any other library function instead of through AWS's Lambda entrypoint.
AWS recently rolled out features that simplify testing and debugging Lambda functions while keeping IAM permissions and networking intact. It's worth checking out their new updates for a smoother development process!
Does this work for custom runtimes in Go too? I'm really interested in how this would function for IntelliJ.
Definitely! This could open up new avenues for us.
I typically use SAM for local testing with Docker, though I prefer testing in the cloud with real policies and networks for accuracy. The SAM Sync feature helps with quick deployment to get testing done faster.
We primarily use Middy for HTTP routing within our setup, and it's been fairly reliable for us. I'm intrigued to hear more about the issues you've faced!