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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f12dda287cfa2d61280b785833d6e3c7a975b45a
4
- data.tar.gz: 94e2c24cbc54c445f366c4d0b17fb9353c1f1d60
3
+ metadata.gz: 9de77c555253db18fb3501a860fd378a2285ae7e
4
+ data.tar.gz: 9874f168edca11bab394839f8a85426bc92aa9eb
5
5
  SHA512:
6
- metadata.gz: f75d87b5e49abacb9e265993ab5c25e35d621071a3bea27efe5d672d61b3a8e72205726ee37c4c9cf71e90669f4de29344451e70855303cb266916171cbd605b
7
- data.tar.gz: 0c9349f38bea59b25f790b7529f60f5f6d438916f5ca9fe552d431149b3b4a6604cb9d85037ed17386eb026b53eeb1350ee4944576fc4cd8fab82b17232d4c55
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
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.60"
2
+ VERSION = "0.0.61"
3
3
  end
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.60
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-04 00:00:00.000000000 Z
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: