Installing the AWS SAM CLI on macOS
The following steps help you to install and configure the required prerequisites for using the AWS SAM CLI on your macOS host:
-
Create an AWS account.
-
Configure IAM permissions.
-
Install Docker. Note: Docker is only a prerequisite for testing your application locally.
-
Install Homebrew.
-
Install the AWS SAM CLI.
Step 1: Create an AWS account
If you don't already have an AWS account, see aws.amazon.com
Step 2: Create an IAM user with administrator permissions
If you don't already have an IAM user with administrator permissions, see Creating Your First IAM Admin User and Group in the IAM User Guide.
In addition, you must set up AWS credentials to enable the AWS SAM CLI to make AWS service calls. For example, the AWS SAM CLI makes calls to Amazon S3 and AWS CloudFormation. For more information about setting up AWS credentials, see Setting up AWS credentials.
If you want to use the AWS SAM CLI with an IAM user that does not have administrator permissions, you can instead attach a set of AWS managed policies to the IAM user. The following set of AWS managed policies are sufficient to deploy the Hello World sample application:
-
AWSCloudFormationFullAccess
-
IAMFullAccess
-
AWSLambdaFullAccess
-
AmazonAPIGatewayAdministrator
For more information about attaching policies to an IAM user, see Changing permissions for an IAM user.
Step 3: Install Docker
Docker is only a prerequisite for testing your application locally and to build
deployment packages using the --use-container flag. You may skip this
section or install Docker at a later time if you do not plan to use these features
initially.
Docker is an application that runs containers on your macOS machines. AWS SAM provides a local environment that's similar to AWS Lambda to use as a Docker container. You can use this container to build, test, and debug your serverless applications.
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.
-
Install Docker
The AWS SAM CLI supports Docker running on macOS Sierra 10.12 or above. To install Docker see Install Docker Desktop for Mac
. -
Configure your shared drives
The AWS SAM CLI requires that the project directory, or any parent directory, is listed in a shared drive. To share drives on macOS, see File sharing
. -
Verify the installation
After Docker is installed, verify that it's working. Also confirm that you can run Docker commands from the command line (for example,
docker ps). You don't need to install, fetch, or pull any containers––the AWS SAM CLI does this automatically as required.
If you run into issues installing Docker, see the Logs and
troubleshooting
Step 4: Install Homebrew
The recommended approach for installing the AWS SAM CLI on macOS is to use the
Homebrew package manager. For more information about
Homebrew, see Homebrew Documentation
To install Homebrew, you must first install Git. For more information
about Git, see Git Documentation
Once you have successfully installed Git, run the following to install Homebrew, making sure to follow the prompts:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Verify that Homebrew is installed:
brew --version
You should see output like the following on successful installation of Homebrew:
Homebrew 2.4.11
Homebrew/homebrew-core (git revision 54246b; last commit 2020-08-13)
Homebrew/homebrew-cask (git revision 4fd7ce; last commit 2020-08-14)
Step 5: Install the AWS SAM CLI
Follow these steps to install the AWS SAM CLI using Homebrew:
brew tap aws/tap brew install aws-sam-cli
Verify the installation:
sam --version
You should see output like the following after successful installation of the AWS SAM CLI:
SAM CLI, version 1.3.0
You're now ready to start development.
Upgrading
To upgrade the AWS SAM CLI, you still use Homebrew, but replace
install with upgrade as follows:
brew upgrade aws-sam-cli
Next steps
You're now ready to begin building your own serverless applications using AWS SAM! If you want to start with sample serverless applications, choose one of the following links:
-
Tutorial: Deploying a Hello World application – Step-by-step instructions to download, build, and deploy a simple serverless application.
-
AWS SAM example applications in GitHub
– Sample applications in the AWS SAM GitHub repository that you can further experiment with.

