From 430ba74a9223e6aa74b431ce7834c1498c5f4753 Mon Sep 17 00:00:00 2001 From: Zongheng Yang Date: Fri, 2 Jun 2023 11:23:57 -0700 Subject: [PATCH] `sky check` UX: show underlying exceptions for AWS errors. (#2002) --- sky/clouds/aws.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sky/clouds/aws.py b/sky/clouds/aws.py index ced38cf4f78..9b2c66f8d71 100644 --- a/sky/clouds/aws.py +++ b/sky/clouds/aws.py @@ -90,6 +90,7 @@ class AWS(clouds.Cloud): 'Run the following commands:' f'\n{_INDENT_PREFIX} $ pip install boto3' f'\n{_INDENT_PREFIX} $ aws configure' + f'\n{_INDENT_PREFIX} $ aws configure list # Ensure that this shows identity is set.' f'\n{_INDENT_PREFIX}For more info: ' 'https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html' # pylint: disable=line-too-long ) @@ -567,17 +568,25 @@ def get_current_user_identity(cls) -> Optional[List[str]]: # 2. In the case where the multiple users belong to an organization, # those users will have different account id, so fallback works. user_ids = [user_info['UserId'], user_info['Account']] - except aws.botocore_exceptions().NoCredentialsError: + except aws.botocore_exceptions().NoCredentialsError as e: with ux_utils.print_exception_no_traceback(): raise exceptions.CloudUserIdentityError( - f'AWS credentials are not set. {cls._STATIC_CREDENTIAL_HELP_STR}' + 'AWS credentials are not set. ' + f'{cls._STATIC_CREDENTIAL_HELP_STR}\n' + f'{cls._INDENT_PREFIX}Details: `aws sts ' + 'get-caller-identity` failed with error:' + f' {common_utils.format_exception(e, use_bracket=True)}.' ) from None - except aws.botocore_exceptions().ClientError: + except aws.botocore_exceptions().ClientError as e: with ux_utils.print_exception_no_traceback(): raise exceptions.CloudUserIdentityError( 'Failed to access AWS services with credentials. ' 'Make sure that the access and secret keys are correct.' - f' {cls._STATIC_CREDENTIAL_HELP_STR}') from None + f' {cls._STATIC_CREDENTIAL_HELP_STR}\n' + f'{cls._INDENT_PREFIX}Details: `aws sts ' + 'get-caller-identity` failed with error:' + f' {common_utils.format_exception(e, use_bracket=True)}.' + ) from None except aws.botocore_exceptions().InvalidConfigError as e: # pylint: disable=import-outside-toplevel import awscli