python - How to iterate through security groups in AWS ec2? -


i trying iterate through ec2 security groups. have wrote following code connect , security groups:

security_groups = ec2_conn.get_all_security_groups() 

next step need use group id each security group. in loop used code print :

print(security_groups[group_id]) 

i tried many different attributes instead of [group_id] keep getting error :

"nameerror: name 'group_id' not defined"

what right way retrieve or print 1 attribute security groups ?

here working example of how iterate on security groups, , print group ids

import boto ec2_conn = boto.connect_ec2() security_groups = ec2_conn.get_all_security_groups() group in security_groups:     print(group.id) 

some additional information on manipulating security groups: http://boto.readthedocs.org/en/latest/security_groups.html


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -