WSL

Install AWS Serverless Application Model Command Line Interface (AWS SAM CLI) on Windows Subsystem for Linux (WSL 2)

· 2 min read
Install AWS Serverless Application Model Command Line Interface (AWS SAM CLI) on Windows Subsystem for Linux (WSL 2)

AWS SAM command line interface (AWS SAM CLI) tool is must have for building AWS serverless applications. In this post, we'll see how to install latest version of AWS SAM CLI on Windows Subsystem for Linux (WSL 2).

Video:

Prerequisites:

AWS Command Line Interface (AWS CLI 2) is recommended for SAM CLI.  If you are not sure, then run following command to confirm AWS CLI 2 is installed or not.

abhijit@AwsJunkie:~$ aws --version
aws-cli/2.10.2 Python/3.9.11 Linux/5.10.102.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 prompt/off

If AWS CLI is not installed, then follow the below article and come back once done.

Install AWS Command Line Interface (AWS CLI) on Windows Subsystem for Linux (WSL 2)
AWS Command Line Interface (AWS CLI) is used to interact with different AWS (Amazon Web Services) product and services in command-line shell. AWS CLI version 2 is the latest one. In this article, we’ll see how to download and install AWS CLI on Windows Subsystem for Linux (WSL 2). Update

Installation:

Download the AWS SAM CLI installer.

abhijit@AwsJunkie:~$ curl -L "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip" -o "aws-sam-cli-linux-x86_64.zip"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 66.0M  100 66.0M    0     0  43.2M      0  0:00:01  0:00:01 --:--:-- 60.9M

abhijit@AwsJunkie:~$ ls -l
total 67680
-rw-r--r-- 1 abhijit abhijit 69303381 Feb 23 21:43 aws-sam-cli-linux-x86_64.zip

Unzip the downloaded installer package (e.g. aws-sam-cli-linux-x86_64.zip) to sam-installation directory.

abhijit@AwsJunkie:~$ unzip -q aws-sam-cli-linux-x86_64.zip -d sam-installation
abhijit@AwsJunkie:~$ ls -l
total 67684
-rw-r--r-- 1 abhijit abhijit 69303381 Feb 23 21:52 aws-sam-cli-linux-x86_64.zip
drwxr-xr-x 4 abhijit abhijit     4096 Feb 23 21:53 sam-installation

Run the install program sudo ./sam-installation/install

abhijit@AwsJunkie:~$ sudo ./sam-installation/install
You can now run: /usr/local/bin/sam --version

Check AWS SAM CLI version to confirm the installation.

abhijit@AwsJunkie:~$ sam --version
SAM CLI, version 1.74.0

Happy Learning!

References