Skip to content

Commit

Permalink
Handle case when no profiles are configured for the plugin or for AWS…
Browse files Browse the repository at this point in the history
… CLI
  • Loading branch information
Tom Bamford committed Apr 22, 2018
1 parent f45da4b commit 5c5d1f0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions vars_plugins/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _connect_profiles(self):

def _export_credentials(self):
self.aws_profile = None
profiles = self.config.get('aws_profiles', None)
profiles = self.config.get('aws_profiles', ['default'])

if isinstance(profiles, dict):
profiles_list = profiles.keys()
Expand Down Expand Up @@ -142,7 +142,13 @@ def _export_credentials(self):
def _init_session(self, profile):
if not hasattr(self, 'sessions'):
self.sessions = dict()
self.sessions[profile] = boto3.Session(profile_name=profile)
try:
self.sessions[profile] = boto3.Session(profile_name=profile)
except botocore.exceptions.ProfileNotFound as e:
if profile == 'default':
self.sessions[profile] = boto3.Session()
else:
raise


def _session(self, profile):
Expand Down

0 comments on commit 5c5d1f0

Please sign in to comment.