Can't install windows nvidia driver from AWS administered S3 Bucket: ec2-windows-nvidia-drivers

1

Hi, We are trying to install the latest windows NVIDIA windows driver for our custom AMI. We are doing this via packer which is running a powershell script. This is using the guidelines recommended here in option 4. When the script runs on the ec2 instance, we're getting a 404. But when we check that url on our own machines, it's fine. The bucket in question is supposed to be publicly accessible, and I can download it from plenty of other machines.

Here's the log from packer:

Downloading https://ec2-windows-nvidia-drivers.s3.amazonaws.com/latest/537.13_grid_win10_win11_server2019_server2022_dch_64bit_international_aws_swl.exe latest/537.70_grid_win10_win11_server2019_server2022_dch_64bit_international_aws_swl.exe to C:\Users\Administrator\Downloads\NVIDIA\installer.exe

 Directory: C:\Users\Administrator\Downloads


 Mode                LastWriteTime         Length Name
----                -------------         ------ ----
 d-----        11/1/2023  11:47 AM                NVIDIA
Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."

This is the code:

$ErrorActionPreference = "Stop"
$ProgressPreference = 'SilentlyContinue'

Write-Output "Beginning Nvidia driver installation"
$wc = New-Object net.webclient

$Bucket = "ec2-windows-nvidia-drivers"
$KeyPrefix = "latest"
$LocalDirectory = "$home\Downloads\NVIDIA"
$LocalInstallerPath = "$LocalDirectory\installer.exe"

$Objects = aws s3api list-objects --bucket $Bucket --prefix $KeyPrefix --no-sign --output json | ConvertFrom-Json
$InstallerExeKey = ($Objects.Contents | Where-Object { $_.Key -like "*.exe" }).Key
$InstallerUrl = "https://$Bucket.s3.amazonaws.com/$InstallerExeKey"

Write-Output "Downloading $InstallerUrl to $LocalInstallerPath"

New-Item -ItemType Directory -Path "$LocalDirectory" -Force
$wc.DownloadFile("$InstallerUrl", "$LocalInstallerPath")

Any idea what the issue might be?

We've made sure our Iam role has s3 access, etc (even though we're downloading via http).

profile picture
ede
asked 6 months ago363 views
1 Answer
0
Accepted Answer

Looks like the script above does not support multiple "latest" entries being returned. As logged, the identified url to download is actually two urls:

https://ec2-windows-nvidia-drivers.s3.amazonaws.com/latest/537.13_grid_win10_win11_server2019_server2022_dch_64bit_international_aws_swl.exe
<space>
latest/537.70_grid_win10_win11_server2019_server2022_dch_64bit_international_aws_swl.exe

The fix is to use something like

$InstallerExeKey = ($Objects.Contents | Where-Object { $_.Key -like "*.exe" } | Sort-Object -Property LastModified -Descending | Select-Object -First 1).Key

to select only the most recent driver URL.

answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions