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

Support AWS_SHARED_CREDENTIALS_FILE #623

Merged
merged 2 commits into from
Aug 11, 2015
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion botocore/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class Session(object):
# These variables are intended for internal use so don't have any
# user settable values.
# This is the shared credentials file amongst sdks.
'credentials_file': (None, None, '~/.aws/credentials', None),
'credentials_file': (None, 'AWS_SHARED_CREDENTIALS_FILE',
'~/.aws/credentials', None),

# These variables only exist in the config file.

Expand Down
15 changes: 14 additions & 1 deletion tests/integration/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import mock

from botocore.session import Session
from tests import BaseEnvVar
from tests import BaseEnvVar, temporary_file


class TestCredentialPrecedence(BaseEnvVar):
Expand Down Expand Up @@ -107,3 +107,16 @@ def test_access_secret_env_vs_profile_code(self):

self.assertEqual(credentials.access_key, 'test')
self.assertEqual(credentials.secret_key, 'test-secret')

def test_honors_aws_shared_credentials_file_env_var(self):
with temporary_file('w') as f:
f.write('[default]\n'
'aws_access_key_id=custom1\n'
'aws_secret_access_key=custom2\n')
f.flush()
os.environ['AWS_SHARED_CREDENTIALS_FILE'] = f.name
s = Session()
credentials = s.get_credentials()

self.assertEqual(credentials.access_key, 'custom1')
self.assertEqual(credentials.secret_key, 'custom2')