Class: Awful::IAM
- Inherits:
-
Cli
- Object
- Thor
- Cli
- Awful::IAM
show all
- Defined in:
- lib/awful/iam.rb
Instance Method Summary
collapse
Methods inherited from Cli
#initialize
Constructor Details
This class inherits a constructor from Awful::Cli
Instance Method Details
#certificates(name = /./) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/awful/iam.rb', line 13
def certificates(name = /./)
iam.list_server_certificates.server_certificate_metadata_list.select do |cert|
cert.server_certificate_name.match(name)
end.tap do |certs|
if options[:long]
print_table certs.map { |c|
[
c.server_certificate_name,
c.server_certificate_id,
c.arn,
c.upload_date,
c.expiration,
]
}.sort
else
puts certs.map(&:server_certificate_name).sort
end
end
end
|
#policy(type, name, policy = nil) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/awful/iam.rb', line 58
def policy(type, name, policy = nil)
thing_name = iam.send("list_#{type}s").send("#{type}s").find do |thing|
thing.send("#{type}_name").match(name)
end.send("#{type}_name")
policies = iam.send("list_#{type}_policies", "#{type}_name".to_sym => thing_name).policy_names
if policy.nil? policies.tap(&method(:puts))
else policy_name = policies.find { |p| p.match(/#{policy}/i) }
doc = iam.send("get_#{type}_policy", "#{type}_name".to_sym => thing_name, policy_name: policy_name).policy_document
URI.unescape(doc).tap do |str|
if options[:pretty]
puts JSON.pretty_generate(JSON.parse(str))
else
puts str
end
end
end
end
|
#roles(name = /./) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/awful/iam.rb', line 36
def roles(name = /./)
iam.list_roles.roles.select do |role|
role.role_name.match(name)
end.tap do |roles|
name_method = options[:arns] ? :arn : :role_name
if options[:long]
print_table roles.map { |r|
[
r.send(name_method),
r.role_id,
r.create_date,
options[:arns] ? r.arn : nil
]
}
else
puts roles.map(&name_method)
end
end
end
|