Class: Mappru::Exporter
- Inherits:
-
Object
- Object
- Mappru::Exporter
- Includes:
- Logger::Helper, Utils::Helper
- Defined in:
- lib/mappru/exporter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(client, options = {}) ⇒ Exporter
constructor
A new instance of Exporter.
Methods included from Utils::Helper
Methods included from Logger::Helper
Constructor Details
#initialize(client, options = {}) ⇒ Exporter
Returns a new instance of Exporter.
9 10 11 12 13 |
# File 'lib/mappru/exporter.rb', line 9 def initialize(client, = {}) @client = client @resource = Aws::EC2::Resource.new(client: @client) = end |
Class Method Details
.export(client, options = {}) ⇒ Object
5 6 7 |
# File 'lib/mappru/exporter.rb', line 5 def self.export(client, = {}) self.new(client, ).export end |
Instance Method Details
#export ⇒ Object
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 |
# File 'lib/mappru/exporter.rb', line 15 def export result = {} @resource route_tables = @resource.route_tables route_tables.each do |rt| vpc_id = rt.vpc_id name_tag = rt..find {|i| i.key == 'Name' } || {} name = name_tag[:value] next unless matched?(vpc_id, [:vpc_id]) unless name log(:warn, "Cannot manage the nameless Route Table: #{vpc_id}", color: :yellow) next end next unless matched?(name, [:rt_name]) result[vpc_id] ||= {} if result[vpc_id][name] raise "Duplication Subnet found: #{vpc_id}: #{name}" end result[vpc_id][name] = export_route_table(rt) end result end |