EC2 Windows에서 AWS CLI를 사용할 시 The term ‘aws’ is not recognized as the name of a cmdlet, function, script file, or operable program 에러 해결

EC2 Windows에서 AWS CLI를 사용할 시 The term ‘aws’ is not recognized as the name of a cmdlet, function, script file, or operable program 에러를 해결하는 방법에 대해서 정리해 봤습니다.
2023.12.16

안녕하세요 클래스메소드 김재욱(Kim Jaewook) 입니다. 이번에는 EC2 Windows에서 AWS CLI를 사용할 시 The term ‘aws’ is not recognized as the name of a cmdlet, function, script file, or operable program 에러를 해결하는 방법에 대해서 정리해 봤습니다.

문제 발생

aws : The term 'aws' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + aws s3 ls + ~~~ + CategoryInfo : ObjectNotFound: (aws:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

s3 리스트를 출력하는 명령어를 입력하자 상기와 같은 에러가 발생했습니다.

문제 해결

EC2 Windows에 AWS CLI가 설치되어 있지 않기 떄문에 발생하는 문제로, AWS CLI를 설치할 필요가 있습니다.

$command = "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
Invoke-Expression $command
Invoke-WebRequest -Uri "https://awscli.amazonaws.com/AWSCLIV2.msi" -Outfile C:\AWSCLIV2.msi
$arguments = "/i `"C:\AWSCLIV2.msi`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")

상기 명령어를 통해 AWS CLI를 인스톨합니다.

이후 aws s3 ls 명령어를 입력하면, 성공적으로 버킷 리스트를 출력할 수 있습니다.

참고

본 블로그 게시글을 읽고 궁금한 사항이 있으신 분들은 kis2702@naver.com로 보내주시면 감사하겠습니다.