def set_instances(name, instances, test=False, region=None, key=None, keyid=None, profile=None):
 ret = True
 current = set([i['instance_id'] for i in get_instance_health(name, region, key, keyid, profile)])
 desired = set(instances)
 add = (desired - current)
 remove = (current - desired)
 if test:
  return bool((add or remove))
 if len(remove):
  if (deregister_instances(name, list(remove), region, key, keyid, profile) is False):
   ret = False
 if len(add):
  if (register_instances(name, list(add), region, key, keyid, profile) is False):
   ret = False
 return ret

def set_instances ( name , instances , test = False , region = None , key = None , keyid = None , profile = None ) : ret = True current = set ( [ i [ 'instance_id' ] for i in get_instance_health ( name , region , key , keyid , profile ) ] ) desired = set ( instances ) add = ( desired - current ) remove = ( current - desired ) if test : return bool ( ( add or remove ) ) if len ( remove ) : if ( deregister_instances ( name , list ( remove ) , region , key , keyid , profile ) is False ) : ret = False if len ( add ) : if ( register_instances ( name , list ( add ) , region , key , keyid , profile ) is False ) : ret = False return ret
set the instances assigned to an elb to exactly the list given cli example: .