Posted On: Jul 19, 2018
The AWS Serverless Application Model (SAM) Command Line Interface (CLI) lets you locally build, test, and debug serverless applications defined by AWS SAM templates. You can now use the sam logs command to fetch, tail, and filter logs generated by your AWS Lambda functions. You can also use the sam local start-lambda command to invoke local Lambda functions from your automated tests.
The sam logs command allows you to fetch all logs generated by your Lambda function so you can troubleshoot failures faster, directly from SAM CLI. You can fetch logs for a specific time range, or use the --tail option to see new logs as they arrive. You can also use the --filter option to quickly find logs that match terms, phrases, or values in your logs.
The sam local start-lambda command starts a local endpoint that emulates the Lambda service’s invoke endpoint so you can invoke local Lambda functions from your automated tests. This allows you to write tests once and run them against a local or a deployed Lambda function.
To get started with SAM CLI, install it using the command: pip install aws-sam-cli. You can also use SAM CLI with IDEs such as AWS Cloud9, Visual Studio Code, and Eclipse. To learn more about building, testing, and deploying serverless applications using SAM CLI, visit our documentation and the code repository on GitHub.
Modified 12/23/2021 – In an effort to ensure a great experience, expired links in this post have been updated or removed from the original post.