NOTE: This is post that I had already posted here.
Since we use a shared account of AWS to work. It becomes incredibly painful to manage it. So I thought it would be good to have a mechanism write or export the list to of instances to a CSV so we could send a claim mail to see who claims these instances. So I wrote this
#!/usr/bin/env python from boto.ec2 import EC2Connection csv_file = open('instances.csv','w+') def process_instance_list(connection): map(build_instance_list,connection.get_all_instances()) def build_instance_list(reservation): map(write_instances,reservation.instances) def write_instances(instance): if (instance.virtualizationType == 'hvm'): platform = 'Windows' else: platform = 'Linux' csv_file.write("%s,%s,%s,%s,%s,%s\n"%(instance.id,instance.public_dns_name, instance.state,instance.placement,instance.architecture, platform)) csv_file.flush() if __name__=="__main__": connection = EC2Connection(aws_access_key_id='XXXXXXX',aws_secret_access_key='XXXXXXXX') process_instance_list(connection) csv_file.close()
This piece of code is pretty straight and any EC2 noop could understand it. What I do is, get list of instances and layout their details line-wise and comma separated into a csv file. Now this file could be easily imported into excel sheet. I need to get a better mechanism, I know. But, for now this works.