Managing AWS SAMÂ CLI versions
Manage your AWS Serverless Application Model Command Line Interface (AWS SAMÂ CLI) versions through upgrading, downgrading, and uninstalling. Optionally, you can download and install the AWS SAMÂ CLI nightly build.
Topics
Upgrading the AWS SAMÂ CLI
To upgrade the AWS SAMÂ CLI on Linux, follow the installation instructions in Installing the AWS SAMÂ CLI,
but add the --update option to the install command, as follows:
sudo ./sam-installation/install --update
The AWS SAMÂ CLI must be upgraded through the same method used to install it. We recommend that you use the package installer to install and upgrade the AWS SAMÂ CLI.
To upgrade the AWS SAMÂ CLI using the package installer, install the latest package version. For instructions, see Installing the AWS SAMÂ CLI.
To upgrade the AWS SAMÂ CLI, repeat the Windows installation steps in Install the AWS SAMÂ CLI again.
Uninstalling the AWS SAMÂ CLI
To uninstall the AWS SAMÂ CLI on Linux, you must delete the symlink and installation directory by running the following commands:
-
Locate the symlink and install paths.
-
Find the symlink using the which command:
which samThe output shows the path where the AWS SAM binaries are located, for example:
/usr/local/bin/sam
-
Find the directory that the symlink points to using the ls command:
ls -l /usr/local/bin/samIn the following example, the installation directory is
/usr/local/aws-sam-cli.lrwxrwxrwx 1 ec2-user ec2-user 49 Oct 22 09:49 /usr/local/bin/sam -> /usr/local/aws-sam-cli/current/bin/sam
-
-
Delete the symlink.
sudo rm /usr/local/bin/sam -
Delete the installation directory.
sudo rm -rf /usr/local/aws-sam-cli
Uninstall the AWS SAMÂ CLI through the same method that was used to install it. We recommend that you use the package installer to install the AWS SAMÂ CLI.
If you installed the AWS SAMÂ CLI using the package installer, follow these steps to uninstall.
To uninstall the AWS SAMÂ CLI
-
Remove the AWS SAMÂ CLI program by modifying and running the following:
$sudorm -rf/path-to/aws-sam-cli-
sudo– If your user has write permissions to where the AWS SAM CLI program is installed, sudo is not required. Otherwise, sudo is required. -
/path-to– Path to where you installed the AWS SAM CLI program. The default location is/usr/local.
-
-
Remove the AWS SAMÂ CLI
$PATHby modifying and running the following:$sudorm -rf/path-to-symlink-directory/sam-
sudo– If your user has write permissions to$PATH, sudo is not required. Otherwise, sudo is required. -
path-to-symlink-directory– Your$PATHenvironment variable. The default location is/usr/local/bin.
-
-
Verify that the AWS SAMÂ CLI is uninstalled by running the following:
$sam --versioncommand not found: sam
To uninstall the AWS SAMÂ CLI using Windows Settings, follow these steps:
-
From the Start menu, search for "Add or remove programs".
-
Choose the result named AWS SAM Command Line Interface, and then choose Uninstall to launch the uninstaller.
-
Confirm that you want to uninstall the AWS SAMÂ CLI.
Switch from using Homebrew to manage the AWS SAMÂ CLI
If you use Homebrew to install and upgrade the AWS SAMÂ CLI, we recommend using an AWS supported method. Follow these instructions to switch to a supported method.
To switch from using Homebrew
-
Follow instructions at Uninstalling a Homebrew installed AWS SAM CLI to uninstall the Homebrew managed version.
-
Follow instructions at Install the AWS SAMÂ CLI to install the AWS SAM CLI using a supported method.
Managing the AWS SAMÂ CLI nightly build
You can download and install the AWS SAMÂ CLI nightly build. It contains a pre-release
version of the AWS SAMÂ CLI code that may be less stable than the production version. When
installed, you can use the nightly build with the sam-nightly command. You
can install and use both the production and nightly build versions of the AWS SAMÂ CLI at the
same time.
Note
The nightly build does not contain a pre-release version of the build image. Because of that, building your serverless application with the --use-container option uses the latest production version of the build image.
Installing the AWS SAMÂ CLI nightly build
To install the AWS SAMÂ CLI nightly build, follow these instructions.
You can install the nightly build version of the AWS SAMÂ CLI on the Linux x86_64 platform using the package installer.
To install the AWS SAMÂ CLI nightly build
-
Download the package installer from sam-cli-nightly
in the aws-sam-cli GitHub repository. -
Follow the steps for installing the AWS SAMÂ CLI to install the nightly build package.
You can install the nightly build version of the AWS SAMÂ CLI on macOS, using the nightly build package installer.
To install the AWS SAMÂ CLI nightly build
-
Download the package installer for your platform from sam-cli-nightly
in the aws-sam-cli GitHub repository. -
Follow the steps for installing the AWS SAMÂ CLI to install the nightly build package.
The nightly build version of the AWS SAMÂ CLI is available with this download link:
AWS SAMÂ CLI nightly build
To verify that you have installed the nightly build version, run the
sam-nightly --version command. The output of this command is in the
form 1.X.Y.dev<YYYYMMDDHHmm>, for example:
SAM CLI, version 1.20.0.dev202103151200Switch from Homebrew to the package installer
If you are using Homebrew to install and upgrade the AWS SAMÂ CLI nightly build and would like to switch to using the package installer, follow these steps.
To switch from Homebrew to the package installer
-
Uninstall the Homebrew installed AWS SAMÂ CLI nightly build.
$brew uninstall aws-sam-cli-nightly -
Verify that the AWS SAMÂ CLI nightly build is uninstalled by running the following:
$sam-nightly --versionzsh: command not found: sam-nightly -
Follow steps in the previous section to install the AWS SAMÂ CLI nightly build.
Installing the AWS SAMÂ CLI into a virtual environment using pip
We recommend using the native package installer to install the AWS SAMÂ CLI. If you must use pip, we recommend that you install the AWS SAMÂ CLI into a virtual environment. This ensures a clean installation environment and an isolated environment if errors occur.
Note
As of October 24, 2023, the AWS SAM CLI is discontinuing support for Python 3.7. To learn more, see AWS SAMÂ CLI discontinuing support for Python 3.7.
To install the AWS SAMÂ CLI into a virtual environment
-
From a starting directory of your choice, create a virtual environment and name it.
-
Activate the virtual environment
-
Install the AWS SAMÂ CLI into your virtual environment.
(venv) $pip install --upgrade aws-sam-cli -
Verify that the AWS SAMÂ CLI is installed correctly.
(venv) $sam --versionSAM CLI, version1.94.0 -
You can use the
deactivatecommand to exit the virtual environment. Whenever you start a new session, you must reactivate the environment.
Managing the AWS SAMÂ CLI with Homebrew
Note
Starting September 2023, AWS will no longer maintain the AWS managed Homebrew installer for the AWS SAMÂ CLI
(aws/tap/aws-sam-cli). To continue using Homebrew, you can use the community managed
installer (aws-sam-cli). From September 2023, any Homebrew command that references
aws/tap/aws-sam-cli will redirect to aws-sam-cli.
We recommend that you use our supported installation and upgrade methods.
Installing the AWS SAMÂ CLI using Homebrew
Note
These instructions use the community managed AWS SAMÂ CLI Homebrew installer. For further support,
see the homebrew-core
To install the AWS SAMÂ CLI
-
Run the following:
$brew install aws-sam-cli -
Verify the installation:
$sam --versionAfter successful installation of the AWS SAMÂ CLI, you should see output like the following:
SAM CLI, version1.94.0
Upgrading the AWS SAMÂ CLI using Homebrew
To upgrade the AWS SAMÂ CLI using Homebrew, run the following command:
$brew upgrade aws-sam-cli
Uninstalling a Homebrew installed AWS SAM CLI
If the AWS SAMÂ CLI was installed using Homebrew, follow these steps to uninstall it.
To uninstall the AWS SAMÂ CLI
-
Run the following:
$brew uninstall aws-sam-cli -
Verify that the AWS SAMÂ CLI is uninstalled by running the following:
$sam --versioncommand not found: sam
Switching to the community managed Homebrew installer
If you are using the AWS managed Homebrew installer (aws/tap/aws-sam-cli) and prefer
to continue using Homebrew, we recommend switching to the community managed Homebrew
installer (aws-sam-cli).
To switch in a single command, run the following:
$brew uninstall aws-sam-cli && brew untap aws/tap && brew cleanup aws/tap && brew update && brew install aws-sam-cli
Follow these instructions to run each command individually.
To switch to the community managed Homebrew installer
-
Uninstall the AWS managed Homebrew version of the AWS SAMÂ CLI:
$brew uninstall aws-sam-cli -
Verify that the AWS SAMÂ CLI has been uninstalled:
$which samsam not found -
Remove the AWS managed AWS SAMÂ CLI tap:
$brew untap aws/tapIf you receive an error like the following, add the
--forceoption and try again.Error: Refusing to untap aws/tap because it contains the following installed formulae or casks: aws-sam-cli-nightly
-
Remove cached files for the AWS managed installer:
$brew cleanup aws/tap -
Update Homebrew and all formulae:
$brew update -
Install the community managed version of the AWS SAMÂ CLI:
$brew install aws-sam-cli -
Verify that the AWS SAMÂ CLI is successfully installed:
$sam --versionSAM CLI, version1.94.0
Troubleshooting
If you come across errors when installing or using the AWS SAMÂ CLI, see AWS SAMÂ CLI troubleshooting.

