I m using Python AWS-SDK BOTO. I m trying to retrieve all the security group details of my account.
secgrpList = ec2conn.get_all_security_groups()
ipRange = secgrpList[0].rules[1].ipRanges
print ipRange
print type(ipRange).__name__
But when i print the ipRange it shows nothing just two enter
. When i check the type it is unicode. I even tried to conver to string str() but in vain.
What is the issue ? How can i retrieve the details ?
Please advice me.
To loop over all security groups and print its rules including protocol, ports and ip range, try this:
import boto.ec2
conn = boto.ec2.connect_to_region("eu-west-1")
groups = conn.get_all_security_groups()
for group in groups:
print group.name
for rule in group.rules:
print rule.ip_protocol, rule.from_port, rule.to_port, rule.grants
which may result:
default
tcp 22 22 [0.0.0.0/0]
tcp 80 80 [0.0.0.0/0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With