terraforming 0.4.0 → 0.5.0

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
2
  SHA1:
3
- metadata.gz: 66c5df7584aafe8c899dd0fc56b1aa3c67afd047
4
- data.tar.gz: c81276bc2e5fe556971f7ee27d67b89b581a8edc
3
+ metadata.gz: 838cb35c9f3ccaf96a07929407282dd25620a2ce
4
+ data.tar.gz: 2c81b7c5a24cc7e19e3679ec6c5341eac4ef18c0
5
5
  SHA512:
6
- metadata.gz: f64e996eabafb2a6dc9457b8bc2f5d92cb833cdee12d8a26acc454445a60de89e15066804030f1c47d0d7a08b60ec9f5ac242475bf579811a9ae597a4e0412f2
7
- data.tar.gz: 1b38d910a7f83523ad7833c98273f00021c0719e9d2c354cf6f3c812ab89f0d026390ca58c498162d0755f749de8f55d765efb026eb9f0a2262d2cc0cbc7551b
6
+ metadata.gz: 43f07b3a3fe4953da6c189b946cb628bb9b73ae9b8474c026bca836d61aace8f63f16dd1b73b4e971265cb9093ead75077bd082ae65df49292f6842925d9c234
7
+ data.tar.gz: 6e469450a3de21eb142db4fe9263e7546c173b78f5adc7d666b199ace5927c048e23192f65e20dacb96ae89c24612e3e9b34138cae7cb492c74097d41642ad37
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- # [v0.4.0](https://github.com/dtan4/terraforming/releases/tag/v0.4.0) (2015-10-06)
1
+ # [v0.5.0](https://github.com/dtan4/terraforming/releases/tag/v0.5.0) (2015-11-20)
2
+
3
+ ## Resource
4
+
5
+ - AWS Route Table #137 (thanks @k1LoW)
6
+
7
+ # [v0.4.0](https://github.com/dtan4/terraforming/releases/tag/v0.4.0) (2015-11-10)
2
8
 
3
9
  ## New feature
4
10
 
data/README.md CHANGED
@@ -89,6 +89,7 @@ Commands:
89
89
  terraforming r53r # Route53 Record
90
90
  terraforming r53z # Route53 Hosted Zone
91
91
  terraforming rds # RDS
92
+ terraforming rt # Route Table
92
93
  terraforming s3 # S3
93
94
  terraforming sg # Security Group
94
95
  terraforming sn # Subnet
data/lib/terraforming.rb CHANGED
@@ -32,6 +32,7 @@ require "terraforming/resource/iam_user_policy"
32
32
  require "terraforming/resource/network_acl"
33
33
  require "terraforming/resource/network_interface"
34
34
  require "terraforming/resource/rds"
35
+ require "terraforming/resource/route_table"
35
36
  require "terraforming/resource/route53_record"
36
37
  require "terraforming/resource/route53_zone"
37
38
  require "terraforming/resource/s3"
@@ -120,6 +120,11 @@ module Terraforming
120
120
  execute(Terraforming::Resource::RDS, options)
121
121
  end
122
122
 
123
+ desc "rt", "Route Table"
124
+ def rt
125
+ execute(Terraforming::Resource::RouteTable, options)
126
+ end
127
+
123
128
  desc "s3", "S3"
124
129
  def s3
125
130
  execute(Terraforming::Resource::S3, options)
@@ -0,0 +1,57 @@
1
+ module Terraforming
2
+ module Resource
3
+ class RouteTable
4
+ include Terraforming::Util
5
+
6
+ def self.tf(client: Aws::EC2::Client.new)
7
+ self.new(client).tf
8
+ end
9
+
10
+ def self.tfstate(client: Aws::EC2::Client.new)
11
+ self.new(client).tfstate
12
+ end
13
+
14
+ def initialize(client)
15
+ @client = client
16
+ end
17
+
18
+ def tf
19
+ apply_template(@client, "tf/route_table")
20
+ end
21
+
22
+ def tfstate
23
+ route_tables.inject({}) do |resources, route_table|
24
+ attributes = {
25
+ "id" => route_table.route_table_id,
26
+ "route.#" => routes_of(route_table).length.to_s,
27
+ "tags.#" => route_table.tags.length.to_s,
28
+ "vpc_id" => route_table.vpc_id,
29
+ }
30
+ resources["aws_route_table.#{module_name_of(route_table)}"] = {
31
+ "type" => "aws_route_table",
32
+ "primary" => {
33
+ "id" => route_table.route_table_id,
34
+ "attributes" => attributes
35
+ }
36
+ }
37
+
38
+ resources
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def routes_of(route_table)
45
+ route_table.routes
46
+ end
47
+
48
+ def module_name_of(route_table)
49
+ normalize_module_name(name_from_tag(route_table, route_table.route_table_id))
50
+ end
51
+
52
+ def route_tables
53
+ @client.describe_route_tables.route_tables
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,30 @@
1
+ <% route_tables.each do |route_table| -%>
2
+ resource "aws_route_table" "<%= module_name_of(route_table) %>" {
3
+ vpc_id = "<%= route_table.vpc_id %>"
4
+
5
+ <% routes_of(route_table).each do |route| -%>
6
+ route {
7
+ cidr_block = "<%= route.destination_cidr_block %>"
8
+ <% if route.gateway_id -%>
9
+ gateway_id = "<%= route.gateway_id %>"
10
+ <% end -%>
11
+ <% if route.instance_id -%>
12
+ instance_id = "<%= route.instance_id %>"
13
+ <% end -%>
14
+ <% if route.vpc_peering_connection_id -%>
15
+ vpc_peering_connection_id = "<%= route.vpc_peering_connection_id %>"
16
+ <% end -%>
17
+ <% if route.network_interface_id -%>
18
+ network_interface_id = "<%= route.network_interface_id %>"
19
+ <% end -%>
20
+ }
21
+
22
+ <% end -%>
23
+ tags {
24
+ <% route_table.tags.each do |tag| -%>
25
+ "<%= tag.key %>" = "<%= tag.value %>"
26
+ <% end -%>
27
+ }
28
+ }
29
+
30
+ <% end -%>
@@ -1,3 +1,3 @@
1
1
  module Terraforming
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/terraforming.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "aws-sdk", "~> 2.1.15"
22
+ spec.add_dependency "aws-sdk", "~> 2.2.0"
23
23
  spec.add_dependency "oj"
24
24
  spec.add_dependency "ox"
25
25
  spec.add_dependency "thor"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraforming
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daisuke Fujita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.15
19
+ version: 2.2.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.1.15
26
+ version: 2.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: oj
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -208,6 +208,7 @@ files:
208
208
  - lib/terraforming/resource/rds.rb
209
209
  - lib/terraforming/resource/route53_record.rb
210
210
  - lib/terraforming/resource/route53_zone.rb
211
+ - lib/terraforming/resource/route_table.rb
211
212
  - lib/terraforming/resource/s3.rb
212
213
  - lib/terraforming/resource/security_group.rb
213
214
  - lib/terraforming/resource/subnet.rb
@@ -235,6 +236,7 @@ files:
235
236
  - lib/terraforming/template/tf/rds.erb
236
237
  - lib/terraforming/template/tf/route53_record.erb
237
238
  - lib/terraforming/template/tf/route53_zone.erb
239
+ - lib/terraforming/template/tf/route_table.erb
238
240
  - lib/terraforming/template/tf/s3.erb
239
241
  - lib/terraforming/template/tf/security_group.erb
240
242
  - lib/terraforming/template/tf/subnet.erb
@@ -264,8 +266,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
266
  version: '0'
265
267
  requirements: []
266
268
  rubyforge_project:
267
- rubygems_version: 2.4.5.1
269
+ rubygems_version: 2.4.8
268
270
  signing_key:
269
271
  specification_version: 4
270
272
  summary: Export existing AWS resources to Terraform style (tf, tfstate)
271
273
  test_files: []
274
+ has_rdoc: