-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
62 lines (51 loc) · 1.25 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require_relative 'lib/ec2_utils'
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new(:style)
task default: :spec
def check_cache
puts `rake cache:clear` if ENV['cache'] == 'no'
end
namespace :cache do
desc 'Clear cached objects'
task :clear do
AwsUtils.clear_cache
end
desc 'Show all cached objects'
task :show do
cache_files = Dir.glob("#{File.dirname(__FILE__)}/cache/*")
cache_files.each do |cache_file|
puts cache_file.info
end
end
end
namespace :log do
desc 'Truncate the log'
task :clear do
AwsUtils.clear_log
end
end
namespace :audit do
desc 'Run all AWS audit tasks'
task :all do
%w[ec2s keys users s3s].each { |task| sh "rake #{task}:audit" }
end
end
desc 'Show filtered available AWS regions'
task :regions do
FileUtils.rm_rf "#{CACHE_PATH}/regions_cache.yaml" if ENV['cache'] == 'no'
Ec2Utils.new.show_regions
end
namespace :regions do
desc 'Show all available AWS regions'
task :all do
Ec2Utils.new.show_regions(true)
end
end
desc 'Set default region to arg: rake region[new_region]'
task :region, :region_value do |_t, args|
ec2u = Ec2Utils.new
ec2u.default_region = (args[:region_value])
end