Building and installing the Amazon CLI from source
This topic describes how to install or update from source to the latest release of the Amazon Command Line Interface (Amazon CLI) on supported operating systems.
For information on the latest releases of Amazon CLI, see the Amazon CLI version 2 Changelog
Important
Amazon CLI versions 1 and 2 use the same aws command name. If you previously
      installed Amazon CLI version 1, see Migration guide for the Amazon CLI version 2.
Topics
Why build from source?
The Amazon CLI is available as pre-built installers for most platforms and environments as well as a Docker image.
Generally, these installers provide coverage for most use-cases. The instructions for installing from source are to help with the use-cases our installers do not cover. Some of these use-cases include the following:
- 
        The pre-built installers do not support your environment. For example, ARM 32-bit is not supported by the pre-built installers. 
- 
        The pre-built installers have dependencies your environment lacks. For example, Alpine Linux uses musl, but the current installers require glibccausing the pre-built installers to not immediately work.
- 
        The pre-built installers require resources your environment restricts access to. For example, security hardened systems might not give permissions to shared memory. This is needed for the frozen awsinstaller.
- 
        The pre-built installers are often blockers for maintainers in package managers, as full control over the building process for code and packages is preferred. Building from source enables distribution maintainers a more streamlined process to keep the Amazon CLI updated. Enabling maintainers provides customers more up-to-date versions of the Amazon CLI when installing from a 3rd party package manager such as brew,yum, andapt.
- 
        Customers that patch Amazon CLI functionality require building and installing the Amazon CLI from source. This is especially important for community members that want to test changes they've made to the source prior to contributing the change to the Amazon CLI GitHub repository. 
Quicksteps
Note
All code examples are assumed to run from the root of the source directory.
To build and install the Amazon CLI from source, follow the steps in this section. The Amazon CLI
      leverages GNU
        Autotools
- 
        Setup all requirements for your environment. This includes being able to run GNU Autotools generated files and Python 3.8 or later is installed. 
- 
        In your terminal, navigate to the top level of the Amazon CLI source folder and run the ./configurecommand. This command checks the system for all required dependencies and generates aMakefilefor building and installing the Amazon CLI based on detected and specified configurations.For details, available configuration options, and default setting information, see the Step 2: Configuring the Amazon CLI source installation section. 
- 
        Run the makecommand. This command builds the Amazon CLI according to your configuration settings.The following makecommand example builds with default options using your existing./configuresettings.For details and available build options, see the Step 3: Building the Amazon CLI section. 
- 
        Run the make installcommand. This command installs your built Amazon CLI to the configured location on your system.The following make installcommand example installs your built Amazon CLI and creates symlinks in your configured locations using default command settings.For details and available install options, see the Step 4: Installing the Amazon CLI section. 
- 
        Confirm the Amazon CLI successfully installed using the following command: $aws --versionaws-cli/2.27.41 Python/3.11.6 Windows/10 exe/AMD64 prompt/offFor troubleshooting steps for install errors see the Troubleshooting Amazon CLI install and uninstall errors section. 
Step 1: Setup all requirements
To build the Amazon CLI from source you need the following completed beforehand:
Note
All code examples are assumed to run from the root of the source directory.
- Download the Amazon CLI source by either forking the Amazon CLI GitHub repository or downloading the source tarball. The instructions is one of the following: - 
            Fork and clone the Amazon CLI repository from GitHub. For more information, see Fork a repo in the GitHub Docs. 
- 
            Download the latest source tarball at https://awscli.amazonaws.com/awscli.tar.gz extract the contents using the following commands: $curl "https://awscli.amazonaws.com/awscli.tar.gz" -o "awscli.tar.gz"$tar -xzf awscli.tar.gzNoteTo download a specific version, use the following link format: https://awscli.amazonaws.com/awscli- versionnumber.tar.gzFor example, for version 2.10.0 the link is the following: https://awscli.amazonaws.com/awscli- 2.10.0.tar.gzSource versions are available starting with version 2.10.0 of the Amazon CLI. (Optional) Verifying the integrity of your downloaded zip file by completing the following steps: - 
                You can use the following steps to verify the signatures by using the GnuPGtool.The Amazon CLI installer package .zipfiles are cryptographically signed using PGP signatures. If there is any damage or alteration of the files, this verification fails and you should not proceed with installation.
- 
                Download and install the gpgcommand using your package manager. For more information aboutGnuPG, see the GnuPG website. 
- 
                To create the public key file, create a text file and paste in the following text. -----BEGIN PGP PUBLIC KEY BLOCK----- mQINBF2Cr7UBEADJZHcgusOJl7ENSyumXh85z0TRV0xJorM2B/JL0kHOyigQluUG ZMLhENaG0bYatdrKP+3H91lvK050pXwnO/R7fB/FSTouki4ciIx5OuLlnJZIxSzx PqGl0mkxImLNbGWoi6Lto0LYxqHN2iQtzlwTVmq9733zd3XfcXrZ3+LblHAgEt5G TfNxEKJ8soPLyWmwDH6HWCnjZ/aIQRBTIQ05uVeEoYxSh6wOai7ss/KveoSNBbYz gb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ay/mU+6w hhmdF18vpyK0vfkvvGresWtSXbag7Hkt3XjaEw76BzxQH21EBDqU8WJVjHgU6ru+ DJTs+SxgJbaT3hb/vyjlw0lK+hFfhWKRwgOXH8vqducF95NRSUxtS4fpqxWVaw3Q V2OWSjbne99A5EPEySzryFTKbMGwaTlAwMCwYevt4YT6eb7NmFhTx0Fis4TalUs+ j+c7Kg92pDx2uQ== =OBAt -----END PGP PUBLIC KEY BLOCK-----For reference, the following are the details of the public key. Key ID: A6310ACC4672 Type: RSA Size: 4096/4096 Created: 2019-09-18 Expires: 2026-07-07 User ID: AWS CLI Team <aws-cli@amazon.com> Key fingerprint: FB5D B77F D5C1 18B8 0511 ADA8 A631 0ACC 4672 475C
- 
                Import the Amazon CLI public key with the following command, substituting public-key-file-namewith the file name of the public key you created.$gpg --importpublic-key-file-namegpg: /home/username/.gnupg/trustdb.gpg: trustdb created gpg: key A6310ACC4672475C: public key "AWS CLI Team <aws-cli@amazon.com>" imported gpg: Total number processed: 1 gpg: imported: 1
- 
                Download the Amazon CLI signature file for the package you downloaded at https://awscli.amazonaws.com/awscli.tar.gz.sig . It has the same path and name as the tarball file it corresponds to, but has the extension .sig. Save it in the same path as the tarball file. Or use the following command block:$curl awscliv2.sig https://awscli.amazonaws.com/ -o awscli.tar.gz.sig
- 
                Verify the signature, passing both the downloaded .sigand.zipfile names as parameters to thegpgcommand.$gpg --verify awscliv2.sig awscli.tar.gzThe output should look similar to the following. gpg: Signature made Mon Nov 4 19:00:01 2019 PST gpg: using RSA key FB5D B77F D5C1 18B8 0511 ADA8 A631 0ACC 4672 475C gpg: Good signature from "AWS CLI Team <aws-cli@amazon.com>" [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: FB5D B77F D5C1 18B8 0511 ADA8 A631 0ACC 4672 475CImportantThe warning in the output is expected and doesn't indicate a problem. It occurs because there isn't a chain of trust between your personal PGP key (if you have one) and the Amazon CLI PGP key. For more information, see Web of trust . 
 
- 
                
 
- 
            
- 
        You have an environment that can run GNU Autotools generated files such as configureandMakefile. These files are widely portable across POSIX platforms.
- 
        A Python 3.8 or later interpreter is installed. The minimum Python version required follows the same timelines as the official Python support policy for Amazon SDKs and Tools . An interpreter is only supported 6 months after its end-of-support date. 
- 
        
        
        (Optional) Install all build and runtime Python library dependencies of the Amazon CLI. The ./configurecommand informs you if you are missing any dependencies and how to install them.You can automatically install and use these dependencies through configuration, see Downloading dependencies for more information. 
Step 2: Configuring the Amazon CLI source installation
Configuration for building and installing the Amazon CLI is specified using the
        configure script. For the documentation of all configuration options, run the
        configure script with the --help option:
The most important options are the following:
Install location
The source installation of the Amazon CLI uses two configurable directories to install the Amazon CLI:
- 
          libdir- Parent directory where the Amazon CLI will be installed. The path to the Amazon CLI installation is<libdir-value>/aws-clilibdirvalue for Linux and macOS is/usr/local/libmaking the default installation directory/usr/local/lib/aws-cli
- 
          bindir- Directory where the Amazon CLI executables are installed. The default location is/usr/local/bin.
The following configure options control the directories used:
- 
          --prefix- Sets the directory prefix to use for the installation. The default value for Linux and macOS is/usr/local.
- 
          --libdir- Sets thelibdirto use for installing the Amazon CLI. The default value is<prefix-value>/lib. If both--libdirand--prefixare not specified, the default for Linux and macOS is/usr/local/lib/.
- 
          --bindir- Sets thebindirto use for installing the Amazon CLIawsandaws_completerexecutables. The default value is<prefix-value>/bin. If bothbindirand--prefixare not specified, the default for Linux and macOS is/usr/local/bin/.
Python interpreter
Note
It is highly recommended to specify the Python interpreter when installing for Windows.
The ./configure script automatically selects an installed
        Python 3.8 or later interpreter to use in building and running the Amazon CLI using the AM_PATH_PYTHON
The Python interpreter to use can be explicitly set using the PYTHON
        environment variable when running the configure script:
Downloading dependencies
By default, it is required that all build and runtime dependencies of the Amazon CLI are
        already installed on the system. This includes any Python library dependencies. All
        dependencies are checked when the configure script is run, and if the system is
        missing any Python dependencies, the configure script errors out. 
The following code example errors out when your system is missing dependencies:
To automatically install the required Python dependencies, use the
          --with-download-deps option. When using this flag, the build process does the
        following:
- 
          Skips the Python library dependencies check. 
- 
          Configures the settings to download all required Python dependencies and use only the downloaded dependencies to build the Amazon CLI during the makebuild.
The following configure command example uses the --with-download-deps
        option to download and use the Python dependencies:
Install type
The source install process supports the following installation types:
- 
          system-sandbox- (Default) Creates an isolated Python virtual environment, installs the Amazon CLI into the virtual environment, and symlinks to theawsandaws_completerexecutable in the virtual environment. This install of the Amazon CLI depends directly on the selected Python interpreter for its runtime.This is a lightweight install mechanism to get the Amazon CLI installed on a system and follows best Python practices by sandboxing the installation in a virtual environment. This installation is intended for customers that want to install the Amazon CLI from source in the most frictionless way possible with the installation coupled to your installation of Python. 
- 
          portable-exe- Freezes the Amazon CLI into a standalone executable that can be distributed to environments of similar architectures. This is the same process used to generate the official pre-built executables of the Amazon CLI. Theportable-exefreezes in a copy of the Python interpreter chosen in theconfigurestep to use for the runtime of the Amazon CLI. This allows it to be moved to other machines that may not have a Python interpreter.This type of builds is useful because you can ensure your Amazon CLI installation isn't coupled to the environment's installed Python version and you can distribute a build to other system that may not already have Python installed. This enables you to control the dependencies and security on the Amazon CLI executables you use. 
To configure the installation type, use the --with-install-type option and
        specify a value of portable-exe or system-sandbox. 
The following ./configure command example specifies a value of
          portable-exe:
Step 3: Building the Amazon CLI
Use the make command to build the Amazon CLI using your configuration
      settings:
Note
When using the make command, the following steps are completed behind
            the scenes:
- 
            A virtual environment is created in the build directory using the Python venvmodule. The virtual environment is bootstraped with a version of pip that is vendored in the Python standard library . 
- 
            Copies Python library dependencies. Depending on if the --with-download-depsflag is specified in theconfigurecommand, this step does one of the following:- 
                The --with-download-depsis specified. Python dependencies are pip installed. This includeswheel,setuptools, and all Amazon CLI runtime dependencies. If you are building theportable-exe,pyinstalleris installed. These requirements are all specified in lock files generated frompip-compile. 
- 
                The --with-download-depsis not specified. Python libraries from the Python interpreter's site package plus any scripts (e.g.pyinstaller) are copied into the virtual environment being used for the build.
 
- 
                
- 
            Runs pip installdirectly on the Amazon CLI codebase to do an offline, in-tree build and install of the Amazon CLI into the build virtual environment. This install uses the pip flags --no-build-isolation, --use-feature=in-tree-build , --no-cache-dir , and --no-index. 
- 
            (Optional) If the --install-typeis set toportable-exein theconfigurecommand, builds a standalone executable usingpyinstaller. 
Step 4: Installing the Amazon CLI
The make install command installs your built Amazon CLI to the configured location
      on the system. 
The make install rule supports the DESTDIR
Note
When running make install, the following steps are completed behind
            the scenes
- 
            Moves one of the following to the configured install directory: - 
                If the install type is system-sandbox, moves your built virtual environment.
- 
                If the install type is a portable-exe, moves your built standalone executable.
 
- 
                
- 
            Creates symlinks for both the awsandaws_completerexecutables in your configured bin directory.
Step 5: Verifying the Amazon CLI installation
Confirm the Amazon CLI successfully installed by using the following command:
$aws --versionaws-cli/2.27.41 Python/3.11.6 Windows/10 exe/AMD64 prompt/off
If the aws command is not recognized, you may need to restart your terminal
      for new symlinks to update. If you come across additional issues after installing or
      uninstalling the Amazon CLI, see Troubleshooting errors for the Amazon CLI for common
      troubleshooting steps
Workflow examples
This section provides some basic workflow examples for installing from source.
Basic Linux and macOS install
The following example is a basic installation workflow where the Amazon CLI is installed in
        the default location of /usr/local/lib/aws-cli. 
$cdpath/to/cli/respository/$./configure$make$make install
Automated Windows install
Note
You must run PowerShell as an Administrator to use this workflow.
MSYS2 can be used in an automated fashion in a CI setting, see Using MSYS2 in CI
Alpine Linux container
Below is an example Dockerfile that can be used to get a working installation of the
        Amazon CLI in an Alpine Linux container as an alternative to pre-built binaries for
          AlpineAWSCLI_VERSION
        with you desired Amazon CLI version number:
FROM python:3.8-alpine AS builder ENV AWSCLI_VERSION=2.10.1 RUN apk add --no-cache \ curl \ make \ cmake \ gcc \ g++ \ libc-dev \ libffi-dev \ openssl-dev \ && curl https://awscli.amazonaws.com/awscli-${AWSCLI_VERSION}.tar.gz | tar -xz \ && cd awscli-${AWSCLI_VERSION} \ && ./configure --prefix=/opt/aws-cli/ --with-download-deps \ && make \ && make install FROM python:3.8-alpine RUN apk --no-cache add groff COPY --from=builder /opt/aws-cli/ /opt/aws-cli/ ENTRYPOINT ["/opt/aws-cli/bin/aws"]
This image is built and the Amazon CLI invoked from a container similar to the one that is built on Amazon Linux 2:
$docker build --tag awscli-alpine .$docker run --rm -it awscli-alpine --versionaws-cli/2.2.1 Python/3.8.11 Linux/5.10.25-linuxkit source-sandbox/x86_64.alpine.3 prompt/off
The final size of this image is smaller than the size of the official Amazon CLI Docker image. For information on the official Docker image, see Running the official Amazon ECR Public or Docker images for the Amazon CLI.
Troubleshooting Amazon CLI install and uninstall errors
For troubleshooting steps for install errors, see Troubleshooting errors for the Amazon CLI for common troubleshooting steps. For the most relevant troubleshooting steps, see Command not found errors, The "aws --version" command returns a different version than you installed, and The "aws --version" command returns a version after uninstalling the Amazon CLI.
For any issues not covered in the troubleshooting guides, search the issues with the
        source-distribution label in the Amazon CLI Repository
Next steps
After installing the Amazon CLI, you should perform a Setting up the Amazon CLI.