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

AWS Credentials Check #1194

Merged
merged 5 commits into from
Oct 5, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion sky/clouds/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import typing
from typing import Dict, Iterator, List, Optional, Tuple

import boto3

from sky import clouds
from sky.clouds import service_catalog

Expand Down Expand Up @@ -314,9 +316,20 @@ def check_credentials(self) -> Tuple[bool, Optional[str]]:
elif line.startswith('secret_key'):
if '<not set>' not in line:
secret_key_ok = True

if access_key_ok and secret_key_ok:
# Checks if AWS credentials are valid and can connect to AWS services.
# https://stackoverflow.com/questions/53548737/verify-aws-credentials-with-boto3
sts = boto3.client('sts')
try:
sts.get_caller_identity()
except boto3.exceptions.ClientError:
return False, (
'AWS credentials are not set properly.'
' Make sure that the access and secret keys are correct'
' in `~/.aws/credentials`.')
Michaelvll marked this conversation as resolved.
Show resolved Hide resolved
return True, None
return False, 'AWS credentials is not set.' + help_str
return False, 'AWS credentials are not set.' + help_str

def get_credential_file_mounts(self) -> Dict[str, str]:
return {
Expand Down