awful 0.0.60 → 0.0.61
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/iam.rb +51 -1
- data/lib/awful/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9de77c555253db18fb3501a860fd378a2285ae7e
|
4
|
+
data.tar.gz: 9874f168edca11bab394839f8a85426bc92aa9eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d63c654d168b348bd4e90a3c54fbc8b6b9f9fc053c21260ee15dea4fa6b8766aa086f6a7477d12a432ca42dbaf374f1fcb23ab2bfdc072589ea9f9a1924a128
|
7
|
+
data.tar.gz: 80d40f3d3dd3efb35d613ba326eff0fcaa4e4d19a1253e338481c5952865c1d90cfc3d54413ef89079677fe3e0d21f55b25329937e5d68d3a6afb0b7b36636f6
|
data/lib/awful/iam.rb
CHANGED
@@ -30,6 +30,56 @@ module Awful
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
desc 'roles [NAME]', 'list IAM roles [matching NAME]'
|
34
|
+
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
35
|
+
method_option :arns, aliases: '-a', default: false, desc: 'Show ARNs instead of names'
|
36
|
+
def roles(name = /./)
|
37
|
+
iam.list_roles.roles.select do |role|
|
38
|
+
role.role_name.match(name)
|
39
|
+
end.tap do |roles|
|
40
|
+
name_method = options[:arns] ? :arn : :role_name
|
41
|
+
if options[:long]
|
42
|
+
print_table roles.map { |r|
|
43
|
+
[
|
44
|
+
r.send(name_method),
|
45
|
+
r.role_id,
|
46
|
+
r.create_date,
|
47
|
+
options[:arns] ? r.arn : nil
|
48
|
+
]
|
49
|
+
}
|
50
|
+
else
|
51
|
+
puts roles.map(&name_method)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'policy {role,group,user} NAME', 'List or show policy(s) for {role,group,user} NAME'
|
57
|
+
method_option :pretty, aliases: '-p', default: false, desc: 'Pretty-print policy document'
|
58
|
+
def policy(type, name, policy = nil)
|
59
|
+
|
60
|
+
## first matching role, group or user
|
61
|
+
thing_name = iam.send("list_#{type}s").send("#{type}s").find do |thing|
|
62
|
+
thing.send("#{type}_name").match(name)
|
63
|
+
end.send("#{type}_name")
|
64
|
+
|
65
|
+
## policies for this role, group or user
|
66
|
+
policies = iam.send("list_#{type}_policies", "#{type}_name".to_sym => thing_name).policy_names
|
67
|
+
|
68
|
+
if policy.nil? # just list policies
|
69
|
+
policies.tap(&method(:puts))
|
70
|
+
else # get policy document
|
71
|
+
policy_name = policies.find { |p| p.match(/#{policy}/i) }
|
72
|
+
doc = iam.send("get_#{type}_policy", "#{type}_name".to_sym => thing_name, policy_name: policy_name).policy_document
|
73
|
+
URI.unescape(doc).tap do |str|
|
74
|
+
if options[:pretty]
|
75
|
+
puts JSON.pretty_generate(JSON.parse(str))
|
76
|
+
else
|
77
|
+
puts str
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
33
83
|
end
|
34
84
|
|
35
|
-
end
|
85
|
+
end
|
data/lib/awful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.61
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -183,3 +183,4 @@ signing_key:
|
|
183
183
|
specification_version: 4
|
184
184
|
summary: Simple AWS command-line tool.
|
185
185
|
test_files: []
|
186
|
+
has_rdoc:
|