-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsgMap.py
More file actions
executable file
·36 lines (29 loc) · 1.13 KB
/
sgMap.py
File metadata and controls
executable file
·36 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import boto
import httplib
# this doesn't work
if boto.Version < 2:
print "wrong boto version"
exit()
# pseudoDNS users credentials
AccessKeyID = ""
secretAccessKey = ""
conn = boto.connect_ec2(AccessKeyID, secretAccessKey)
rules = {}
for region_local in [ conn.get_all_regions()[2] ]:
print(region_local)
conn_local = region_local.connect(aws_secret_access_key=secretAccessKey, aws_access_key_id=AccessKeyID)
for sg in conn_local.get_all_security_groups():
for rule in sg.rules:
#rule.to_port to rule.from_port
incoming = rule.grants[0]
if incoming.name: print '"' + str(incoming.name) + '"',
if incoming.cidr_ip: print '"' + incoming.cidr_ip + '"',
print "->",
print '"' + str(rule.parent.name) + '"',
if rule.from_port == rule.to_port:
print '[ label="' + str(rule.from_port) + '" ]',
else:
print '[ label="' + str(rule.from_port) + '-' + str(rule.to_port) + '" ]',
print ";"
#print incoming.name + incoming.cidr_ip + " " + str(rule.parent.name)