title: Python script for listing instances based on custom tags values passed during script execution
body: <p>I was trying out executing a python script in following way python script.py -env  - role  to fetch instances on specified environment and role values . Here is my script :</p>
  
  <pre><code>   import argparse
     import boto.ec2
  
     AWS_ACCESS_KEY_ID = '&lt;xxxxxx&gt;'
     AWS_SECRET_ACCESS_KEY = '&lt;xxxxx&gt;'
     ec2conn = boto.ec2.connection.EC2Connection(AWS_ACCESS_KEY_ID,         AWS_SECRET_ACCESS_KEY)
  
     env = ''
     role = ''
  
     def get_ec2_instances():
      regions = ['us-east-1','us-west-1','us-west-2','eu-west-1','sa-east-1',
                  'ap-southeast-1','ap-southeast-2','ap-northeast-1']
      parser = argparse.ArgumentParser()
      parser.add_argument('env', help='tag:environment');
      parser.add_argument('role', help='tag:role');
      args = parser.parse_args()
      global env
      global role
      env = args.env
      role = args.role
  
     reservations = ec2conn.get_all_instances(filters={"tag:environment" :    "env","tag:role" : "role"})
    #reservations = ec2conn.get_all_instances()
    inst = [i for r in reservations for i in r.instances]
    for i in inst:
        print  "%s" % (i.tags['Name'])
  
     if  __name__ =='__get_ec2_instances__':get_ec2_instances()
  </code></pre>
  
  <p>Its throwing no error and no result.. </p>