Skip to content

Commit

Permalink
fix ordering of creds for aws
Browse files Browse the repository at this point in the history
  • Loading branch information
schae234 committed Sep 6, 2018
1 parent 7b380d5 commit 7432594
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions minus80/CloudData.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,24 @@ def __init__(self):
import boto3
from botocore.client import Config

# handle credentials
if 'CLOUD_ACCESS_KEY' in os.environ \
and 'CLOUD_SECRET_KEY' in os.environ \
and 'CLOUD_ENDPOINT' in os.environ: #pragma: no cover
aws_endpoint = os.environ['CLOUD_ENDPOINT']
# Fetch creds from config file
aws_endpoint = cf.cloud.endpoint
aws_access_key = cf.cloud.access_key
aws_secret_key = cf.cloud.secret_key

# override config with ENV variables
if 'CLOUD_ENDPOINT' in os.environ:
aws_endpoint = os.environ['CLOUD_ENDPOINT']
if 'CLOUD_ACCESS_KEY' in os.environ:
aws_access_key = os.environ['CLOUD_ACCESS_KEY']
if 'CLOUD_SECRET_KEY' in os.environ:
aws_secret_key = os.environ['CLOUD_SECRET_KEY']
else: #pragma: no cover
if cf.cloud.access_key == 'None' or cf.cloud.secret_key == 'None':
raise ValueError('Fill in your S3 Credentials in ~/.minus80.conf')
aws_endpoint = cf.cloud.endpoint
aws_access_key = cf.cloud.access_key
aws_secret_key = cf.cloud.secret_key

if aws_access_key is None or aws_secret_key is None:
raise ValueError(
'Fill in your S3 Credentials in ~/.minus80.conf or '
'set ENV variables'
)

self.s3 = boto3.client(
service_name='s3',
Expand Down

0 comments on commit 7432594

Please sign in to comment.