Python Forum
Thread Rating:
  • 3 Vote(s) - 2.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list-instances
#1
this is a python command to list AWS EC2 instances using multiprocessing (with the multiprocessing module) to query each region in parallel (up to eleven of them as of the date of this post). it uses botocore, which you need to install to use this (with pip).  the arguments are region names.  if no arguments are given, it lists all known regions (in the aws_regions module).  the US gov and Chinese regions are not supported (you modify the code if you need them).  if you make a copy or link or symlink called list-running-instances (or any name with 'run in it) that lists only the running or pending instances.  the instance tags are included.  long instance IDs work just fine.  it needs these 3 modules:  aws_regions, imports, pyutils which are also available at the same site.  this is not tested on windows (that's up to you if you know how to make it work there) or anywhere else but Ubuntu Linux 16.04 LTS with Python 2.7.11.

http://stratusrelay.com/free/list-instances.py

and the modules it needs:

http://stratusrelay.com/free/aws_regions.py
http://stratusrelay.com/free/imports.py
http://stratusrelay.com/free/pyutils.py

if you just want to view these in your browser and it only lets you download, you can append '.txt' to the URL and view it that way, like these links:

http://stratusrelay.com/free/list-instances.py.txt
http://stratusrelay.com/free/aws_regions.py.txt
http://stratusrelay.com/free/imports.py.txt
http://stratusrelay.com/free/pyutils.py.txt

note that list-instance uses pickle.  it is used in a safe and secure manner over pipes between process instances of itself.  it does not accept pickle data from untrusted sources. it creates a child instance of itself, per AWS region (specified or all of them), and uses pickle to send structured data, over the pipe, to the parent, which formats it for output.

nice ... when i reply to my own post it appends it to there.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
#2
Do you have a git repo? Since this seems like something that could change with time, it seems like it'd be a good thing to host there rather than just static files on a server.
#3
(Oct-03-2016, 08:08 PM)micseydel Wrote: Do you have a git repo? Since this seems like something that could change with time, it seems like it'd be a good thing to host there rather than just static files on a server.

no, i don't have one.  i went to github.com and clicked on "Sign up for Github" but the first thing i see is "There were problems creating your account." (in red color) even before i entered info, so there must be an issue with my IP address (not the first time that has happened).  the static files are on AWS S3 (so no issue with my IP), but they are under my company domain, so i guess that is the issue.  if i do end up on github, i'll be looking for a script (preferably in python) to sync my files to there.

i'll also do more code embedding here.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
#4
Quote:so there must be an issue with my IP address (not the first time that has happened)
I have never had this happen once.  :huh:
Recommended Tutorials:
#5
(Oct-04-2016, 01:45 AM)metulburr Wrote:
Quote:so there must be an issue with my IP address (not the first time that has happened)
I have never had this happen once.  :huh:

i guess i might try going through a tunnel ending in an AWS instance, using their IP.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020