Skip to content

Commit b787986

Browse files
committed
Use AWS CLI v2 for Windows, update install method
1 parent 06a2cb1 commit b787986

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

packer/linux/scripts/install-utils.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
AWS_CLI_LINUX_VERSION=2.28.15
6+
57
case $(uname -m) in
68
x86_64) ARCH=amd64 ;;
79
aarch64) ARCH=arm64 ;;
@@ -15,7 +17,6 @@ echo Installing utils...
1517
sudo dnf install -yq \
1618
amazon-ssm-agent \
1719
aws-cfn-bootstrap \
18-
awscli-2 \
1920
ec2-instance-connect \
2021
git \
2122
jq \
@@ -42,6 +43,24 @@ sudo dnf -yq groupinstall "Development Tools"
4243
sudo systemctl enable --now amazon-ssm-agent
4344
sudo systemctl enable --now rsyslog
4445

46+
echo "Installing AWS CLI v2 ${AWS_CLI_LINUX_VERSION}..."
47+
pushd "$(mktemp -d)"
48+
case $(uname -m) in
49+
x86_64)
50+
curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_LINUX_VERSION}.zip" -o "awscliv2.zip"
51+
;;
52+
aarch64)
53+
curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-aarch64-${AWS_CLI_LINUX_VERSION}.zip" -o "awscliv2.zip"
54+
;;
55+
*)
56+
echo "Unsupported architecture for AWS CLI v2"
57+
exit 1
58+
;;
59+
esac
60+
unzip -qq awscliv2.zip
61+
sudo ./aws/install
62+
popd
63+
4564
GIT_LFS_VERSION=3.4.0
4665
echo "Installing git lfs ${GIT_LFS_VERSION}..."
4766
pushd "$(mktemp -d)"

packer/windows/scripts/install-utils.ps1

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Stop script execution when a non-terminating error occurs
22
$ErrorActionPreference = "Stop"
33

4-
# pinned because awscli v2 drops 'aws ecr get-login'
5-
# https://github.com/buildkite-plugins/ecr-buildkite-plugin/issues/37
6-
$AWS_CLI_VERSION = 1.18.11
7-
$GIT_VERSION = 2.39.1
4+
$AWS_CLI_WINDOWS_VERSION = "2.28.15"
5+
$GIT_VERSION = "2.39.1"
86

97
Write-Output "Installing chocolatey package manager"
108
Set-ExecutionPolicy Bypass -Scope Process -Force
@@ -14,8 +12,13 @@ Write-Output "Installing jq"
1412
choco install -y jq
1513
If ($lastexitcode -ne 0) { Exit $lastexitcode }
1614

17-
Write-Output "Installing awscli"
18-
choco install -y awscli --version=$AWS_CLI_VERSION
15+
Write-Output "Installing AWS CLI v2 $AWS_CLI_WINDOWS_VERSION..."
16+
$tempDir = New-TemporaryFile | %{ Remove-Item $_; New-Item -ItemType Directory -Path $_ }
17+
$msiPath = Join-Path $tempDir "AWSCLIV2.msi"
18+
$msiUrl = "https://awscli.amazonaws.com/AWSCLIV2-$AWS_CLI_WINDOWS_VERSION.msi"
19+
Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath
20+
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$msiPath`" /quiet" -Wait
21+
Remove-Item -Recurse -Force $tempDir
1922
If ($lastexitcode -ne 0) { Exit $lastexitcode }
2023

2124
Write-Output "Installing Git for Windows"
@@ -42,7 +45,7 @@ Update-SessionEnvironment
4245
Write-Output "Prepending 'gitinstall\mingw64\bin' and 'gitinstall\usr\bin' to the system's PATH"
4346
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
4447
$newpath = "C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;$oldpath"
45-
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
48+
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newpath
4649

4750
# Set autocrlf to false so we don't end up with mismatched line endings
4851
git config --system core.autocrlf false

0 commit comments

Comments
 (0)