terraforming 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -0
- data/lib/terraforming/resource/route53_zone.rb +5 -0
- data/lib/terraforming/resource/route_table.rb +76 -3
- data/lib/terraforming/resource/route_table_association.rb +2 -1
- data/lib/terraforming/template/tf/ec2.erb +2 -0
- data/lib/terraforming/template/tf/route53_zone.erb +1 -0
- data/lib/terraforming/template/tf/route_table.erb +4 -0
- data/lib/terraforming/template/tf/route_table_association.erb +0 -2
- data/lib/terraforming/version.rb +1 -1
- data/script/console +0 -0
- data/script/setup +0 -0
- data/terraforming.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67886dcb207d5bb56ceaf16ca3051f771f65ffad
|
4
|
+
data.tar.gz: 35ba0a5d88adec6d84fc14af5966c505ab81ac00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fe49e3e0d6e45c8f13fb0750b4021cddc09ebe73c7c6ac4db95914a72cfb9c55be583c875586a837b030c6190ad313e73529bedd09f5828ce23c72080ae9b16
|
7
|
+
data.tar.gz: 5b120fdc4fe6039ad4883408b994d69042cde5c62f30fd5cb2ffb259a213d1d257341b3374cc257c6db7bd928f6169ea356b32368a7332e6e1ef6b38a276e346
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# [v0.6.2](https://github.com/dtan4/terraforming/releases/tag/v0.6.2) (2015-12-11)
|
2
|
+
|
3
|
+
## Fixed
|
4
|
+
|
5
|
+
- Get zone comment of Route53 Zone #149 (thanks @tjend)
|
6
|
+
- Skip implicit Route Table Association when generating tfstate #148 (thanks @kovyrin)
|
7
|
+
- Improve Route Table support #146 (thanks @kovyrin)
|
8
|
+
- Ignore EC2 source_dest_check if nil #143 (thanks @cmcarthur)
|
9
|
+
|
1
10
|
# [v0.6.1](https://github.com/dtan4/terraforming/releases/tag/v0.6.1) (2015-11-27)
|
2
11
|
|
3
12
|
## Fixed
|
data/README.md
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/terraforming.svg)](http://badge.fury.io/rb/terraforming)
|
8
8
|
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
|
9
9
|
[![Docker Repository on Quay.io](https://quay.io/repository/dtan4/terraforming/status "Docker Repository on Quay.io")](https://quay.io/repository/dtan4/terraforming)
|
10
|
+
[![Join the chat at https://gitter.im/dtan4/terraforming](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dtan4/terraforming?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
10
11
|
|
11
12
|
Export existing AWS resources to [Terraform](https://terraform.io/) style (tf, tfstate)
|
12
13
|
|
@@ -25,6 +25,7 @@ module Terraforming
|
|
25
25
|
vpc = vpc_of(hosted_zone)
|
26
26
|
|
27
27
|
attributes = {
|
28
|
+
"comment"=> comment_of(hosted_zone),
|
28
29
|
"id"=> zone_id,
|
29
30
|
"name"=> name_of(hosted_zone),
|
30
31
|
"name_servers.#" => name_servers_of(hosted_zone).length.to_s,
|
@@ -55,6 +56,10 @@ module Terraforming
|
|
55
56
|
@client.list_tags_for_resource(resource_type: "hostedzone", resource_id: zone_id_of(hosted_zone)).resource_tag_set.tags
|
56
57
|
end
|
57
58
|
|
59
|
+
def comment_of(hosted_zone)
|
60
|
+
hosted_zone.hosted_zone.config.comment
|
61
|
+
end
|
62
|
+
|
58
63
|
def name_of(hosted_zone)
|
59
64
|
hosted_zone.hosted_zone.name.gsub(/\.\z/, "")
|
60
65
|
end
|
@@ -23,10 +23,13 @@ module Terraforming
|
|
23
23
|
route_tables.inject({}) do |resources, route_table|
|
24
24
|
attributes = {
|
25
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
26
|
"vpc_id" => route_table.vpc_id,
|
29
27
|
}
|
28
|
+
|
29
|
+
attributes.merge!(tags_attributes_of(route_table))
|
30
|
+
attributes.merge!(routes_attributes_of(route_table))
|
31
|
+
attributes.merge!(propagating_vgws_attributes_of(route_table))
|
32
|
+
|
30
33
|
resources["aws_route_table.#{module_name_of(route_table)}"] = {
|
31
34
|
"type" => "aws_route_table",
|
32
35
|
"primary" => {
|
@@ -42,7 +45,11 @@ module Terraforming
|
|
42
45
|
private
|
43
46
|
|
44
47
|
def routes_of(route_table)
|
45
|
-
route_table.routes
|
48
|
+
route_table.routes.reject do |route|
|
49
|
+
route.gateway_id.to_s == 'local' ||
|
50
|
+
route.origin.to_s == 'EnableVgwRoutePropagation' ||
|
51
|
+
route.destination_prefix_list_id
|
52
|
+
end
|
46
53
|
end
|
47
54
|
|
48
55
|
def module_name_of(route_table)
|
@@ -52,6 +59,72 @@ module Terraforming
|
|
52
59
|
def route_tables
|
53
60
|
@client.describe_route_tables.route_tables
|
54
61
|
end
|
62
|
+
|
63
|
+
def routes_attributes_of(route_table)
|
64
|
+
routes = routes_of(route_table)
|
65
|
+
attributes = { "route.#" => routes.length.to_s }
|
66
|
+
|
67
|
+
routes.each do |route|
|
68
|
+
attributes.merge!(route_attributes_of(route))
|
69
|
+
end
|
70
|
+
|
71
|
+
attributes
|
72
|
+
end
|
73
|
+
|
74
|
+
def route_attributes_of(route)
|
75
|
+
hashcode = route_hashcode_of(route)
|
76
|
+
attributes = {
|
77
|
+
"route.#{hashcode}.cidr_block" => route.destination_cidr_block.to_s,
|
78
|
+
"route.#{hashcode}.gateway_id" => route.gateway_id.to_s,
|
79
|
+
"route.#{hashcode}.instance_id" => route.instance_id.to_s,
|
80
|
+
"route.#{hashcode}.network_interface_id" => route.network_interface_id.to_s,
|
81
|
+
"route.#{hashcode}.vpc_peering_connection_id" => route.vpc_peering_connection_id.to_s
|
82
|
+
}
|
83
|
+
|
84
|
+
attributes
|
85
|
+
end
|
86
|
+
|
87
|
+
def route_hashcode_of(route)
|
88
|
+
string = "#{route.destination_cidr_block}-" <<
|
89
|
+
"#{route.gateway_id}-"
|
90
|
+
|
91
|
+
instance_set = false
|
92
|
+
if route.instance_id != ''
|
93
|
+
string << route.instance_id.to_s
|
94
|
+
instance_set = true
|
95
|
+
end
|
96
|
+
|
97
|
+
string << route.vpc_peering_connection_id.to_s
|
98
|
+
|
99
|
+
unless instance_set
|
100
|
+
string << route.network_interface_id.to_s
|
101
|
+
end
|
102
|
+
|
103
|
+
Zlib.crc32(string)
|
104
|
+
end
|
105
|
+
|
106
|
+
def propagaving_vgws_of(route_table)
|
107
|
+
route_table.propagating_vgws.map(&:gateway_id).map(&:to_s)
|
108
|
+
end
|
109
|
+
|
110
|
+
def propagating_vgws_attributes_of(route_table)
|
111
|
+
vgws = propagaving_vgws_of(route_table)
|
112
|
+
attributes = { "propagating_vgws.#" => vgws.length.to_s }
|
113
|
+
|
114
|
+
vgws.each do |gateway_id|
|
115
|
+
hashcode = Zlib.crc32(gateway_id)
|
116
|
+
attributes["propagating_vgws.#{hashcode}"] = gateway_id
|
117
|
+
end
|
118
|
+
|
119
|
+
attributes
|
120
|
+
end
|
121
|
+
|
122
|
+
def tags_attributes_of(route_table)
|
123
|
+
tags = route_table.tags
|
124
|
+
attributes = { "tags.#" => tags.length.to_s }
|
125
|
+
tags.each { |tag| attributes["tags.#{tag.key}"] = tag.value }
|
126
|
+
attributes
|
127
|
+
end
|
55
128
|
end
|
56
129
|
end
|
57
130
|
end
|
@@ -28,6 +28,7 @@ module Terraforming
|
|
28
28
|
"route_table_id" => assoc.route_table_id,
|
29
29
|
"subnet_id" => assoc.subnet_id,
|
30
30
|
}
|
31
|
+
|
31
32
|
resources["aws_route_table_association.#{module_name_of(route_table, assoc)}"] = {
|
32
33
|
"type" => "aws_route_table_association",
|
33
34
|
"primary" => {
|
@@ -43,7 +44,7 @@ module Terraforming
|
|
43
44
|
private
|
44
45
|
|
45
46
|
def associations_of(route_table)
|
46
|
-
route_table.associations
|
47
|
+
route_table.associations.reject { |association| association.subnet_id.nil? }
|
47
48
|
end
|
48
49
|
|
49
50
|
def module_name_of(route_table, assoc)
|
@@ -14,7 +14,9 @@ resource "aws_instance" "<%= module_name_of(instance) %>" {
|
|
14
14
|
<%- end -%>
|
15
15
|
associate_public_ip_address = true
|
16
16
|
private_ip = "<%= instance.private_ip_address %>"
|
17
|
+
<%- if instance.source_dest_check -%>
|
17
18
|
source_dest_check = <%= instance.source_dest_check %>
|
19
|
+
<%- end -%>
|
18
20
|
|
19
21
|
<% block_devices_of(instance).each do |block_device| -%>
|
20
22
|
<%- mapping = block_device_mapping_of(instance, block_device.volume_id) -%>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<% hosted_zones.each do |hosted_zone| -%>
|
2
2
|
resource "aws_route53_zone" "<%= module_name_of(hosted_zone) %>" {
|
3
3
|
name = "<%= name_of(hosted_zone) %>"
|
4
|
+
comment = "<%= comment_of(hosted_zone) %>"
|
4
5
|
<%- if private_hosted_zone?(hosted_zone) -%>
|
5
6
|
<%- vpc = vpc_of(hosted_zone) -%>
|
6
7
|
vpc_id = "<%= vpc.vpc_id %>"
|
@@ -19,6 +19,10 @@ resource "aws_route_table" "<%= module_name_of(route_table) %>" {
|
|
19
19
|
<% end -%>
|
20
20
|
}
|
21
21
|
|
22
|
+
<% end -%>
|
23
|
+
<% if route_table.propagating_vgws.any? -%>
|
24
|
+
propagating_vgws = <%= propagaving_vgws_of(route_table).inspect %>
|
25
|
+
|
22
26
|
<% end -%>
|
23
27
|
tags {
|
24
28
|
<% route_table.tags.each do |tag| -%>
|
@@ -1,6 +1,5 @@
|
|
1
1
|
<% route_tables.each do |route_table| -%>
|
2
2
|
<% associations_of(route_table).each do |assoc| -%>
|
3
|
-
<% if assoc.subnet_id -%>
|
4
3
|
resource "aws_route_table_association" "<%= module_name_of(route_table, assoc) %>" {
|
5
4
|
route_table_id = "<%= assoc.route_table_id %>"
|
6
5
|
subnet_id = "<%= assoc.subnet_id %>"
|
@@ -8,4 +7,3 @@ resource "aws_route_table_association" "<%= module_name_of(route_table, assoc) %
|
|
8
7
|
|
9
8
|
<% end -%>
|
10
9
|
<% end -%>
|
11
|
-
<% end -%>
|
data/lib/terraforming/version.rb
CHANGED
data/script/console
CHANGED
File without changes
|
data/script/setup
CHANGED
File without changes
|
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", "
|
22
|
+
spec.add_dependency "aws-sdk", "= 2.2.5"
|
23
23
|
spec.add_dependency "oj"
|
24
24
|
spec.add_dependency "ox"
|
25
25
|
spec.add_dependency "thor"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraforming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
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
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2.
|
19
|
+
version: 2.2.5
|
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.2.
|
26
|
+
version: 2.2.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: oj
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|