def ip_permission_grants_access_to_group_with_id(ipp, security_group_id):
    """
    Returns True if an EC2 security group IP permission opens access to
    a security with the given ID and False otherwise.

    >>> ip_permission_grants_access_to_group_with_id(
    ... {'UserIdGroupPairs': [{'GroupId': 'test-sgid'}]}, 'test-sgid')
    True
    >>> ip_permission_grants_access_to_group_with_id(
    ... {'UserIdGroupPairs': [{'GroupId': 'test-sgid'}]}, 'not-test-sgid')
    False
    >>> ip_permission_grants_access_to_group_with_id({}, 'test-sgid')
    False
    """
    for user_id_group_pair in ipp.get('UserIdGroupPairs', []):
        if user_id_group_pair.get('GroupId', None) == security_group_id:
            return True
    return False
