def port_in_rule(port, rule):
    """
    Return True or False if port is covered by a security group rule.

    :param port: port to check
    :type port: int
    :param rule: security group rule to check
    :return: True or False if port is covered by a security group rule.
    :rtype: bool
    """
    try:
        return port in range(rule["FromPort"], rule["ToPort"] + 1)
    except KeyError:
        return False