{"id":2875,"library":"aws-sam-cli","title":"AWS SAM CLI","description":"The AWS Serverless Application Model (SAM) Command Line Interface (CLI) is an open-source tool that enables developers to build, test, debug, and deploy serverless applications defined by the AWS SAM specification. It provides a local Lambda-like execution environment and integrates with container tools like Docker and Finch for local development. Currently at version 1.158.0, it maintains a frequent release cadence with updates typically occurring weekly or bi-weekly.","status":"active","version":"1.158.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-sam-cli","tags":["AWS","Serverless","CLI","Lambda","Development Tool","Deployment","Infrastructure as Code"],"install":[{"cmd":"pip install aws-sam-cli","lang":"bash","label":"Install via pip"},{"cmd":"brew tap aws/tap\nbrew install aws-sam-cli","lang":"bash","label":"Install via Homebrew (macOS/Linux)"}],"dependencies":[{"reason":"Used for building and packaging AWS Lambda functions for various runtimes and frameworks.","package":"aws-lambda-builders","optional":false},{"reason":"Used for transforming SAM templates into CloudFormation templates.","package":"aws-sam-translator","optional":false}],"imports":[{"note":"The `aws-sam-cli` package provides the `sam` executable for terminal use, not Python modules for direct programmatic import.","symbol":"AWS SAM CLI","correct":"This is a command-line interface tool and is not typically imported as a Python library in application code."}],"quickstart":{"code":"# Initialize a new serverless application (choose 'AWS Quick Start Templates', 'Python 3.x', 'Hello World Example')\nsam init --runtime python3.11 --app-template hello-world --name my-sam-app\n\n# Navigate into the project directory\ncd my-sam-app\n\n# Build your application (requires Docker or Finch for local container builds)\nsam build\n\n# Locally invoke the Lambda function with a sample event\nsam local invoke HelloWorldFunction --event events/event.json\n\n# Start a local API Gateway to test your API\nsam local start-api\n\n# Deploy your application to AWS Cloud (follow guided prompts)\n# Ensure AWS credentials are configured (e.g., via `aws configure` or environment variables)\nsam deploy --guided","lang":"bash","description":"This quickstart guides you through initializing a new Python-based 'Hello World' serverless application, building it, testing it locally using `sam local invoke` and `sam local start-api`, and finally deploying it to the AWS Cloud with `sam deploy --guided`. Local testing requires Docker or Finch to be running."},"warnings":[{"fix":"Upgrade your local Python environment to 3.8 or newer for SAM CLI installation. This does not affect the Lambda runtime version you can deploy.","message":"AWS SAM CLI discontinued official support for Python 3.7 as of October 24, 2023. If installed via pip, users on Python 3.7 will be affected. Upgrade your development environment to Python 3.8 or newer.","severity":"breaking","affected_versions":"<= 1.100.0 (approximately)"},{"fix":"Install and start Docker Desktop (or Docker Engine) or Finch on your operating system. SAM CLI will automatically detect and use Finch if Docker is not available (as of v1.137.0+).","message":"Local development and testing features (e.g., `sam build`, `sam local invoke`, `sam local start-api`) require a containerization tool like Docker or Finch to be installed and running on your local machine.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to AWS SAM CLI v1.134.0 or newer. After upgrading, you *must* re-build your applications using `sam build --use-container` to update symlinks and mitigate the issue. For CVE-2025-3047, use `--mount-symlinks` if you need the previous host-symlink resolution behavior.","message":"Security vulnerabilities (CVE-2025-3047 and CVE-2025-3048) related to symlink handling during `sam build` with Docker were found. These could allow unauthorized access to host files.","severity":"breaking","affected_versions":"<= v1.133.0 (CVE-2025-3047), <= v1.132.0 (CVE-2025-3048)"},{"fix":"Avoid explicitly setting resource names in your `template.yaml`. Instead, let CloudFormation generate names based on the stack name and resource logical ID. Pass generated resource names to your Lambda functions via environment variables, e.g., using `!Ref` or `!GetAtt` in your template.","message":"When using `sam sync` or `sam deploy` across multiple developer environments, explicitly naming resources (e.g., DynamoDB tables) in your `template.yaml` can lead to resource naming conflicts. CloudFormation generates unique names if not specified.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always make changes to your original source code files in your project directory. Run `sam build` to update the `.aws-sam/build` directory with your changes.","message":"The `.aws-sam/build` directory is an output directory for SAM CLI's build process. Manually modifying files within this directory is not recommended, as changes will be overwritten by subsequent `sam build` commands.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `sam deploy` directly, which will automatically package your application artifacts before deployment. If specific packaging parameters are needed, they can often be passed to `sam deploy`.","message":"The `sam package` command's functionality is now implicitly included within `sam deploy`. While `sam package` still works, it's generally recommended to use `sam deploy` directly, which handles both packaging and deployment.","severity":"deprecated","affected_versions":"v1.0.0 onwards, effectively deprecated by `sam deploy` improvements"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}