AWS › AWS Serverless Application Model (SAM)
What is the SAM CLI, and how does it support local testing of serverless applications before deployment?
BeginnerAnswer
The SAM CLI is a command line tool that lets you build, test, and debug serverless applications locally on your own machine using Docker to emulate the actual Lambda execution environment, allowing you to invoke functions and test API Gateway endpoints locally before ever deploying anything to AWS, significantly speeding up the development feedback loop compared to deploying to the cloud after every small code change.
sam local invoke MyFunction --event event.json
sam local start-apiReal-world example A developer building a new Lambda function uses sam local invoke to test their function's logic against a sample event directly on their laptop, catching several bugs before ever deploying the function to an actual AWS environment.