[Update] The aws update command has been added to the AWS CLI
This page has been translated by machine translation. View original
This is Shibata.
While checking the AWS CLI update history as usual, I noticed that a new aws update command was added in Ver.2.36.0, which was released a little while ago.
- feature:
update: Adds theupdatecommand, which downloads and installs the latest AWS CLI version.
- From CHANGELOG
This article shares the results of my investigation into this command.
What is this command?
As the name suggests, this command updates the AWS CLI to the latest version.
There are no detailed parameters, and you simply type aws update on any platform to update to the latest version of AWS CLI.
# Update to the latest version of AWS CLI
aws update
Investigating the implementation
After checking the implementation from the source on GitHub, the mechanism is simple: it downloads and executes an update script from the internet.
There are update scripts for Windows environments (install.ps1) and for non-Windows environments (install.sh), and in the current AWS CLI v2, they are respectively located at:
Both scripts perform equivalent processing:
- Check the local environment's platform, installation method, and installed version
- Download the latest version's installer according to the installation method and execute the installation
The latest version information is retrieved from:
Trying it out
This time, I verified the behavior using the AWS CLI installed on my development PC (Windows 11).
I set the AWS CLI version to Ver.2.36.0 in advance.
Also, since my environment uses a system-wide installation, I'm running the PowerShell console as "Run as administrator."

I first tried it from PowerShell 7 (7.6.4) which I use regularly, but unfortunately it didn't work as expected there.
When I ran the aws update command, the installation script was executed in a separate window, but it seemed like the latest MSI installer was not being downloaded to the intended directory, and the installation process terminated immediately.


The aws update command appeared to complete successfully on the surface, but the version had not actually been updated.

Instead, when I ran the aws update command from Windows PowerShell, the installation script was executed in a separate window, and the MSI installer installation process ran as intended.

When the separate window closed, the installation was complete, and it was updated to Ver.2.36.8, the latest version as of today.

Looks good.
I plan to provide feedback later about the unexpected behavior in PowerShell 7.
Note 1: Alternative command for PowerShell 7
What's happening in the Windows environment is simply running the latest MSI installer, so at minimum, the following command can substitute for the aws update process.
# Alternative for system installation
msiexec /i https://awscli.amazonaws.com/AWSCLIV2.msi /qn /norestart
In the case of an MSI installer, the branching between new installation and update processing is handled internally, so the new installation command can be used as-is.
Note 2: A Ping to localhost (127.0.0.1) is executed on Windows environments
In Windows environments, there is a restriction that prevents updating an executable file while a process is running.
AWS CLI works around this by pinging localhost (127.0.0.1) three times to buy some time.
# Windows acquires a lock when running an exe process, preventing
# an update in-place. The workaround is to launch a detached CMD
# subprocess and exit the parent early. Use ping to wait before
# running the installation to ensure the parent isn't holding onto
# the lock.
f.write('@echo off\n')
f.write('set AWS_CLI_DISTRIBUTION_SOURCE_OVERRIDE=update-exe\n')
if self._no_color:
f.write('set NO_COLOR=1\n')
f.write('ping -n 3 127.0.0.1 >nul 2>&1\n')
f.write(f'"{ps_exe}" {ps_args}\n')
Personally, my reaction is "Why Ping? Wouldn't Sleep work?", but since this is the current implementation, there's no need to panic if a Ping is suddenly sent.
Note 3: Linux environment (WSL2)
While I'm at it, let me also try it in the Ubuntu environment on WSL2.
Just like with Windows, I first set it to Ver.2.36.0.

Since this environment also uses a system installation, I run the aws update command with sudo.
Here, the installation script ran smoothly and was updated to Ver.2.36.8.


Nice and easy.
Closing
That's all.
I did find a bug in the Windows environment, but I think it's a very useful command.
Please feel free to make use of it.
