docs.aws.amazon.com

Install the latest release of the AWS Serverless Application Model Command Line Interface (AWS SAM CLI) on supported operating systems by following instructions in Step 1: Install the AWS CLI.

For information on managing a currently installed version of the AWS SAM CLI, including how to upgrade, uninstall, or manage nightly builds, see Managing AWS SAM CLI versions.

Is this your first time installing the AWS SAM CLI?

Complete all prerequisites in the previous section before moving forward. This includes:

  1. Signing up for an AWS account.

  2. Setting up secure access to AWS.

  3. Creating an access key ID and secret access key.

  4. Installing the AWS CLI.

  5. Configuring AWS credentials.

Topics

Installing the AWS SAM CLI

Note

Starting September 2023, AWS will no longer maintain the AWS managed Homebrew installer for the AWS SAM CLI (aws/tap/aws-sam-cli). If you use Homebrew to install and manage the AWS SAM CLI, see the following options:

To install the AWS SAM CLI, follow the instructions for your operating system.

Installation steps

Use the package installer to install the AWS SAM CLI. Additionally, the package installer has two installation methods that you can choose from: GUI and Command line. You can install for all users or just your current user. To install for all users, superuser authorization is required.

Note

AWS SAM CLI doesn't support MacOS versions older than MacOS 13.x. Upgrade to a supported version of MacOS or install AWS SAM CLI with Homebrew.

Windows Installer (MSI) files are the package installer files for the Windows operating system.

Follow these steps to install the AWS SAM CLI using the MSI file.

  1. Download the AWS SAM CLI 64-bit .

  2. (Optional) You can verify the integrity of the installer before installation. For instructions, see Optional: Verify the integrity of the AWS SAM CLI installer.

  3. Verify the installation.

    After completing the installation, verify it by opening a new command prompt or PowerShell prompt. You should be able to invoke sam from the command line.

    sam --version

    After successful installation of the AWS SAM CLI, you should see output like the following:

    SAM CLI, <latest version>
  4. Enable long paths (Windows 10 and newer only).

    Important

    The AWS SAM CLI might interact with filepaths that exceed the Windows max path limitation. This may cause errors when running sam init due to Windows 10 MAX_PATH limitations. To resolve this issue, the new long paths behavior must be configured.

    To enable long paths, see Enable Long Paths in Windows 10, Version 1607, and Later in the Microsoft Windows App Development Documentation.

  5. Install Git.

    To download sample applications using the sam init command, you must also install Git. For instructions, see Installing Git .

Troubleshooting installation errors

Linux

Docker error: "Cannot connect to the Docker daemon. Is the docker daemon running on this host?"

In some cases, to provide permissions for the ec2-user to access the Docker daemon, you might have to reboot your instance. If you receive this error, try rebooting your instance.

Shell error: "command not found"

If you receive this error, your shell can't locate the AWS SAM CLI executable in the path. Verify the location of the directory where you installed the AWS SAM CLI executable, and then verify that the directory is on your path.

AWS SAM CLI error: "/lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/local/aws-sam-cli/dist/libz.so.1)"

If you receive this error, you're using an unsupported version of Linux, and the built-in glibc version is out of date. Try either of the following:

  • Upgrade your Linux host to the 64-bit version of a recent distribution of CentOS, Fedora, Ubuntu, or Amazon Linux 2.

  • Follow the instructions for Install the AWS SAM CLI.

macOS

The installation failed

Image of the AWS SAM CLI installer showing an installation failed message

If you are installing the AWS SAM CLI for your user and selected an installation directory that you don’t have write permissions for, this error could occur. Try either of the following:

  1. Select a different installation directory that you have write permissions for.

  2. Delete the installer. Then, download and run it again.

Next steps

To learn more about the AWS SAM CLI and to begin building your own serverless applications, see the following:

Read the original on docs.aws.amazon.com ↗