Skip to content

Commit

Permalink
more informative error message for missing AWS credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
SooLee committed Dec 17, 2019
1 parent 2a1497b commit 15e5a69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tibanna/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Version information."""

# The following line *must* be the last in the module, exactly as formatted:
__version__ = "0.11.1"
__version__ = "0.11.2"
9 changes: 8 additions & 1 deletion tibanna/vars.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import os
import boto3
import sys


if boto3.session.Session().get_credentials() is None:
print('Please provide AWS credentials.')
sys.exit(-1)


# AWS account info
AWS_ACCOUNT_NUMBER = os.environ.get('AWS_ACCOUNT_NUMBER', '')
if not AWS_ACCOUNT_NUMBER:
try:
AWS_ACCOUNT_NUMBER = boto3.client('sts').get_caller_identity().get('Account')
except Exception as e:
raise Exception("Cannot find AWS_ACCOUNT_NUMBER: %s" % e)
raise Exception("Cannot obtain AWS account number. Please provide AWS credentials")

AWS_REGION = os.environ.get('TIBANNA_AWS_REGION', '')
if not AWS_REGION:
Expand Down

0 comments on commit 15e5a69

Please sign in to comment.