def METHOD_NAME(ec2, group_id, port, cidr_ip):
    response = ec2.describe_security_groups(GroupIds=[group_id])
    security_groups = response['SecurityGroups']
    assert len(security_groups) == 1
    ip_permissions = security_groups[0]['IpPermissions']
    ip_perm = next(
        filter(lambda rule: rule['FromPort'] == port, ip_permissions))
    return any(filter(lambda x: x['CidrIp'] == cidr_ip, ip_perm['IpRanges']))