diff --git a/sky/clouds/aws.py b/sky/clouds/aws.py index 55cfbf9c2e1..3e7cd08ad68 100644 --- a/sky/clouds/aws.py +++ b/sky/clouds/aws.py @@ -461,6 +461,13 @@ def _make(instance_list): def check_credentials(cls) -> Tuple[bool, Optional[str]]: """Checks if the user has access credentials to this cloud.""" + dependency_installation_hints = ( + 'AWS dependencies are not installed. ' + 'Run the following commands:' + f'\n{cls._INDENT_PREFIX} $ pip install skypilot[aws]' + f'\n{cls._INDENT_PREFIX}Credentials may also need to be set. ' + f'{cls._STATIC_CREDENTIAL_HELP_STR}') + # Checks if the AWS CLI is installed properly proc = subprocess.run('aws --version', shell=True, @@ -468,12 +475,14 @@ def check_credentials(cls) -> Tuple[bool, Optional[str]]: stdout=subprocess.PIPE, stderr=subprocess.PIPE) if proc.returncode != 0: - return False, ( - 'AWS CLI is not installed properly. ' - 'Run the following commands:' - f'\n{cls._INDENT_PREFIX} $ pip install skypilot[aws]' - f'\n{cls._INDENT_PREFIX}Credentials may also need to be set. ' - f'{cls._STATIC_CREDENTIAL_HELP_STR}') + return False, dependency_installation_hints + try: + # Checks if aws boto is installed properly + # pylint: disable=import-outside-toplevel, unused-import + import boto3 + import botocore + except ImportError: + return False, dependency_installation_hints # Checks if AWS credentials 1) exist and 2) are valid. # https://stackoverflow.com/questions/53548737/verify-aws-credentials-with-boto3