code: def _check_security_group(self, name):
          
          connection = self._connect()
  
          filters = {}
          if self._vpc:
              filters = {'vpc-id': self._vpc_id}
  
          security_groups = connection.get_all_security_groups(filters=filters)
  
          matching_groups = [
              group
              for group
               in security_groups
               if name in [group.name, group.id]
          ]
          if len(matching_groups) == 0:
              raise SecurityGroupError(
                  "the specified security group %s does not exist" % name)
          elif len(matching_groups) == 1:
              return matching_groups[0].id
          elif self._vpc and len(matching_groups) > 1:
              raise SecurityGroupError(
                  "the specified security group name %s matches "
                  "more than one security group" % name)
docs: Checks if the security group exists.
  
          :param str name: name of the security group
          :return: str - security group id of the security group
          :raises: `SecurityGroupError` if group does not exist