Skip to content

Commit

Permalink
sky check UX: show underlying exceptions for AWS errors. (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
concretevitamin authored Jun 2, 2023
1 parent 1304fae commit 430ba74
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions sky/clouds/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 430ba74

Please sign in to comment.