diff --git a/awscli/customizations/datapipeline/createdefaultroles.py b/awscli/customizations/datapipeline/createdefaultroles.py index 176ee04fb0a7..b8b5bf117736 100644 --- a/awscli/customizations/datapipeline/createdefaultroles.py +++ b/awscli/customizations/datapipeline/createdefaultroles.py @@ -23,7 +23,7 @@ DATAPIPELINE_DEFAULT_RESOURCE_ROLE_ASSUME_POLICY from awscli.customizations.commands import BasicCommand from awscli.customizations.datapipeline.translator \ - import display_response, dict_to_string, get_region + import display_response, dict_to_string, get_region, remove_cli_error_event from botocore.exceptions import ClientError LOG = logging.getLogger(__name__) @@ -35,12 +35,12 @@ class CreateDefaultRoles(BasicCommand): DESCRIPTION = ('Creates the default IAM role ' + DATAPIPELINE_DEFAULT_SERVICE_ROLE_NAME + ' and ' + DATAPIPELINE_DEFAULT_RESOURCE_ROLE_NAME + - '\n which are used while creating an EMR cluster. ' - '\nIf the roles do not exist, create-default-roles ' + ' which are used while creating an EMR cluster.\n' + 'If the roles do not exist, create-default-roles ' 'will automatically create them and set their policies.' - '\nIf these roles are already ' + ' If these roles are already ' 'created create-default-roles' - 'will not update their policies.' + ' will not update their policies.' '\n') def __init__(self, session, formatter=None): @@ -53,6 +53,7 @@ def _run_main(self, parsed_args, parsed_globals, **kwargs): self._iam_client = self._session.create_client( 'iam', self._region, self._endpoint_url, parsed_globals.verify_ssl) + remove_cli_error_event(self._iam_client) return self._create_default_roles(parsed_args, parsed_globals) def _create_role(self, role_name, role_arn, role_policy): diff --git a/awscli/customizations/datapipeline/translator.py b/awscli/customizations/datapipeline/translator.py index 61dd161c9983..8db2a8504fd0 100644 --- a/awscli/customizations/datapipeline/translator.py +++ b/awscli/customizations/datapipeline/translator.py @@ -37,6 +37,16 @@ def get_region(session, parsed_globals): return region +def remove_cli_error_event(client): + """This unregister call will go away once the client switchover + is done, but for now we're relying on S3 catching a ClientError + when we check if a bucket exists, so we need to ensure the + botocore ClientError is raised instead of the CLI's error handler. + """ + client.meta.events.unregister( + 'after-call', unique_id='awscli-error-handler') + + # Method to display the response for a particular CLI operation def display_response(session, operation_name, result, parsed_globals): cli_operation_caller = CLIOperationCaller(session)