Created
May 20, 2010 03:08
-
-
Save peplin/407142 to your computer and use it in GitHub Desktop.
Python script to output current EC2 instance info to a text file for Conky
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| conkec2 | |
| Christopher Peplin, [email protected] | |
| Python script to output current EC2 instance information to a text file, ideally | |
| for Conky to display on your desktop. | |
| Expects the standard AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment | |
| variables to be defined. | |
| Requires the boto Python package: | |
| $ pip install boto | |
| """ | |
| #!/usr/bin/env python | |
| import os | |
| import boto.ec2 | |
| AWS_ACCESS_KEY = os.environ['AWS_ACCESS_KEY_ID'] | |
| AWS_SECRET_KEY = os.environ['AWS_SECRET_ACCESS_KEY'] | |
| EC2_CONNECTION = boto.ec2.EC2Connection(AWS_ACCESS_KEY, AWS_SECRET_KEY) | |
| output = open(os.environ['HOME']+ '/.conkec2', 'w') | |
| for reservation in EC2_CONNECTION.get_all_instances(): | |
| for instance in reservation.instances: | |
| output.write(instance.id + ": ") | |
| output.write(instance.state + "\n") | |
| output.write(instance.instance_type + "\n") | |
| output.write(instance.launch_time + "\n") | |
| output.write(instance.dns_name + "\n") | |
| output.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment