Installing the AWS SAM CLI on Linux
The AWS Command Line Interface (AWS CLI) and Docker are required to install the AWS SAM CLI on Linux. The following steps describe how to successfully install Docker, and how to install the AWS SAM CLI using either Homebrew or Pip.
Topics
Install Docker for Linux
Docker is an application that runs containers on your Linux machines. AWS SAM provides a local environment similar to AWS Lambda to use as a Docker container. You can use this container to build, test, and debug your Lambda functions.
You must have Docker installed and working to be able to run serverless
projects and functions locally with the AWS SAM CLI. The AWS SAM CLI uses the
DOCKER_HOST environment variable to contact the Docker
daemon. The following steps describe how to install, configure, and verify a Docker
installation to work with the AWS SAM CLI.
1. Install Docker.
Docker supports several common Linux distributions. Choose your version of Linux for the correct Docker installation steps:
-
To install Docker for CentOS, see Get Docker CE for CentOS.
-
To install Docker for Debian, see Get Docker CE for Debian.
-
To install Docker for Fedora, see Get Docker CE for Fedora.
-
To install Docker for Ubuntu, see Get Docker CE for Ubuntu.
-
To install Docker for other unsupported platforms, see Install Docker CE from binaries.
2. Verify the installation.
Verify that Docker is working, and that you can run Docker commands from the
AWS SAM CLI (for example, docker ps). You don't need to
install, fetch, or pull any containers––the AWS SAM CLI does this automatically
as required.
Install the AWS SAM CLI Using Homebrew
Homebrew is a package manager available for Linux. Homebrew is required for this installation.
Follow these steps to install the AWS SAM CLI using Homebrew:
-
To install the Homebrew package manager, see Homebrew on Linux.
-
Add a brew tap from GitHub.
brew tap aws/tap -
Install aws-sam-cli from the brew tap.
brew install aws-sam-cli -
Verify
samis installed to the following location./home/homebrew/.homebrew/bin/sam -
Verify the installation. You should be able to invoke
samfrom the command line.sam --version
Install the AWS SAM CLI Using Pip
Pip is a package installer for Python. Python is required for this installation.
Follow these steps to install the AWS SAM CLI by using pip:
-
Verify that the Python version is 2.7 or 3.6.
$ python --versionIf it isn't installed, download and install Python.
-
Verify that pip is installed.
$ pip --versionIf it isn't installed, download and install pip.
-
Install
aws-sam-cli.pip install --user aws-sam-cli -
Adjust your
PATHto include the Python scripts that are installed under the user's home directory.-
Linux: Adjusting Your Path on Linux
-
Windows: Adjusting Your Path on Windows
-
macOS: Adjusting Your Path on macOS
-
-
Verify that
samis installed.Restart or open a new terminal, and verify that the installation worked.
# Restart current shell $ sam --version
