python


How to query AWS to get ELB names and attached instances to that using python boto modules?


I am trying retrieve the ELB names and the attached instances ids using python boto modules.
{
import boto
conn = boto.connect_elb()
conn.get_all_load_balancers()
}
Gives only load-balancer names now how can i retrieve the Instance-ids attached to the load-balancer ?
conn.get_all_load_balancers() - returns a list of elbs objects. Each elb object has a parameter instances that will show you attached instances. And from there you can get their Id's.
If you want to find elb by name, then you need to filter first loop.
So something like this should work (Thanks #Frédéric Henri for update):
import boto
conn = boto.connect_elb()
elbs = conn.get_all_load_balancers(load_balancer_names=['MY-ELB-NAME'])[0]
instances = [inst.id for elb in elbs for inst in elb.instances]

Related Links

Why use user nobody nogroup in upstart services or daemon services
Grouping a list in python specifically
How to use python to loop through all possible results in postgresql?
Python: multiple assignment vs. individual assignment speed
reading graph from titan using python without rexter server
Overwriting builtins python class
How to get name of a required page in flask?
Outputting to a file in HDFS using a subprocess
Unable to destroy wx.Dialog in wxpython
Python Serial Writes slows down after some time
String to datetime django
How to replace all the file extensions in a folder? (Python)
Python in proccess of geting to pig game [closed]
QGIS XML plugin to read and parse second try
making autogenerated module members visible to PyDev/PyLint static analysis
Python Assistance with a small code

Categories

HOME
caching
crystal-reports
ssas-2012
google-cloud-bigtable
paramiko
reportportal
azureservicebus
simpy
docker-windows
structuremap
height
powershell-v3.0
cortex-a
ida
sql-tuning
bar-chart
derived
ng2-dragula
tortoisegit
embedly
facebook4j
iup
helper
fileinfo
datadog
dd-wrt
ocs
modulo
windows-10-iot-core
hashcat
xen
broadleaf-commerce
axis-labels
poco-libraries
deepstream.io
android-preferences
lexical-analysis
spring-bean
pinvoke
goquery
cgcontext
component-pascal
chrome-remote-desktop
adler32
qos
restivejs
rsqlite
atlassian-crowd
slam-algorithm
brython
fps
gemini
android-cursoradapter
schtasks.exe
affix
on-duplicate-key
coypu
shift-jis
robocode
alphablending
cpu-speed
hidden-field
google-admin-audit-api
sid
eclipse-classpath
funkload
cling
modeshape
nservicebus4
onselect
astyanax
visual-studio-2003
carddav
ng-pattern
mstsc
mvccontrib
driving-directions
msbuildextensionpack
windows-live-id
ihttphandler
nagle
requestfactory
recordset
delegatecommand
iphone-sdk-3.2
associativity

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App