swa 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/swa/cli/ec2_command.rb +34 -34
- data/lib/swa/cli/iam_command.rb +157 -0
- data/lib/swa/cli/main_command.rb +2 -0
- data/lib/swa/iam/group.rb +19 -0
- data/lib/swa/iam/policy.rb +27 -0
- data/lib/swa/iam/role.rb +19 -0
- data/lib/swa/iam/user.rb +19 -0
- data/lib/swa/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dc9fcd21e4fbd399ce0a2437fe6a054d4c41495
|
4
|
+
data.tar.gz: 00ac4e5e34e55def411589f177db392db456e22c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dba4cb585a4e6761c1dc9cdfb34ed8b229d0cef5b0eb693285efde74cf92758f06d95febe86ef836a5584a598c85e3be35e561ce9004f34f1d45a86809c80649
|
7
|
+
data.tar.gz: bf783e3b8ec3aa1c66a5a4722d2dede644e2d4292b27eefb5de2d39cad26ce17094b0cf094f1934e857634ab631e163a05d243d499fe4e58d1bb3c5a59ff1011
|
data/README.md
CHANGED
@@ -50,6 +50,17 @@ But you can ask for **all** the data, if you wish:
|
|
50
50
|
|
51
51
|
Specify `-J` if you like JSON better than YAML.
|
52
52
|
|
53
|
+
You can specify a [JMESPath](http://jmespath.org) to extract a subset of the data:
|
54
|
+
|
55
|
+
$ swa ec2 instances data '[].{Id:InstanceId,Profile:IamInstanceProfile.Id}'
|
56
|
+
---
|
57
|
+
- Id: i-7f5495ae
|
58
|
+
Profile: AIPAIDOQKT66MFXRO5BPS
|
59
|
+
- Id: i-9c539e4d
|
60
|
+
Profile: AIPAIRT5GOEJ2ZMVPGGD6
|
61
|
+
- Id: i-fbeda3be
|
62
|
+
Profile: AIPAIZXZFLTUW6L456LFU
|
63
|
+
|
53
64
|
## Inspecting things
|
54
65
|
|
55
66
|
Each "collection" operation has a corresponding "item" operation, e.g.
|
data/lib/swa/cli/ec2_command.rb
CHANGED
@@ -17,40 +17,6 @@ module Swa
|
|
17
17
|
|
18
18
|
class Ec2Command < BaseCommand
|
19
19
|
|
20
|
-
subcommand ["key-pair", "kp"], "Show key-pair" do
|
21
|
-
|
22
|
-
parameter "NAME", "key-pair name"
|
23
|
-
|
24
|
-
include ItemBehaviour
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def key_pair
|
29
|
-
Swa::EC2::KeyPair.new(ec2.key_pair(name))
|
30
|
-
end
|
31
|
-
|
32
|
-
alias_method :item, :key_pair
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
subcommand ["key-pairs", "kps"], "List key-pairs" do
|
37
|
-
|
38
|
-
self.description = <<-EOF
|
39
|
-
List key-pairs.
|
40
|
-
EOF
|
41
|
-
|
42
|
-
include CollectionBehaviour
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def key_pairs
|
47
|
-
query_for(:key_pairs, Swa::EC2::KeyPair)
|
48
|
-
end
|
49
|
-
|
50
|
-
alias_method :collection, :key_pairs
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
20
|
subcommand ["image", "ami"], "Show image" do
|
55
21
|
|
56
22
|
parameter "IMAGE-ID", "image id"
|
@@ -219,6 +185,40 @@ module Swa
|
|
219
185
|
|
220
186
|
end
|
221
187
|
|
188
|
+
subcommand ["key-pair", "kp"], "Show key-pair" do
|
189
|
+
|
190
|
+
parameter "NAME", "key-pair name"
|
191
|
+
|
192
|
+
include ItemBehaviour
|
193
|
+
|
194
|
+
private
|
195
|
+
|
196
|
+
def key_pair
|
197
|
+
Swa::EC2::KeyPair.new(ec2.key_pair(name))
|
198
|
+
end
|
199
|
+
|
200
|
+
alias_method :item, :key_pair
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
subcommand ["key-pairs", "kps"], "List key-pairs" do
|
205
|
+
|
206
|
+
self.description = <<-EOF
|
207
|
+
List key-pairs.
|
208
|
+
EOF
|
209
|
+
|
210
|
+
include CollectionBehaviour
|
211
|
+
|
212
|
+
private
|
213
|
+
|
214
|
+
def key_pairs
|
215
|
+
query_for(:key_pairs, Swa::EC2::KeyPair)
|
216
|
+
end
|
217
|
+
|
218
|
+
alias_method :collection, :key_pairs
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
222
|
subcommand ["security-group", "sg"], "Show security-group" do
|
223
223
|
|
224
224
|
parameter "GROUP-ID", "security-group id"
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require "aws-sdk-resources"
|
2
|
+
require "swa/cli/base_command"
|
3
|
+
require "swa/cli/collection_behaviour"
|
4
|
+
require "swa/cli/item_behaviour"
|
5
|
+
require "swa/iam/group"
|
6
|
+
require "swa/iam/policy"
|
7
|
+
require "swa/iam/role"
|
8
|
+
require "swa/iam/user"
|
9
|
+
|
10
|
+
module Swa
|
11
|
+
module CLI
|
12
|
+
|
13
|
+
class IamCommand < BaseCommand
|
14
|
+
|
15
|
+
subcommand ["group"], "Show group" do
|
16
|
+
|
17
|
+
parameter "NAME", "group name/ARN"
|
18
|
+
|
19
|
+
include ItemBehaviour
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def item
|
24
|
+
Swa::IAM::Group.new(iam.group(File.basename(name)))
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
subcommand ["groups"], "Show groups" do
|
30
|
+
|
31
|
+
self.description = <<-EOF
|
32
|
+
List groups.
|
33
|
+
EOF
|
34
|
+
|
35
|
+
include CollectionBehaviour
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def collection
|
40
|
+
query_for(:groups, Swa::IAM::Group)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
subcommand ["policy"], "Show policy" do
|
46
|
+
|
47
|
+
parameter "ARN", "policy ARN"
|
48
|
+
|
49
|
+
include ItemBehaviour
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def item
|
54
|
+
Swa::IAM::Policy.new(iam.policy(arn))
|
55
|
+
end
|
56
|
+
|
57
|
+
subcommand "document", "print current policy document" do
|
58
|
+
|
59
|
+
def execute
|
60
|
+
puts item.document
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
subcommand ["policies"], "Show policies" do
|
68
|
+
|
69
|
+
self.description = <<-EOF
|
70
|
+
List policies.
|
71
|
+
EOF
|
72
|
+
|
73
|
+
include CollectionBehaviour
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def collection
|
78
|
+
query_for(:policies, Swa::IAM::Policy)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
subcommand ["role"], "Show role" do
|
84
|
+
|
85
|
+
parameter "NAME", "role name/ARN"
|
86
|
+
|
87
|
+
include ItemBehaviour
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def item
|
92
|
+
Swa::IAM::Role.new(iam.role(File.basename(name)))
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
subcommand ["roles"], "Show roles" do
|
98
|
+
|
99
|
+
self.description = <<-EOF
|
100
|
+
List roles.
|
101
|
+
EOF
|
102
|
+
|
103
|
+
include CollectionBehaviour
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def collection
|
108
|
+
query_for(:roles, Swa::IAM::Role)
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
subcommand ["user"], "Show user" do
|
114
|
+
|
115
|
+
parameter "NAME", "user name/ARN"
|
116
|
+
|
117
|
+
include ItemBehaviour
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def item
|
122
|
+
Swa::IAM::User.new(iam.user(File.basename(name)))
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
subcommand ["users"], "Show users" do
|
128
|
+
|
129
|
+
self.description = <<-EOF
|
130
|
+
List users.
|
131
|
+
EOF
|
132
|
+
|
133
|
+
include CollectionBehaviour
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def collection
|
138
|
+
query_for(:users, Swa::IAM::User)
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
protected
|
144
|
+
|
145
|
+
def iam
|
146
|
+
::Aws::IAM::Resource.new(aws_config)
|
147
|
+
end
|
148
|
+
|
149
|
+
def query_for(query_method, resource_model)
|
150
|
+
aws_resources = iam.public_send(query_method)
|
151
|
+
wrapped_resources = resource_model.list(aws_resources)
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
data/lib/swa/cli/main_command.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "swa/cli/base_command"
|
2
2
|
require "swa/cli/ec2_command"
|
3
|
+
require "swa/cli/iam_command"
|
3
4
|
|
4
5
|
module Swa
|
5
6
|
module CLI
|
@@ -7,6 +8,7 @@ module Swa
|
|
7
8
|
class MainCommand < BaseCommand
|
8
9
|
|
9
10
|
subcommand "ec2", "EC2 stuff", Ec2Command
|
11
|
+
subcommand "iam", "IAM stuff", IamCommand
|
10
12
|
|
11
13
|
end
|
12
14
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "cgi"
|
2
|
+
require "swa/resource"
|
3
|
+
|
4
|
+
module Swa
|
5
|
+
module IAM
|
6
|
+
|
7
|
+
class Policy < Resource
|
8
|
+
|
9
|
+
def summary
|
10
|
+
[
|
11
|
+
pad(policy.arn, 60),
|
12
|
+
quoted(policy.description)
|
13
|
+
].join(" ")
|
14
|
+
end
|
15
|
+
|
16
|
+
def document
|
17
|
+
CGI.unescape(policy.default_version.document)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
alias_method :policy, :aws_resource
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/swa/iam/role.rb
ADDED
data/lib/swa/iam/user.rb
ADDED
data/lib/swa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/swa/cli/data_output.rb
|
147
147
|
- lib/swa/cli/ec2_command.rb
|
148
148
|
- lib/swa/cli/filter_options.rb
|
149
|
+
- lib/swa/cli/iam_command.rb
|
149
150
|
- lib/swa/cli/item_behaviour.rb
|
150
151
|
- lib/swa/cli/main_command.rb
|
151
152
|
- lib/swa/cli/selector.rb
|
@@ -160,6 +161,10 @@ files:
|
|
160
161
|
- lib/swa/ec2/tagged_resource.rb
|
161
162
|
- lib/swa/ec2/volume.rb
|
162
163
|
- lib/swa/ec2/vpc.rb
|
164
|
+
- lib/swa/iam/group.rb
|
165
|
+
- lib/swa/iam/policy.rb
|
166
|
+
- lib/swa/iam/role.rb
|
167
|
+
- lib/swa/iam/user.rb
|
163
168
|
- lib/swa/resource.rb
|
164
169
|
- lib/swa/version.rb
|
165
170
|
- swa.gemspec
|