def _check_if_role_exists(self, role_name):
        try:
            # Client call to get the role
            self._iam_client.get_role(RoleName=role_name)
        except ClientError as e:
            # If the role does not exist then the error message
            # would contain the required message.
            if e.response['Error']['Code'] == 'NoSuchEntity':
                # No role error.
                return False
            else:
                # Some other error. raise.
                raise e

        return True
Method to verify if a particular role exists
dataset/ETHPy150Open aws/aws-cli/awscli/customizations/datapipeline/createdefaultroles.py/CreateDefaultRoles._check_if_role_exists