-
Notifications
You must be signed in to change notification settings - Fork 73
/
list_all_aws_resources_skew.py
executable file
·52 lines (44 loc) · 1.53 KB
/
list_all_aws_resources_skew.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
"""
Script using skew (https://github.com/scopely-devops/skew) to list ALL
resources in an AWS account.
If you have ideas for improvements, or want the latest version, it's at:
<https://github.com/jantman/misc-scripts/blob/master/list_all_aws_resources_skew.py>
Copyright 2016 Jason Antman <[email protected]> <http://www.jasonantman.com>
Free for any use provided that patches are submitted back to me.
CHANGELOG:
2016-06-22 Jason Antman <[email protected]>:
- initial version of script
"""
import sys
try:
from skew.arn import ARN
from skew.exception import ConfigNotFoundError
from skew import scan
except ImportError:
raise Exception('You must "pip install skew" before using this script.')
try:
arn = ARN()
except ConfigNotFoundError as ex:
sys.stderr.write("Please create your skew config file per "
"<https://github.com/scopely-devops/skew>\n")
raise ex
services=arn.service.choices()
services.sort()
print('Enumerating all resources in the following services: ' +
' '.join(services) + '\n')
for service in services:
print('******' + service + '******')
if service in ['iam', 'route53']:
uri = 'arn:aws:%s::*:*' % service
else:
uri = 'arn:aws:%s:*:*:*/*' % service
try:
arn = scan(uri)
for i in arn:
id_str = None
if hasattr(i, 'tags'):
id_str = 'tags: %s' % i.tags
print('%s %s' % (i.arn, id_str))
except:
print("=> Error scanning service: %s" % service)