diff --git a/pacu.py b/pacu.py index 974d7b96..beac4f02 100644 --- a/pacu.py +++ b/pacu.py @@ -1060,10 +1060,17 @@ def import_module_by_name(self, module_name, include=()): def print_web_console_url(self): active_session = self.get_active_session() + if not active_session.access_key_id: + print(' No access key has been set. Not generating the URL.') + return + if not active_session.secret_access_key: + print(' No secret key has been set. Not generating the URL.') + return + sts = self.get_boto3_client('sts') res = sts.get_federation_token( - Name=active_session.name, + Name=active_session.key_alias, Policy=json.dumps({ 'Version': '2012-10-17', 'Statement': [ @@ -1091,7 +1098,7 @@ def print_web_console_url(self): params = { 'Action': 'login', - 'Issuer': active_session.name, + 'Issuer': active_session.key_alias, 'Destination': 'https://console.aws.amazon.com/console/home', 'SigninToken': signin_token } @@ -1539,6 +1546,13 @@ def get_boto3_client(self, service, region=None, user_agent=None, socks_port=800 session = self.get_active_session() proxy_settings = self.get_proxy_settings() + if not session.access_key_id: + print(' No access key has been set. Failed to generate boto3 Client.') + return + if not session.secret_access_key: + print(' No secret key has been set. Failed to generate boto3 Client.') + return + # If there is not a custom user_agent passed into this function # and session.boto_user_agent is set, use that as the user agent # for this client. If both are set, the incoming user_agent will @@ -1567,6 +1581,13 @@ def get_boto3_resource(self, service, region=None, user_agent=None, socks_port=8 session = self.get_active_session() proxy_settings = self.get_proxy_settings() + if not session.access_key_id: + print(' No access key has been set. Failed to generate boto3 Resource.') + return + if not session.secret_access_key: + print(' No secret key has been set. Failed to generate boto3 Resource.') + return + if user_agent is None and session.boto_user_agent is not None: user_agent = session.boto_user_agent