code: def query_active_instances():
      ec2_region = config.get(Config.AWS, Config.AWS_EC2_REGION)
      ec2_key = config.get(Config.AWS, Config.AWS_ACCESS_KEY)
      ec2_secret = config.get(Config.AWS, Config.AWS_SECRET_KEY)
  
      conn = boto.ec2.connect_to_region(
          ec2_region,
          aws_access_key_id=ec2_key,
          aws_secret_access_key=ec2_secret,
      )
      reservations = conn.get_all_reservations()
  
      public_dns_names = []
  
      for reservation in reservations:
          instances = reservation.instances
  
          for instance in instances:
              if instance.state == "running":
                  public_dns_names.append(instance.public_dns_name)
  
      return public_dns_names
  
file_path: ATM/fabfile.py
imports: from __future__ import print_function
  from fabric.api import *
  from fabric.colors import green, yellow
  import boto.ec2
  import time
  from atm.config import AWSConfig
label_desc: Use image node_id 2 for calling a global function with example usage: query_active_instances() and returns: public_dns_names