awx 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aws/aws_cache.rb +53 -0
- data/lib/aws/aws_cli.rb +166 -0
- data/lib/aws/aws_cloudformation.rb +68 -0
- data/lib/aws/aws_config.rb +39 -0
- data/lib/aws/aws_credentials.rb +9 -0
- data/lib/aws/aws_outputter.rb +247 -0
- data/lib/aws/aws_reports.rb +271 -0
- data/lib/aws/aws_validator.rb +30 -0
- data/lib/awx.rb +65 -71
- data/lib/core/config.rb +127 -0
- data/lib/core/config_unique.rb +64 -0
- data/lib/core/opt.rb +17 -0
- data/lib/routes/aws_cloudformation_create.rb +732 -0
- data/lib/routes/aws_cloudformation_delete.rb +37 -0
- data/lib/routes/aws_cloudformation_detect_drift.rb +44 -0
- data/lib/routes/aws_lambda.rb +122 -0
- data/lib/routes/aws_list.rb +234 -0
- data/lib/routes/setup.rb +31 -0
- data/lib/version.rb +1 -1
- data/opt/yml/aws-reports.yml +113 -0
- metadata +28 -10
@@ -0,0 +1,271 @@
|
|
1
|
+
module App
|
2
|
+
|
3
|
+
class AWSReports
|
4
|
+
|
5
|
+
CONST_ALL = 'all'
|
6
|
+
CONST_GLOBAL = 'Global'
|
7
|
+
KEY_CLI = 'cli'
|
8
|
+
KEY_COLUMNS = 'columns'
|
9
|
+
KEY_COMMAND = 'command'
|
10
|
+
KEY_EXPORT = 'export'
|
11
|
+
KEY_REGION = 'region'
|
12
|
+
KEY_REGIONS = 'regions'
|
13
|
+
KEY_REGIONS_PREFERRED = 'regionsPreferred'
|
14
|
+
|
15
|
+
YML_FILE = 'aws-reports.yml'
|
16
|
+
|
17
|
+
# Parses the YML file and returns a bunch of Hashes. Throws straight-up runtime errors if something is wrong.
|
18
|
+
# @return void
|
19
|
+
def self.parse_metadata(regions)
|
20
|
+
|
21
|
+
yml_file = "#{App::Opt::get_base_path}#{App::Opt::OPT_PATH_YML}/#{YML_FILE}"
|
22
|
+
Blufin::Terminal::error("File not found: #{Blufin::Terminal::format_directory(yml_file)}", 'This file should be located in the /opt folder of the my (ruby-gem) source-code.', true) unless Blufin::Files::file_exists(yml_file)
|
23
|
+
|
24
|
+
columns = {}
|
25
|
+
table_widths = {}
|
26
|
+
export_map = {}
|
27
|
+
|
28
|
+
begin
|
29
|
+
data = YAML.load_file(File.expand_path(yml_file))
|
30
|
+
rescue => e
|
31
|
+
Blufin::Terminal::error("Unable to parse #{Blufin::Terminal::format_action('YML')} file: #{Blufin::Terminal::format_directory(yml_file)}", e.message, true)
|
32
|
+
end
|
33
|
+
|
34
|
+
data.each do |resource, data|
|
35
|
+
|
36
|
+
# Validates keys (generically).
|
37
|
+
{
|
38
|
+
KEY_REGIONS => [],
|
39
|
+
KEY_REGIONS_PREFERRED => [],
|
40
|
+
KEY_CLI => %w(command root)
|
41
|
+
}.each do |required_key, required_nested_keys|
|
42
|
+
raise RuntimeError, "Missing key: #{required_key} for \xe2\x86\x92 #{resource}" unless data.has_key?(required_key)
|
43
|
+
required_nested_keys.each do |required_nested_key|
|
44
|
+
raise RuntimeError, "Missing key: #{required_key}.#{required_nested_key} for \xe2\x86\x92 #{resource}" unless data[required_key].has_key?(required_nested_key)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Validate regions.
|
49
|
+
validate_region_array(regions, data[KEY_REGIONS], resource) if data.has_key?(KEY_REGIONS)
|
50
|
+
validate_region_array(regions, data[KEY_REGIONS_PREFERRED], resource) if data.has_key?(KEY_REGIONS_PREFERRED)
|
51
|
+
|
52
|
+
# Validate (and parse) columns.
|
53
|
+
if !data[KEY_COLUMNS].nil? && data[KEY_COLUMNS].any?
|
54
|
+
if data.has_key?(KEY_COLUMNS) && data[KEY_COLUMNS].is_a?(Array)
|
55
|
+
columns[resource] = {} unless columns.has_key?(resource)
|
56
|
+
width_wildcard_count = 0
|
57
|
+
width_total = App::AWSOutputter::REGION_WIDTH # Start with 15 to account for hard-coded region column.
|
58
|
+
columns[resource]['Region'] = {
|
59
|
+
:key => 'region',
|
60
|
+
:width => App::AWSOutputter::REGION_WIDTH,
|
61
|
+
:formatter => 'region'
|
62
|
+
}
|
63
|
+
data[KEY_COLUMNS].each_with_index do |column, idx|
|
64
|
+
title = nil
|
65
|
+
key = nil
|
66
|
+
width = nil
|
67
|
+
color = 'default'
|
68
|
+
formatter = nil
|
69
|
+
column.each do |column_inner|
|
70
|
+
column_inner.each do |k, v|
|
71
|
+
title = v if k == 'title'
|
72
|
+
key = v if k == 'key'
|
73
|
+
width = v if k == 'width'
|
74
|
+
color = v if k == 'color'
|
75
|
+
formatter = v if k == 'formatter'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
['Region'].each do |reserved_column|
|
79
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS}[#{idx}] \xe2\x86\x92 #{reserved_column} is a reserved column." if title.downcase == reserved_column.downcase
|
80
|
+
end
|
81
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS}[#{idx}] \xe2\x86\x92 Missing: title" if title.nil?
|
82
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS}[#{idx}] \xe2\x86\x92 Missing: key" if key.nil?
|
83
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS}[#{idx}] \xe2\x86\x92 Missing: width" if width.nil?
|
84
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS}[#{idx}] \xe2\x86\x92 Title already exists: #{title}" if columns[resource].has_key?(title)
|
85
|
+
raise RuntimeError, "Expected width to be wildcard (*) or Integer greater than 0, instead got: (#{width.class}) #{width}" unless width == '*' || width.is_a?(Integer)
|
86
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS}[#{idx}] \xe2\x86\x92 Title length (#{title.length}) is longer that column-width (#{width}) : #{title}" if title.length > width.to_i && width.to_s.strip != '*'
|
87
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS}[#{idx}] \xe2\x86\x92 Formatter not recognized: #{formatter}, valid formatters are: #{App::AWSOutputter::get_formatter.join(', ')}" unless App::AWSOutputter::get_formatter.include?(formatter) || formatter.nil?
|
88
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS}[#{idx}] \xe2\x86\x92 Color not recognized: #{color}, valid colors are: #{App::AWSOutputter::get_color.join(', ')}" unless App::AWSOutputter::get_color.include?(color)
|
89
|
+
width_wildcard_count = width_wildcard_count + 1 if width == '*'
|
90
|
+
width_total = width_total + width unless width == '*'
|
91
|
+
columns[resource][title] = {
|
92
|
+
:key => key,
|
93
|
+
:width => width,
|
94
|
+
:color => color,
|
95
|
+
:formatter => formatter
|
96
|
+
}
|
97
|
+
end
|
98
|
+
raise RuntimeError, "Wildcard width count must be exactly 1, got: #{width_wildcard_count}" unless width_wildcard_count == 1
|
99
|
+
raise RuntimeError, "#{resource}.#{KEY_COLUMNS} \xe2\x86\x92 Total width of columns (#{width_total}) minus wildcard (*) & region exceeds 210." if width_total > 210
|
100
|
+
table_widths[resource] = width_total
|
101
|
+
end
|
102
|
+
end
|
103
|
+
# Validate Exports.
|
104
|
+
if !data[KEY_EXPORT].nil? && data[KEY_EXPORT].any?
|
105
|
+
raise RuntimeError, "Expected #{Blufin::Terminal::format_highlight('export')} to be a Hash, instead got: #{data[KEY_EXPORT].class}" unless data[KEY_EXPORT].is_a?(Hash)
|
106
|
+
raise RuntimeError, "#{resource}.#{KEY_EXPORT} \xe2\x86\x92 Missing: id" unless data[KEY_EXPORT].has_key?('id')
|
107
|
+
raise RuntimeError, "#{resource}.#{KEY_EXPORT} \xe2\x86\x92 Missing: value" unless data[KEY_EXPORT].has_key?('value')
|
108
|
+
raise RuntimeError, "#{resource}.#{KEY_EXPORT} \xe2\x86\x92 Missing: description" unless data[KEY_EXPORT].has_key?('description')
|
109
|
+
# Make sure formatter exists.
|
110
|
+
App::AWSOutputter::get_formatter(data[KEY_EXPORT]['valueFormatter']) if data[KEY_EXPORT].has_key?('valueFormatter')
|
111
|
+
data[KEY_EXPORT].each { |key, val| raise RuntimeError, "Unexpected key: #{key} (#{val})" unless %w(id value valueFormatter description).include?(key) }
|
112
|
+
export_map[data[KEY_EXPORT]['id']] = resource
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# TODO - Maybe add "custom" resources here for WorkMailEmails and SES Identities, etc. here...?? If so, these need custom logic.
|
117
|
+
|
118
|
+
[columns, data, export_map, table_widths]
|
119
|
+
end
|
120
|
+
|
121
|
+
# This runs the AWS GET and does various things depending on the the flags passed.
|
122
|
+
# @return void
|
123
|
+
def self.get_aws_data(regions, resource, resource_title, silent: false)
|
124
|
+
response = {}
|
125
|
+
results = []
|
126
|
+
threads = []
|
127
|
+
semaphore = Mutex.new
|
128
|
+
regions = resource.has_key?(App::AWSReports::KEY_REGIONS) ? resource[App::AWSReports::KEY_REGIONS] : regions
|
129
|
+
puts unless silent
|
130
|
+
regions.each do |region|
|
131
|
+
response[region] = {} if response[region].nil?
|
132
|
+
sleep(0.01) unless silent
|
133
|
+
threads << Thread.new {
|
134
|
+
cmd = "aws #{resource[App::AWSReports::KEY_CLI][App::AWSReports::KEY_COMMAND]}#{region == App::AWSReports::CONST_GLOBAL ? '' : " --region #{region}"}"
|
135
|
+
puts " \x1B[38;5;70m$ \x1B[38;5;240m#{cmd}\x1B[0m" unless silent
|
136
|
+
json = `#{cmd}`
|
137
|
+
begin
|
138
|
+
semaphore.synchronize do
|
139
|
+
if json.strip == ''
|
140
|
+
response[region] = []
|
141
|
+
else
|
142
|
+
response[region] = JSON.parse(json)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
rescue => e
|
146
|
+
puts json.inspect
|
147
|
+
raise RuntimeError, "JSON parsing (for: #{resource_title}) failed:\n\n#{e.message}"
|
148
|
+
end
|
149
|
+
}
|
150
|
+
end
|
151
|
+
sleep(0.1) unless silent
|
152
|
+
puts unless silent
|
153
|
+
|
154
|
+
# Display spinner while waiting for threads to finish.
|
155
|
+
Blufin::Terminal::execute_proc("AWS - Fetching: #{Blufin::Terminal::format_highlight(resource_title, false)}", Proc.new {
|
156
|
+
threads.each { |thread| thread.join }
|
157
|
+
}, verbose: !silent)
|
158
|
+
puts unless silent
|
159
|
+
|
160
|
+
# Extract the regional response(s) (from multi-calls to different regions) and aggregate into a single Array.
|
161
|
+
root_keys = resource[App::AWSReports::KEY_CLI]['root']
|
162
|
+
|
163
|
+
if resource[App::AWSReports::KEY_REGIONS].length == 1 && resource[App::AWSReports::KEY_REGIONS][0] == App::AWSReports::CONST_GLOBAL
|
164
|
+
results = recursively_get_results(App::AWSReports::CONST_GLOBAL, response[App::AWSReports::CONST_GLOBAL], root_keys)
|
165
|
+
else
|
166
|
+
response.each do |region, regional_response|
|
167
|
+
recursively_get_results(region, regional_response, root_keys).each do |regional_result|
|
168
|
+
results << regional_result
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
results
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns a Hash with all the resources that can be auto-fetched using a script.
|
176
|
+
# @return Hash
|
177
|
+
def self.get_auto_fetch_resources(data)
|
178
|
+
auto_fetch_resources = {}
|
179
|
+
data.each do |resource|
|
180
|
+
if resource[1].has_key?(App::AWSReports::KEY_EXPORT)
|
181
|
+
if resource[1][App::AWSReports::KEY_EXPORT].has_key?('id')
|
182
|
+
auto_fetch_resources[resource[1][App::AWSReports::KEY_EXPORT]['id']] = {
|
183
|
+
:resource_title => resource[0],
|
184
|
+
:resource => resource[1]
|
185
|
+
}
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
auto_fetch_resources
|
190
|
+
end
|
191
|
+
|
192
|
+
# Takes AWS api results and translates it to an array of key/value pairs we can pass to Blufin::Terminal::prompt_select().
|
193
|
+
# @return Array (of Hashes)
|
194
|
+
def self.parse_results_for_prompt(resource, results)
|
195
|
+
options = []
|
196
|
+
values = []
|
197
|
+
results.each do |result|
|
198
|
+
value = result[resource[App::AWSReports::KEY_EXPORT]['value']]
|
199
|
+
value = App::AWSOutputter::get_formatter(resource[App::AWSReports::KEY_EXPORT]['valueFormatter']).call(value)[0] if resource[App::AWSReports::KEY_EXPORT].has_key?('valueFormatter')
|
200
|
+
values << value
|
201
|
+
end
|
202
|
+
results.each do |result|
|
203
|
+
value = result[resource[App::AWSReports::KEY_EXPORT]['value']]
|
204
|
+
value = App::AWSOutputter::get_formatter(resource[App::AWSReports::KEY_EXPORT]['valueFormatter']).call(value)[0] if resource[App::AWSReports::KEY_EXPORT].has_key?('valueFormatter')
|
205
|
+
options << {
|
206
|
+
:value => value,
|
207
|
+
:text => "#{value.rjust(values.max_by(&:length).length.to_i, ' ')} \x1B[38;5;246m\xe2\x80\x94 \x1B[38;5;240m#{result[resource[App::AWSReports::KEY_EXPORT]['description']]}\x1B[0m",
|
208
|
+
}
|
209
|
+
end
|
210
|
+
options
|
211
|
+
end
|
212
|
+
|
213
|
+
private
|
214
|
+
|
215
|
+
# Validates a region array such as ['us-west-1','us-west-2'].
|
216
|
+
# @return void
|
217
|
+
def self.validate_region_array(regions, region_array, resource)
|
218
|
+
has_global = false
|
219
|
+
raise RuntimeError, "#{resource} \xe2\x86\x92 Expected regions to be an Array of Strings, instead got: (#{region_array.class}) #{region_array}" unless region_array.is_a?(Array)
|
220
|
+
region_array.each do |region|
|
221
|
+
raise RuntimeError, "#{resource} \xe2\x86\x92 Expected region to be a String, instead got: (#{region.class}) #{region}" unless region.is_a?(String)
|
222
|
+
raise RuntimeError, "#{resource} \xe2\x86\x92 Invalid region: #{Blufin::Terminal::format_invalid(region)}. Valid regions are: #{regions.inspect}" unless region == App::AWSReports::CONST_GLOBAL || regions.include?(region)
|
223
|
+
has_global = true if region == App::AWSReports::CONST_GLOBAL
|
224
|
+
end
|
225
|
+
raise RuntimeError, "#{resource} \xe2\x86\x92 Cannot have more than 1 region when #{App::AWSReports::KEY_REGIONS} has the #{App::AWSReports::CONST_GLOBAL} key. Found: #{region_array.inspect}" if has_global && region_array.length > 1
|
226
|
+
end
|
227
|
+
|
228
|
+
# Recursively gets results out of the JSON returned by AWS.
|
229
|
+
# @return Array
|
230
|
+
def self.recursively_get_results(region, response, keys)
|
231
|
+
ks = keys.split('.')
|
232
|
+
first_key = ks[0]
|
233
|
+
is_array = first_key != first_key.gsub(/\[\]$/, '')
|
234
|
+
first_key = first_key.gsub(/\[\]$/, '') if is_array
|
235
|
+
results = []
|
236
|
+
if response.is_a?(Hash) || response.is_a?(Array)
|
237
|
+
check_root_key_exists(response, first_key) if response.is_a?(Hash)
|
238
|
+
ks.shift
|
239
|
+
if ks.length == 0
|
240
|
+
response[first_key].each do |result|
|
241
|
+
res = result
|
242
|
+
res[App::AWSReports::KEY_REGION] = region
|
243
|
+
results << res
|
244
|
+
end
|
245
|
+
else
|
246
|
+
if is_array
|
247
|
+
results_aggregate = []
|
248
|
+
response[first_key].each do |x|
|
249
|
+
recursively_get_results(region, x, ks.join('.')).each do |y|
|
250
|
+
results_aggregate << y
|
251
|
+
end
|
252
|
+
end
|
253
|
+
results_aggregate
|
254
|
+
else
|
255
|
+
recursively_get_results(region, response[first_key], ks.join('.')) if response.is_a?(Hash)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
else
|
259
|
+
results
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# Throw error if Root Key not found in response.
|
264
|
+
# @return void
|
265
|
+
def self.check_root_key_exists(data, root_key)
|
266
|
+
Blufin::Terminal::error("Root key not found in AWS response: #{Blufin::Terminal::format_invalid(root_key)}", data.to_yaml.split("\n"), true) unless data.has_key?(root_key)
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module App
|
2
|
+
|
3
|
+
class AWSValidator
|
4
|
+
|
5
|
+
# Helper method to get + validate regions. Probably going to be used in all AWS Cli calls.
|
6
|
+
# @return Array
|
7
|
+
def self.get_and_validate_regions(region_given)
|
8
|
+
regions = App::AWSCli::get_regions
|
9
|
+
if region_given
|
10
|
+
Blufin::Terminal::error("Invalid AWS region \xe2\x86\x92 #{Blufin::Terminal::format_invalid(region_given)}. Valid regions are:", regions) unless App::AWSValidator::validate_region(region_given)
|
11
|
+
@regions << region_given
|
12
|
+
else
|
13
|
+
@regions = regions
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Validates AWS region.
|
18
|
+
# @return boolean
|
19
|
+
def self.validate_region(region)
|
20
|
+
if App::Cache::exists?(App::CacheKey::ARRAY_AWS_REGIONS)
|
21
|
+
valid_regions = App::Cache::get(App::CacheKey::ARRAY_AWS_REGIONS)
|
22
|
+
else
|
23
|
+
valid_regions = App::AWSCli::get_regions
|
24
|
+
end
|
25
|
+
valid_regions.include?(region)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/lib/awx.rb
CHANGED
@@ -5,9 +5,10 @@ require 'blufin-lib'
|
|
5
5
|
|
6
6
|
require_relative 'version'
|
7
7
|
require 'core/config_unique'
|
8
|
-
require '
|
9
|
-
require '
|
8
|
+
require 'aws/aws_config'
|
9
|
+
require 'aws/aws_credentials'
|
10
10
|
|
11
|
+
Dir["#{File.dirname(__FILE__)}/aws/**/*.rb"].each { |file| load(file) unless file =~ /\/(config_unique|aws_config|aws_credentials)\.rb\z/ }
|
11
12
|
Dir["#{File.dirname(__FILE__)}/core/**/*.rb"].each { |file| load(file) unless file =~ /\/(config_unique|aws_config|aws_credentials)\.rb\z/ }
|
12
13
|
Dir["#{File.dirname(__FILE__)}/routes/**/*.rb"].each { |file| load(file) }
|
13
14
|
|
@@ -21,96 +22,87 @@ module App
|
|
21
22
|
App::Config.initialize
|
22
23
|
end
|
23
24
|
|
24
|
-
Convoy::App.create do |
|
25
|
+
Convoy::App.create do |awx|
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
awx.version AWX_VERSION
|
28
|
+
awx.summary "\x1B[38;5;198mAWX\x1B[0m \x1B[38;5;134m\xe2\x80\x94 Amazon Web-Services X-Tender (Beta)\x1B[0m"
|
29
|
+
awx.description 'An abstraction layer built around the AWS-cli (written by: Albert Rannetsperger)'
|
28
30
|
|
29
|
-
|
30
|
-
my.summary "\x1B[38;5;198mMY-CLI\x1B[0m \x1B[38;5;240m\xe2\x80\x94 BETA\x1B[0m"
|
31
|
-
my.description "\x1B[38;5;#{title_color}mA command line utility for myself.\nDesigned to work from anywhere on my mac.\n\nUse #{Blufin::Terminal::format_command('my')}\x1B[38;5;#{title_color}m to run.\x1B[0m"
|
32
|
-
|
33
|
-
# Checks whether a AWS 'blufin-cli' profile exists within ~/.aws ...
|
31
|
+
# Checks whether a AWS 'blufin-cli' profile exists within ~/.awx ...
|
34
32
|
unless App::AWSConfig::get_credentials(App::AWSConfig::AWS_PROFILE_ALBERT_CLI).nil?
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
aws_cloudformation_create.summary 'Create stack'
|
44
|
-
aws_cloudformation_create.options do |opts|
|
45
|
-
opts.opt :test, 'Run through test-template.', :short => '-t', :long => '--test', :type => :boolean
|
46
|
-
end
|
47
|
-
aws_cloudformation_create.action do |opts, args|
|
48
|
-
AppCommand::AWSCloudFormationCreate.new(opts, args).execute
|
49
|
-
end
|
50
|
-
end
|
51
|
-
# d - AWS CLOUD FORMATION DETECT-DRIFT
|
52
|
-
aws_cloudformation.command :detect_drift, :aliases => [:d] do |aws_cloudformation_detect_drift|
|
53
|
-
aws_cloudformation_detect_drift.summary 'Detect drift (for stack)'
|
54
|
-
aws_cloudformation_detect_drift.action do |opts, args|
|
55
|
-
AppCommand::AWSCloudFormationDetectDrift.new(opts, args).execute
|
56
|
-
end
|
33
|
+
# cf - AWS CLOUD FORMATION
|
34
|
+
awx.command :cloudformation, :aliases => [:c] do |awx_cloudformation|
|
35
|
+
awx_cloudformation.summary 'Create, list and delete cloud-formation stacks'
|
36
|
+
# c - AWS CLOUD FORMATION CREATE
|
37
|
+
awx_cloudformation.command :create, :aliases => [:c] do |awx_cloudformation_create|
|
38
|
+
awx_cloudformation_create.summary 'Create stack'
|
39
|
+
awx_cloudformation_create.options do |opts|
|
40
|
+
opts.opt :test, 'Run through test-template.', :short => '-t', :long => '--test', :type => :boolean
|
57
41
|
end
|
58
|
-
|
59
|
-
|
60
|
-
aws_cloudformation_delete.summary 'Delete stack'
|
61
|
-
aws_cloudformation_delete.action do |opts, args|
|
62
|
-
AppCommand::AWSCloudFormationDelete.new(opts, args).execute
|
63
|
-
end
|
64
|
-
end
|
65
|
-
aws_cloudformation.action do
|
66
|
-
system("#{ConfigUnique::GEM_NAME} a c -h")
|
42
|
+
awx_cloudformation_create.action do |opts, args|
|
43
|
+
AppCommand::AWSCloudFormationCreate.new(opts, args).execute
|
67
44
|
end
|
68
45
|
end
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
opts
|
74
|
-
opts.opt :json_prompt, 'Return data as JSON (for Terminal::prompt)', :short => '-J', :long => '--json-prompt', :type => :boolean
|
75
|
-
opts.opt :yaml, 'Return data as Yaml', :short => '-y', :long => '--yaml', :type => :boolean
|
76
|
-
opts.opt :resource, "Specify a resource. For all resources type: #{Blufin::Terminal::format_command('all')}", :short => '-r', :long => '--resource', :type => :string
|
77
|
-
opts.opt :verbose, 'Output the original response from AWS (with all fields).', :short => '-v', :long => '--verbose', :type => :boolean
|
78
|
-
opts.opt :metadata, 'Output the YML definition file metadata.', :short => '-m', :long => '--metadata', :type => :boolean
|
79
|
-
# TODO - Implement Region + Project filtering (possibly more).
|
80
|
-
opts.opt :region, 'Specify a region', :short => '-R', :long => '--region', :type => :string
|
81
|
-
opts.opt :project, 'Specify a project (Tag: project)', :short => '-p', :long => '--project', :type => :string
|
82
|
-
end
|
83
|
-
aws_list.action do |opts, args|
|
84
|
-
AppCommand::AWSList.new(opts, args).execute
|
46
|
+
# d - AWS CLOUD FORMATION DETECT-DRIFT
|
47
|
+
awx_cloudformation.command :detect_drift, :aliases => [:d] do |awx_cloudformation_detect_drift|
|
48
|
+
awx_cloudformation_detect_drift.summary 'Detect drift (for stack)'
|
49
|
+
awx_cloudformation_detect_drift.action do |opts, args|
|
50
|
+
AppCommand::AWSCloudFormationDetectDrift.new(opts, args).execute
|
85
51
|
end
|
86
52
|
end
|
87
|
-
#
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
opts
|
92
|
-
opts.opt :payload_file, 'The path to a JSON payload you want to send', :short => '-p', :long => '--pay-load-file', :type => :string
|
93
|
-
end
|
94
|
-
aws_lambda.action do |opts, args|
|
95
|
-
AppCommand::AWSLambda.new(opts, args).execute
|
53
|
+
# D - AWS CLOUD FORMATION DELETE
|
54
|
+
awx_cloudformation.command :delete, :aliases => [:D] do |awx_cloudformation_delete|
|
55
|
+
awx_cloudformation_delete.summary 'Delete stack'
|
56
|
+
awx_cloudformation_delete.action do |opts, args|
|
57
|
+
AppCommand::AWSCloudFormationDelete.new(opts, args).execute
|
96
58
|
end
|
97
59
|
end
|
98
|
-
|
99
|
-
system("#{ConfigUnique::GEM_NAME}
|
60
|
+
awx_cloudformation.action do
|
61
|
+
system("#{ConfigUnique::GEM_NAME} c -h")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
# l - AWS LIST
|
65
|
+
awx.command :list, :aliases => [:l] do |awx_list|
|
66
|
+
awx_list.summary 'List AWS instances/resources'
|
67
|
+
awx_list.options do |opts|
|
68
|
+
opts.opt :json, 'Return data as JSON', :short => '-j', :long => '--json', :type => :boolean
|
69
|
+
opts.opt :json_prompt, 'Return data as JSON (for Terminal::prompt)', :short => '-J', :long => '--json-prompt', :type => :boolean
|
70
|
+
opts.opt :yaml, 'Return data as Yaml', :short => '-y', :long => '--yaml', :type => :boolean
|
71
|
+
opts.opt :resource, "Specify a resource. For all resources type: #{Blufin::Terminal::format_command('all')}", :short => '-r', :long => '--resource', :type => :string
|
72
|
+
opts.opt :verbose, 'Output the original response from AWS (with all fields).', :short => '-v', :long => '--verbose', :type => :boolean
|
73
|
+
opts.opt :metadata, 'Output the YML definition file metadata.', :short => '-m', :long => '--metadata', :type => :boolean
|
74
|
+
# TODO - Implement Region + Project filtering (possibly more).
|
75
|
+
opts.opt :region, "Specify a region \xe2\x80\x94 #{Blufin::Terminal::format_invalid('@NotImplemented')}", :short => '-R', :long => '--region', :type => :string
|
76
|
+
opts.opt :environment, "Specify a environment \xe2\x80\x94 #{Blufin::Terminal::format_invalid('@NotImplemented')}", :short => '-e', :long => '--environment', :type => :string
|
77
|
+
opts.opt :project, "Specify a project \xe2\x80\x94 #{Blufin::Terminal::format_invalid('@NotImplemented')}", :short => '-p', :long => '--project', :type => :string
|
78
|
+
end
|
79
|
+
awx_list.action do |opts, args|
|
80
|
+
AppCommand::AWSList.new(opts, args).execute
|
81
|
+
end
|
82
|
+
end
|
83
|
+
# L - AWS LAMBDA
|
84
|
+
awx.command :lambda, :aliases => [:L] do |awx_lambda|
|
85
|
+
awx_lambda.summary 'Quickly invoke a Lambda function locally (without the need to deploy)'
|
86
|
+
awx_lambda.options do |opts|
|
87
|
+
opts.opt :headers_file, 'The path to a JSON containing HTTP Headers you want to send', :short => '-H', :long => '--headers-file', :type => :string
|
88
|
+
opts.opt :payload_file, 'The path to a JSON payload you want to send', :short => '-p', :long => '--pay-load-file', :type => :string
|
89
|
+
end
|
90
|
+
awx_lambda.action do |opts, args|
|
91
|
+
AppCommand::AWSLambda.new(opts, args).execute
|
100
92
|
end
|
101
93
|
end
|
102
94
|
end
|
103
95
|
|
104
96
|
# x - SETUP
|
105
|
-
|
97
|
+
awx.command :setup, :aliases => [:x] do |setup|
|
106
98
|
setup.summary 'Setup your configuration file'
|
107
99
|
setup.action do |opts, args|
|
108
100
|
AppCommand::Setup.new(opts, args).execute
|
109
101
|
end
|
110
102
|
end
|
111
103
|
|
112
|
-
#
|
113
|
-
|
104
|
+
# AWX (DEFAULT)
|
105
|
+
awx.action do
|
114
106
|
system("#{ConfigUnique::GEM_NAME} -h")
|
115
107
|
end
|
116
108
|
|
@@ -120,5 +112,7 @@ module App
|
|
120
112
|
|
121
113
|
Blufin::Terminal::print_exception(e);
|
122
114
|
end
|
115
|
+
|
123
116
|
end
|
117
|
+
|
124
118
|
end
|