docs: def query_instances(session, client=None, **query):
      """Return a list of ec2 instances for the query.
      """
      if client is None:
          client = session.client('ec2')
      p = client.get_paginator('describe_instances')
      results = p.paginate(**query)
      return list(itertools.chain(
          *[r["Instances"] for r in itertools.chain(
              *[pp['Reservations'] for pp in results])]))