mappru 0.1.8 → 0.1.9.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 7779e15de4d4095b4a32d16b4f36170f5409321b105d9e9620173cc60b2f1950
4
- data.tar.gz: 56f68baede3e08984cb6cf2957e5390b46262333eec977f2ce9104bfeb03ec0a
2
+ SHA1:
3
+ metadata.gz: 44003fe735f676f54f72364497431dc196c0fe11
4
+ data.tar.gz: c7267f893fb5afdcae72469130be865659cdb413
5
5
  SHA512:
6
- metadata.gz: 13bdbcfb2130da63d416000e35f97cfa09a69e7e761803e8416323e18c1171550fa61f50dc9ff993465457543419e51fc866839c1d4790b7e73bd94ba59a7b97
7
- data.tar.gz: e0f12906096c6e2f85f1743bf79d8742b4181c4b8ad3fa709393afcf1cecdfc3162061a18d5599d921d123cde4de45939f1718849bc47c45fb64ef4c35a5fa0e
6
+ metadata.gz: 6b228674aa0c06b181efbb45521234d519deac3c9fcad9ac2dcb68eb35b23a46703264b0f8d8f73b07d40448a5ec75aec642901fae12cd750e634a65bd5dcce1
7
+ data.tar.gz: c40db89940470e5db2dabec180fda41e32b97653b4362ba5edc5e1b02e90820f999819eb84cdc95941a699745d6d1a1f9d21961e60ad6b862eb86b7b294c02ed
data/lib/mappru.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'aws-sdk'
1
+ require 'aws-sdk-ec2'
2
2
  require 'diffy'
3
3
  require 'hash_modern_inspect'
4
4
  require 'hashie'
data/lib/mappru/driver.rb CHANGED
@@ -4,7 +4,6 @@ class Mappru::Driver
4
4
 
5
5
  def initialize(client, options = {})
6
6
  @client = client
7
- @resource = Aws::EC2::Resource.new(client: @client)
8
7
  @options = options
9
8
  end
10
9
 
@@ -12,11 +11,10 @@ class Mappru::Driver
12
11
  log(:info, "Create Route Table `#{vpc_id}` > `#{name}`", color: :cyan)
13
12
 
14
13
  unless @options[:dry_run]
15
- vpc = @resource.vpc(vpc_id)
16
- rt = vpc.create_route_table
14
+ route_table_id = @client.create_route_table(vpc_id: vpc_id).route_table.route_table_id
17
15
  name_tag = {key: 'Name', value: name}
18
- rt.create_tags(tags: [name_tag])
19
- rt_id_by_vpc_rt_name[vpc_id][name] = rt.id
16
+ @client.create_tags(resources: [route_table_id], tags: [name_tag])
17
+ rt_id_by_vpc_rt_name[vpc_id][name] = route_table_id
20
18
  end
21
19
 
22
20
  {routes: [], subnets: []}
@@ -83,7 +81,7 @@ class Mappru::Driver
83
81
  return @rt_ids if @rt_ids
84
82
 
85
83
  @rt_ids = {}
86
- route_tables = @resource.route_tables
84
+ route_tables = @client.describe_route_tables().flat_map(&:route_tables)
87
85
 
88
86
  route_tables.each do |rt|
89
87
  vpc_id = rt.vpc_id
@@ -93,7 +91,7 @@ class Mappru::Driver
93
91
  next unless name
94
92
 
95
93
  @rt_ids[vpc_id] ||= {}
96
- @rt_ids[vpc_id][name] = rt.id
94
+ @rt_ids[vpc_id][name] = rt.route_table_id
97
95
  end
98
96
 
99
97
  @rt_ids
@@ -103,7 +101,7 @@ class Mappru::Driver
103
101
  return @assoc_ids if @assoc_ids
104
102
 
105
103
  @assoc_ids = {}
106
- associations = @resource.route_tables.map(&:associations).flat_map(&:to_a)
104
+ associations = @client.describe_route_tables().flat_map(&:route_tables).map(&:associations).flat_map(&:to_a)
107
105
 
108
106
  associations.each do |assoc|
109
107
  if assoc.subnet_id
@@ -8,15 +8,13 @@ class Mappru::Exporter
8
8
 
9
9
  def initialize(client, options = {})
10
10
  @client = client
11
- @resource = Aws::EC2::Resource.new(client: @client)
12
11
  @options = options
13
12
  end
14
13
 
15
14
  def export
16
15
  result = {}
17
- @resource
18
16
 
19
- route_tables = @resource.route_tables
17
+ route_tables = @client.describe_route_tables().flat_map(&:route_tables)
20
18
 
21
19
  route_tables.each do |rt|
22
20
  vpc_id = rt.vpc_id
@@ -48,14 +46,13 @@ class Mappru::Exporter
48
46
 
49
47
  def export_route_table(rt)
50
48
  result = {
51
- route_table_id: rt.id,
49
+ route_table_id: rt.route_table_id,
52
50
  routes: [],
53
51
  subnets: export_subnets(rt.associations),
54
52
  }
55
53
 
56
- # route -> (Array<Route>, nil)
57
- # http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/RouteTable.html#routes-instance_method
58
- sorted_routes = rt.routes.reject(&:nil?).sort_by do |route|
54
+ # TODO: support VPC endpoint
55
+ sorted_routes = rt.routes.select(&:destination_cidr_block).sort_by do |route|
59
56
  IPAddr.new(route.destination_cidr_block).to_i
60
57
  end
61
58
 
@@ -1,3 +1,3 @@
1
1
  module Mappru
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9.beta'
3
3
  end
data/mappru.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency 'aws-sdk', '~> 2'
22
+ spec.add_dependency 'aws-sdk-ec2'
23
23
  spec.add_dependency 'diffy'
24
24
  spec.add_dependency 'hash_modern_inspect'
25
25
  spec.add_dependency 'hashie'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mappru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-19 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: aws-sdk
14
+ name: aws-sdk-ec2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: diffy
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -185,12 +185,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  requirements:
188
- - - ">="
188
+ - - ">"
189
189
  - !ruby/object:Gem::Version
190
- version: '0'
190
+ version: 1.3.1
191
191
  requirements: []
192
192
  rubyforge_project:
193
- rubygems_version: 2.7.3
193
+ rubygems_version: 2.6.13
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Mappru is a tool to manage VPC Route Table.