Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sky1122
Copy link
Contributor

@sky1122 sky1122 commented Nov 21, 2024

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

  • I've reviewed the guidance in CONTRIBUTING.md

License Acceptance

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines 68 to 82
# 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"
}
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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

Comment on lines 62 to 66
# 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
Copy link
Member

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.

Copy link
Contributor Author

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants