The AWS Serverless Application Model (SAM) is a framework for building serverless applications on AWS, making it easier to create, manage, and deploy serverless applications using AWS CloudFormation. The SAM framework is built on top of CloudFormation, which means that you can use CloudFormation to create your serverless application resources and use the SAM framework to define the serverless components of your application.
The SAM CLI is a command-line tool that enables you to build, test, and deploy serverless applications that are defined using the AWS SAM framework. It provides a simplified way to work with serverless applications by abstracting away some of the underlying complexity of AWS services.
With the SAM CLI, you can create and manage serverless applications using local development environments, such as your own laptop, before deploying them to the AWS Cloud. The CLI includes commands to package and deploy your application, to test your application locally using the built-in Lambda runtime, and to manage application resources such as Lambda functions, API Gateway APIs, and DynamoDB tables.
sam Command Examples
1. Initialize a serverless application:
# sam init
2. Initialize a serverless application with a specific runtime:
# sam init --runtime python3.7
3. Package a SAM application:
# sam package
4. Build your Lambda function code:
# sam build
5. Run your serverless application locally:
# sam local start-api
6. Deploy an AWS SAM application:
# sam deploy
Summary
The SAM CLI is open source software and is available on GitHub, where you can find documentation, examples, and community support. It is written in Python and is available for Windows, macOS, and Linux operating systems.
Overall, the SAM CLI makes it easier for developers to build and deploy serverless applications on AWS, allowing them to focus on their application code rather than the underlying infrastructure.