code: def apply(self, vpc):
          
          assert vpc is not None
          # make sure we're up to date
          self.reload_remote_groups()
  
          vpc_groups = self.vpc_groups(vpc)
          self._apply_groups(vpc)
  
          # reloads groups from AWS, the authority
          self.reload_remote_groups()
          vpc_groups = self.vpc_groups(vpc)
  
  
          groups = {k.name:k for k in vpc_groups}
  
          for x,y in self.config.items():
              # process 1 security group at a time
              group = groups[x]
              if y.get('rules'):
                  # apply all rule changes
                  rules = [Rule.parse(rule) for rule in y.get('rules')]
                  rules = list(itertools.chain(*rules))
  
                  rules = self.filter_existing_rules(rules, group)
                  # need to use chain because multiple rules can be created for a single stanza
                  for rule in rules:
                      group_name = groups.get(rule.group_name, None)
                      if group_name and rule.address:
                          raise Exception("Can't auth an address and a group")
  
                      logger.debug("Authorizing %s %s %s to address:%s name:%s", rule.protocol,
                                   rule.from_port, rule.to_port, rule.address, rule.group_name)
  
                      group_to_authorize = groups.get(rule.group_name, None)
  
                      try:
                          group.authorize(rule.protocol,
                                      rule.from_port,
                                      rule.to_port,
                                      rule.address,
                                      group_to_authorize, None)
                      except Exception as e:
                          print "could not authorize group %s" % group_to_authorize
                          raise
  
                  # apply rules
  
          return self
docs: returns a list of new security groups that will be added