Installing or updating the latest version of the AWS CLI – AWS Command Line Interface
-
To specify which folder the AWS CLI is installed to, you
must create an XML file with any file name. This file is
an XML-formatted file that looks like the following
example. Leave all values as shown, except you must
replace the path
/Users/myusername
in line
9 with the path to the folder you want the AWS CLI
installed to. The folder must
already exist, or the command fails. The
following XML example, named
choices.xml
, specifies
the installer to install the AWS CLI in the folder
/Users/myusername
, where it
creates a folder named
aws-cli
.<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>choiceAttribute</key> <string>customLocation</string> <key>attributeSetting</key> <string>
/Users/myusername
</string> <key>choiceIdentifier</key> <string>default</string> </dict> </array> </plist> -
Download the
pkg
installer using
thecurl
command. The-o
option specifies the file name that the downloaded
package is written to. In this example, the file is
written toAWSCLIV2.pkg
in the current folder.$
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
-
Run the standard macOS
installer
program
with the following options:-
Specify the name of the package to install by
using the-pkg
parameter. -
Specify installing to a current user only by
setting the-target
parameter to
CurrentUserHomeDirectory
. -
Specify the path (relative to the current
folder) and name of the XML file that you created
in the-applyChoiceChangesXML
parameter.
The following example installs the AWS CLI in the folder
/Users/myusername/aws-cli
.$
installer -pkg AWSCLIV2.pkg \ -target CurrentUserHomeDirectory \ -applyChoiceChangesXML
choices.xml
-
-
Because standard user permissions typically don’t
allow writing to folders in your$PATH
, the
installer in this mode doesn’t try to add the symlinks
to theaws
andaws_completer
programs. For the AWS CLI to run correctly, you must
manually create the symlinks after the installer
finishes. If your$PATH
includes a folder
you can write to and you specify the folder as the
target’s path, you can run the following command without
sudo
. If you don’t have a writable
folder in your$PATH
, you must use
sudo
for permissions to write to the
specified target folder. The default location for a
symlink is/usr/local/bin/
. Replace
folder/installed
with the path to your
AWS CLI installation.$
sudo ln -s /folder/installed
/aws-cli/aws /usr/local/bin
/aws$
sudo ln -s /folder/installed
/aws-cli/aws_completer /usr/local/bin
/aws_completerAfter installation is complete, debug logs are written
to/var/log/install.log
. -
To verify that the shell can find and run the
aws
command in your$PATH
,
use the following commands.$
which aws
/usr/local/bin/aws
$
aws --version
aws-cli/2.10.0 Python/3.11.2 Darwin/18.7.0 botocore/2.4.5
If the
aws
command cannot be found, you
might need to restart your terminal or follow the
troubleshooting in Troubleshooting AWS CLI errors.