-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add aws cli to system path #779
base: main
Are you sure you want to change the base?
Conversation
11933d8
to
dbb4c7b
Compare
# Add AWS CLI to PATH | ||
$awsPath = Get-Command aws -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source | ||
if ($awsPath) { | ||
$awsDir = Split-Path -Parent $awsPath | ||
$currentPath = [Environment]::GetEnvironmentVariable("Path", "Machine") | ||
if ($currentPath -notlike "*$awsDir*") { | ||
$newPath = "$currentPath;$awsDir" | ||
[Environment]::SetEnvironmentVariable("Path", $newPath, "Machine") | ||
Write-Output "AWS CLI path added to system PATH: $awsDir" | ||
} else { | ||
Write-Output "AWS CLI path already in system PATH" | ||
} | ||
} else { | ||
Write-Output "AWS CLI not found" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need all this logic? If the MSI installation succeeds, we can assume the AWS binary is at the default path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the default path is C:\Program Files\Amazon\AWSCLIV2\aws
.
$awsPath = "C:\Program Files\Amazon\AWSCLIV2"
$currentPath = [Environment]::GetEnvironmentVariable("Path", "Machine")
$newPath = "$currentPath;$awsPath"
[Environment]::SetEnvironmentVariable("Path", $newPath, "Machine")
Can I change to this? or can we use C:\Program Files\Amazon\AWSCLIV2\aws
to call the aws cli?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that will work, yeah
# Install AWS CLI | ||
Invoke-WebRequest -Uri https://awscli.amazonaws.com/AWSCLIV2.msi -OutFile AWSCLIV2.msi | ||
Start-Process msiexec.exe -Wait -ArgumentList '/I AWSCLIV2.msi /quiet' | ||
aws --version | ||
Remove-Item AWSCLIV2.msi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to merge/rebase from main to remove this from the diff. It's causing a merge conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase it
Signed-off-by: jingwei wang <[email protected]>
dbb4c7b
to
f0cc8e5
Compare
Signed-off-by: jingwei wang <[email protected]>
f0cc8e5
to
2139b54
Compare
Description of changes:
Fix cannot directly use aws cli in command line
Testing done:
have a windows instance and using windows app test the power shell command
License Acceptance
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.