Skip to content

Commit cc8a7fc

Browse files
authored
Merge pull request #1558 from buildkite/SUP-4563-windows-aws-cli-v2
AWS CLI v2 in Windows AMI
2 parents 472fa92 + 3207499 commit cc8a7fc

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

.buildkite/pipeline.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ steps:
106106
- id: "test-windows-amd64"
107107
name: ":cloudformation: :windows: AMD64 Test"
108108
command:
109+
- aws --version
110+
- jq --version
109111
- git --version
110112
- docker info
111113
- docker run --rm mcr.microsoft.com/windows/nanoserver:ltsc2022 cmd.exe /c echo hello
@@ -178,6 +180,8 @@ steps:
178180
- id: "test-linux-amd64"
179181
name: ":cloudformation: :linux: AMD64 Test"
180182
command:
183+
- aws --version
184+
- jq --version
181185
- git --version
182186
- sudo goss validate --format documentation
183187
timeout_in_minutes: 5
@@ -249,6 +253,8 @@ steps:
249253
- id: "test-linux-arm64"
250254
name: ":cloudformation: :linux: ARM64 Test"
251255
command:
256+
- aws --version
257+
- jq --version
252258
- git --version
253259
- sudo goss validate --format documentation
254260
retry: { automatic: { limit: 3 } }

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)