def get_ports_from_rules(body_response_sec_group_list, sec_group_name, protocol='TCP'):
    """
    Retrieve the list of TCP open ports
    :param body_response_sec_group_list: Parsed response (python dic). List of sec. groups
    :param sec_group_name: Name of Sec. Group to look for
    :param protocol: TCP or UDP
    :return: List of TCP ports (list of strings)
    """
    port_list = []
    for sec_group in body_response_sec_group_list['security_groups']:
        if sec_group_name in sec_group['name']:
            for rule in sec_group['rules']:
                if rule['ip_protocol'] == protocol.lower():
                    port = str(rule['from_port'])
                    to_port = str(rule['to_port'])
                    port = port + "-" + to_port if to_port != port else port
                    port_list.append(port)

    return port_list