swa 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +11 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/swa +10 -0
- data/lib/swa.rb +5 -0
- data/lib/swa/cli/base_command.rb +65 -0
- data/lib/swa/cli/collection_behaviour.rb +33 -0
- data/lib/swa/cli/ec2_command.rb +169 -0
- data/lib/swa/cli/filter_options.rb +35 -0
- data/lib/swa/cli/item_behaviour.rb +31 -0
- data/lib/swa/cli/main_command.rb +14 -0
- data/lib/swa/cli/tag_filter_options.rb +40 -0
- data/lib/swa/data_presentation.rb +33 -0
- data/lib/swa/ec2/collection_behaviour.rb +29 -0
- data/lib/swa/ec2/image.rb +29 -0
- data/lib/swa/ec2/instance.rb +34 -0
- data/lib/swa/ec2/key_pair.rb +22 -0
- data/lib/swa/ec2/security_group.rb +28 -0
- data/lib/swa/ec2/tagged_resource.rb +17 -0
- data/lib/swa/resource.rb +26 -0
- data/lib/swa/version.rb +3 -0
- data/swa.gemspec +32 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b98869bb46cdaa1706e8e104f235b08d0e716b3f
|
4
|
+
data.tar.gz: 906a6c395ca7356437a299e168cdeaf34211326c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c906663672e41e702ae0b2e95bb533e05fe85c40a85759b25a529784eda5f111a5beff66a937e45399038561a74829f57d5cea0bf861f2681561c8ec57200fad
|
7
|
+
data.tar.gz: 9bf329852348b044046a3d45178b460122195074389738d28765ae68cf401f925902b2a716c2070036704eaef12a3614664294a42885c6386b10346923b5797e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Mike Williams
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# SWA
|
2
|
+
|
3
|
+
It's an alternative CLI for AWS.
|
4
|
+
|
5
|
+
## Contributing
|
6
|
+
|
7
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/swa.
|
8
|
+
|
9
|
+
## License
|
10
|
+
|
11
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "swa"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/swa
ADDED
data/lib/swa.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require "clamp"
|
2
|
+
require "console_logger"
|
3
|
+
require "jmespath"
|
4
|
+
require "multi_json"
|
5
|
+
require "yaml"
|
6
|
+
|
7
|
+
module Swa
|
8
|
+
module CLI
|
9
|
+
|
10
|
+
class BaseCommand < Clamp::Command
|
11
|
+
|
12
|
+
option ["--region"], "REGION", "AWS region"
|
13
|
+
option "--access-key", "KEY", "AWS access key",
|
14
|
+
:attribute_name => :access_key_id
|
15
|
+
option "--secret-key", "KEY", "AWS secret key",
|
16
|
+
:attribute_name => :secret_access_key
|
17
|
+
option "--session-token", "KEY", "AWS security token",
|
18
|
+
:attribute_name => :session_token
|
19
|
+
|
20
|
+
option ["-Y", "--yaml"], :flag, "output data in YAML format"
|
21
|
+
|
22
|
+
option ["--debug"], :flag, "enable debugging"
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def logger
|
27
|
+
@logger ||= ConsoleLogger.new($stderr, debug?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def aws_config
|
31
|
+
{
|
32
|
+
:access_key_id => access_key_id,
|
33
|
+
:secret_access_key => secret_access_key,
|
34
|
+
:session_token => session_token,
|
35
|
+
:region => region,
|
36
|
+
:logger => logger, :log_level => :debug
|
37
|
+
}.reject { |_k, v| v.nil? }
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse(arguments)
|
41
|
+
if arguments.first =~ /^(\w+)-[0-9a-f]+$/
|
42
|
+
arguments = [$1] + arguments if self.class.find_subcommand($1)
|
43
|
+
end
|
44
|
+
super(arguments)
|
45
|
+
end
|
46
|
+
|
47
|
+
def format_data(data)
|
48
|
+
if yaml?
|
49
|
+
YAML.dump(data)
|
50
|
+
else
|
51
|
+
MultiJson.dump(data, :pretty => true)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def display_data(data, jmespath_expression = nil)
|
56
|
+
unless jmespath_expression.nil?
|
57
|
+
data = JMESPath.search(jmespath_expression, data)
|
58
|
+
end
|
59
|
+
puts format_data(data)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Swa
|
2
|
+
module CLI
|
3
|
+
|
4
|
+
module CollectionBehaviour
|
5
|
+
|
6
|
+
def self.included(target)
|
7
|
+
|
8
|
+
target.default_subcommand = "summary"
|
9
|
+
|
10
|
+
target.subcommand ["summary", "s"], "brief summary (one per line)" do
|
11
|
+
def execute
|
12
|
+
collection.each do |i|
|
13
|
+
puts i.summary
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
target.subcommand ["data", "d"], "full details" do
|
19
|
+
|
20
|
+
parameter "[QUERY]", "JMESPath expression"
|
21
|
+
|
22
|
+
def execute
|
23
|
+
display_data(collection.map(&:data).to_a, query)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,169 @@
|
|
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/cli/tag_filter_options"
|
6
|
+
require "swa/ec2/key_pair"
|
7
|
+
require "swa/ec2/image"
|
8
|
+
require "swa/ec2/instance"
|
9
|
+
require "swa/ec2/security_group"
|
10
|
+
|
11
|
+
module Swa
|
12
|
+
module CLI
|
13
|
+
|
14
|
+
class Ec2Command < BaseCommand
|
15
|
+
|
16
|
+
subcommand ["key-pair", "kp"], "show key-pair" do
|
17
|
+
|
18
|
+
parameter "NAME", "key-pair name"
|
19
|
+
|
20
|
+
include ItemBehaviour
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def key_pair
|
25
|
+
Swa::EC2::KeyPair.new(ec2.key_pair(name))
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method :item, :key_pair
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
subcommand ["key-pairs", "kps"], "list key-pairs" do
|
33
|
+
|
34
|
+
include CollectionBehaviour
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def key_pairs
|
39
|
+
Swa::EC2::KeyPair.list(ec2.key_pairs)
|
40
|
+
end
|
41
|
+
|
42
|
+
alias_method :collection, :key_pairs
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
subcommand ["image", "ami"], "show image" do
|
47
|
+
|
48
|
+
parameter "IMAGE-ID", "image id"
|
49
|
+
|
50
|
+
include ItemBehaviour
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def image
|
55
|
+
Swa::EC2::Image.new(ec2.image(image_id))
|
56
|
+
end
|
57
|
+
|
58
|
+
alias_method :item, :image
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
subcommand ["images", "amis"], "list images" do
|
63
|
+
|
64
|
+
option "--owned-by", "OWNER", "limit to those with selected owner", :default => "self"
|
65
|
+
option "--named", "PATTERN", "limit to those with matching name"
|
66
|
+
|
67
|
+
include TagFilterOptions
|
68
|
+
include CollectionBehaviour
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def named=(name_pattern)
|
73
|
+
add_filter("name", name_pattern)
|
74
|
+
end
|
75
|
+
|
76
|
+
def images
|
77
|
+
options = {
|
78
|
+
:owners => [owned_by]
|
79
|
+
}
|
80
|
+
options[:filters] = filters unless filters.empty?
|
81
|
+
Swa::EC2::Image.list(ec2.images(options))
|
82
|
+
end
|
83
|
+
|
84
|
+
alias_method :collection, :images
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
subcommand ["instance", "i"], "show instance" do
|
89
|
+
|
90
|
+
parameter "INSTANCE-ID", "instance id"
|
91
|
+
|
92
|
+
include ItemBehaviour
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def instance
|
97
|
+
Swa::EC2::Instance.new(ec2.instance(instance_id))
|
98
|
+
end
|
99
|
+
|
100
|
+
alias_method :item, :instance
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
subcommand ["instances", "is"], "list instances" do
|
105
|
+
|
106
|
+
option "--named", "NAME", "with matching name"
|
107
|
+
|
108
|
+
include TagFilterOptions
|
109
|
+
include CollectionBehaviour
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def named=(name)
|
114
|
+
add_tag_filter("Name", name)
|
115
|
+
end
|
116
|
+
|
117
|
+
def instances
|
118
|
+
options = {}
|
119
|
+
options[:filters] = filters unless filters.empty?
|
120
|
+
Swa::EC2::Instance.list(ec2.instances(options))
|
121
|
+
end
|
122
|
+
|
123
|
+
alias_method :collection, :instances
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
subcommand ["security-group", "sg"], "show security-group" do
|
128
|
+
|
129
|
+
parameter "GROUP-ID", "security-group id"
|
130
|
+
|
131
|
+
include ItemBehaviour
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def security_group
|
136
|
+
Swa::EC2::SecurityGroup.new(ec2.security_group(group_id))
|
137
|
+
end
|
138
|
+
|
139
|
+
alias_method :item, :security_group
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
subcommand ["security-groups", "sgs"], "list security-groups" do
|
144
|
+
|
145
|
+
include TagFilterOptions
|
146
|
+
include CollectionBehaviour
|
147
|
+
|
148
|
+
private
|
149
|
+
|
150
|
+
def security_groups
|
151
|
+
options = {}
|
152
|
+
options[:filters] = filters unless filters.empty?
|
153
|
+
Swa::EC2::SecurityGroup.list(ec2.security_groups(options))
|
154
|
+
end
|
155
|
+
|
156
|
+
alias_method :collection, :security_groups
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
protected
|
161
|
+
|
162
|
+
def ec2
|
163
|
+
::Aws::EC2::Resource.new(aws_config)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "clamp"
|
2
|
+
|
3
|
+
module Swa
|
4
|
+
module CLI
|
5
|
+
|
6
|
+
module FilterOptions
|
7
|
+
|
8
|
+
extend Clamp::Option::Declaration
|
9
|
+
|
10
|
+
option "--filter", "NAME=VALUE", "apply a filter",
|
11
|
+
:multivalued => true, :attribute_name => :filters
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def filters
|
16
|
+
@filters ||= []
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_filter(name, *values)
|
20
|
+
filters << {
|
21
|
+
name: name,
|
22
|
+
values: values
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def append_to_filters(arg)
|
27
|
+
name, value = arg.split("=", 2)
|
28
|
+
raise ArgumentError, "no value supplied" unless value
|
29
|
+
add_filter(name, value)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Swa
|
2
|
+
module CLI
|
3
|
+
|
4
|
+
module ItemBehaviour
|
5
|
+
|
6
|
+
def self.included(target)
|
7
|
+
|
8
|
+
target.default_subcommand = "summary"
|
9
|
+
|
10
|
+
target.subcommand ["summary", "s"], "brief summary (one per line)" do
|
11
|
+
def execute
|
12
|
+
puts item.summary
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
target.subcommand ["data", "d"], "full details" do
|
17
|
+
|
18
|
+
parameter "[QUERY]", "JMESPath expression"
|
19
|
+
|
20
|
+
def execute
|
21
|
+
display_data(item.data, query)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "swa/cli/filter_options"
|
2
|
+
|
3
|
+
module Swa
|
4
|
+
module CLI
|
5
|
+
|
6
|
+
module TagFilterOptions
|
7
|
+
|
8
|
+
extend Clamp::Option::Declaration
|
9
|
+
|
10
|
+
include FilterOptions
|
11
|
+
|
12
|
+
option "--tagged", "KEY[=VALUE]", "with matching tag",
|
13
|
+
:multivalued => true, :attribute_name => :tag_list
|
14
|
+
option "--stack", "NAME", "from the named CloudFormation stack"
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def append_to_tag_list(arg)
|
19
|
+
key, value_pattern = arg.split("=", 2)
|
20
|
+
add_tag_filter(key, value_pattern)
|
21
|
+
end
|
22
|
+
|
23
|
+
def stack=(name)
|
24
|
+
add_tag_filter("aws:cloudformation:stack-name", name)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def add_tag_filter(key, value_pattern = nil)
|
30
|
+
if value_pattern
|
31
|
+
add_filter("tag:#{key}", value_pattern)
|
32
|
+
else
|
33
|
+
add_filter("tag-key", key)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Swa
|
2
|
+
|
3
|
+
module DataPresentation
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def quoted(value)
|
8
|
+
%("#{value}") if value
|
9
|
+
end
|
10
|
+
|
11
|
+
def pad(s, width)
|
12
|
+
s = (s || "").to_s
|
13
|
+
s.ljust(width)
|
14
|
+
end
|
15
|
+
|
16
|
+
def camelize_keys(data)
|
17
|
+
case data
|
18
|
+
when Hash
|
19
|
+
data.map { |k,v| [camelize(k), camelize_keys(v)] }.to_h
|
20
|
+
when Array
|
21
|
+
data.map { |v| camelize_keys(v) }
|
22
|
+
else
|
23
|
+
data
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def camelize(symbol)
|
28
|
+
symbol.to_s.split("_").map(&:capitalize).join("")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Swa
|
2
|
+
module CLI
|
3
|
+
|
4
|
+
module CollectionBehaviour
|
5
|
+
|
6
|
+
def self.included(target)
|
7
|
+
|
8
|
+
target.default_subcommand = "summary"
|
9
|
+
|
10
|
+
target.subcommand ["summary", "s"], "brief summary (one per line)" do
|
11
|
+
def execute
|
12
|
+
collection.each do |i|
|
13
|
+
puts i.summary
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
target.subcommand ["detail", "d"], "full details" do
|
19
|
+
def execute
|
20
|
+
display_data(collection.map(&:data).to_a)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "swa/resource"
|
2
|
+
require "swa/ec2/tagged_resource"
|
3
|
+
|
4
|
+
module Swa
|
5
|
+
module EC2
|
6
|
+
|
7
|
+
class Image < Resource
|
8
|
+
|
9
|
+
include TaggedResource
|
10
|
+
|
11
|
+
def summary
|
12
|
+
[
|
13
|
+
pad(ami.image_id, 13),
|
14
|
+
quoted(name)
|
15
|
+
].join(" ")
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
ami.name
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
alias_method :ami, :aws_resource
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "swa/resource"
|
2
|
+
require "swa/ec2/tagged_resource"
|
3
|
+
|
4
|
+
module Swa
|
5
|
+
module EC2
|
6
|
+
|
7
|
+
class Instance < Resource
|
8
|
+
|
9
|
+
include TaggedResource
|
10
|
+
|
11
|
+
def summary
|
12
|
+
[
|
13
|
+
pad(i.instance_id, 11),
|
14
|
+
pad(i.image_id, 13),
|
15
|
+
pad(i.instance_type, 10),
|
16
|
+
pad(i.state.name, 11),
|
17
|
+
pad(i.private_ip_address, 15),
|
18
|
+
pad(i.public_ip_address, 15),
|
19
|
+
quoted(name)
|
20
|
+
].join(" ")
|
21
|
+
end
|
22
|
+
|
23
|
+
def name
|
24
|
+
tags["Name"]
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
alias_method :i, :aws_resource
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "swa/resource"
|
2
|
+
|
3
|
+
module Swa
|
4
|
+
module EC2
|
5
|
+
|
6
|
+
class KeyPair < Resource
|
7
|
+
|
8
|
+
def summary
|
9
|
+
[
|
10
|
+
pad(name, 45),
|
11
|
+
aws_resource.key_fingerprint
|
12
|
+
].join(" ")
|
13
|
+
end
|
14
|
+
|
15
|
+
def name
|
16
|
+
aws_resource.name
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "swa/ec2/tagged_resource"
|
2
|
+
require "swa/resource"
|
3
|
+
|
4
|
+
module Swa
|
5
|
+
module EC2
|
6
|
+
|
7
|
+
class SecurityGroup < Resource
|
8
|
+
|
9
|
+
def summary
|
10
|
+
[
|
11
|
+
pad(sg.group_id, 12),
|
12
|
+
pad(sg.vpc_id, 13),
|
13
|
+
quoted(sg.group_name)
|
14
|
+
].join(" ")
|
15
|
+
end
|
16
|
+
|
17
|
+
def name
|
18
|
+
aws_resource.name
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
alias_method :sg, :aws_resource
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/swa/resource.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "swa/data_presentation"
|
2
|
+
|
3
|
+
module Swa
|
4
|
+
|
5
|
+
class Resource
|
6
|
+
|
7
|
+
def self.list(aws_resources)
|
8
|
+
aws_resources.lazy.map(&method(:new))
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(aws_resource)
|
12
|
+
@aws_resource = aws_resource
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :aws_resource
|
16
|
+
alias_method :_resource_, :aws_resource
|
17
|
+
|
18
|
+
include DataPresentation
|
19
|
+
|
20
|
+
def data
|
21
|
+
camelize_keys(_resource_.data.to_h)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/swa/version.rb
ADDED
data/swa.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'swa/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
|
8
|
+
spec.name = "swa"
|
9
|
+
spec.version = Swa::VERSION
|
10
|
+
spec.authors = ["Mike Williams"]
|
11
|
+
spec.email = ["mdub@dogbiscuit.org"]
|
12
|
+
|
13
|
+
spec.summary = %q{AWS, backwards}
|
14
|
+
|
15
|
+
spec.homepage = "https://github.com/mdub/swa"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "aws-sdk-resources"
|
28
|
+
spec.add_runtime_dependency "clamp"
|
29
|
+
spec.add_runtime_dependency "console_logger"
|
30
|
+
spec.add_runtime_dependency "multi_json"
|
31
|
+
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: swa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk-resources
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: clamp
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: console_logger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: multi_json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- mdub@dogbiscuit.org
|
114
|
+
executables:
|
115
|
+
- swa
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- exe/swa
|
129
|
+
- lib/swa.rb
|
130
|
+
- lib/swa/cli/base_command.rb
|
131
|
+
- lib/swa/cli/collection_behaviour.rb
|
132
|
+
- lib/swa/cli/ec2_command.rb
|
133
|
+
- lib/swa/cli/filter_options.rb
|
134
|
+
- lib/swa/cli/item_behaviour.rb
|
135
|
+
- lib/swa/cli/main_command.rb
|
136
|
+
- lib/swa/cli/tag_filter_options.rb
|
137
|
+
- lib/swa/data_presentation.rb
|
138
|
+
- lib/swa/ec2/collection_behaviour.rb
|
139
|
+
- lib/swa/ec2/image.rb
|
140
|
+
- lib/swa/ec2/instance.rb
|
141
|
+
- lib/swa/ec2/key_pair.rb
|
142
|
+
- lib/swa/ec2/security_group.rb
|
143
|
+
- lib/swa/ec2/tagged_resource.rb
|
144
|
+
- lib/swa/resource.rb
|
145
|
+
- lib/swa/version.rb
|
146
|
+
- swa.gemspec
|
147
|
+
homepage: https://github.com/mdub/swa
|
148
|
+
licenses:
|
149
|
+
- MIT
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.5.1
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: AWS, backwards
|
171
|
+
test_files: []
|