AWS

How to install awslocal ( LocalStack AWS CLI) on Ubuntu running on WSL2 (Windows Subsystem for Linux)?

· 4 min read
How to install awslocal - LocalStack AWS CLI on Ubuntu running on WSL2 (Windows Subsystem for Linux)?

If you are already enjoying LocalStack ("A fully functional local cloud stack") for building awesome AWS cloud and serverless applications locally, then awslocal will add extra Saccharin to sweeten your development experience for sure.

What is awslocal?

awslocal is a wrapper around the AWS CLI to be used with LocalStack to shorten the command (in other words, less typing). It also supports the command completion feature of AWS CLI.

Prerequisites:

You need AWS Command Line Interface (AWS CLI) and obviously Localstack to proceed.

To confirm AWS CLI installation run aws --version.

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

If not installed, please refer following article.

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). Video:

To check Localstack, run localstack --version.

abhijit@AwsJunkie:~$ localstack --version
1.4.0

If you don't have LocalStack installed, then please follow my below post.

How to install LocalStack (AWS cloud service emulator) on WSL2 to develop cloud and serverless apps offline?
LocalStack is an AWS cloud service emulator that can be used as a local cloud sandbox for development, prototyping and testing. It is “A fully functional local cloud stack”. You can efficiently build AWS cloud and serverless applications locally without connecting to AWS cloud. Therefore, it will he…

In this post, I'll use Ubuntu 22.04 distro (jammy) running on WSL2 (Windows Subsystem for Linux) to install awslocal

abhijit@AwsJunkie:~$ uname -a
Linux AwsJunkie 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
abhijit@AwsJunkie:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:        22.04
Codename:       jammy

Installation of awslocal:

It's just one command pip install awscli-local. That's simple.

abhijit@AwsJunkie:~$ pip install awscli-local
Defaulting to user installation because normal site-packages is not writeable
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/awscli-local/
Collecting awscli-local
  Downloading awscli-local-0.20.tar.gz (6.9 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: localstack-client in ./.local/lib/python3.10/site-packages (from awscli-local) (2.0)
Requirement already satisfied: boto3 in ./.local/lib/python3.10/site-packages (from localstack-client->awscli-local) (1.26.100)
Requirement already satisfied: s3transfer<0.7.0,>=0.6.0 in ./.local/lib/python3.10/site-packages (from boto3->localstack-client->awscli-local) (0.6.0)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in ./.local/lib/python3.10/site-packages (from boto3->localstack-client->awscli-local) (1.0.1)
Requirement already satisfied: botocore<1.30.0,>=1.29.100 in ./.local/lib/python3.10/site-packages (from boto3->localstack-client->awscli-local) (1.29.100)
Requirement already satisfied: urllib3<1.27,>=1.25.4 in ./.local/lib/python3.10/site-packages (from botocore<1.30.0,>=1.29.100->boto3->localstack-client->awscli-local) (1.26.15)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./.local/lib/python3.10/site-packages (from botocore<1.30.0,>=1.29.100->boto3->localstack-client->awscli-local) (2.8.2)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.30.0,>=1.29.100->boto3->localstack-client->awscli-local) (1.16.0)
Building wheels for collected packages: awscli-local
  Building wheel for awscli-local (setup.py) ... done
  Created wheel for awscli-local: filename=awscli_local-0.20-py3-none-any.whl size=7018 sha256=8b9a13df7a659ba2dfb2b2d5791314c57ed6c2cc3eac77d42e8fbc08992b9b06
  Stored in directory: /home/abhijit/.cache/pip/wheels/8f/05/c3/604ac5be71b9730e9760e24ac8d80257b14251581e08997211
Successfully built awscli-local
Installing collected packages: awscli-local
Successfully installed awscli-local-0.20

To verify, run awslocal -h.

abhijit@AwsJunkie:~$ awslocal -h
Thin wrapper around the "aws" command line interface (CLI) for use
with LocalStack.

The "awslocal" CLI allows you to easily interact with your local services
without having to specify "--endpoint-url=http://..." for every single command.

Example:
Instead of the following command ...
aws --endpoint-url=https://localhost:4568 --no-verify-ssl kinesis list-streams
... you can simply use this:
awslocal kinesis list-streams

Options:
  Run "aws help" for more details on the aws CLI subcommands.
"The "awslocal" CLI allows you to easily interact with your local services without having to specify "--endpoint-url=http://..." for every single command."

Enjoy less typing!

References