DEV Community

Discussion on: Why local development for serverless is an anti-pattern

Collapse
 
garethmcc profile image
Gareth McCumskey

But imitation is likely to be invalid. At least once a week I have a user with an issue that ends up being tracked down to either some library that is available on their local environment that isn't on Lambda, one of the vagaries about how Lambda handles the call stack, an issue with connections to database and many more all because they were attempting to imitate compute locally.

Just test execution of the Lambda in the cloud and save yourself the hassle.

Collapse
 
horaceshmorace profile image
Horace Nelson

No, sam local invoke will test your function in a Docker container running the correct versions of the OS and your language runtime, and while the hardware constraints my not be able to match exactly, it's close enough to be good enough 99% of the time. It's insane to suggest that because the testing environment is not 100% that of production, it is not useful, particularly since I'm talking about one provided by AWS itself. As someone who is constantly building on AWS Serverless technologies, sam local invoke saves a non-insignificant amount of time compared to waiting for sam deploy to finish. I say unit test correctly, and use sam local invoke to test side effects of your functions on other AWS resources in your stack.