terraforming 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +13 -0
- data/README.md +6 -2
- data/lib/terraforming.rb +2 -0
- data/lib/terraforming/cli.rb +10 -0
- data/lib/terraforming/resource/iam_user.rb +1 -1
- data/lib/terraforming/resource/internet_gateway.rb +54 -0
- data/lib/terraforming/resource/redshift.rb +67 -0
- data/lib/terraforming/resource/route53_record.rb +3 -1
- data/lib/terraforming/template/tf/auto_scaling_group.erb +3 -2
- data/lib/terraforming/template/tf/internet_gateway.erb +14 -0
- data/lib/terraforming/template/tf/redshift.erb +23 -0
- data/lib/terraforming/version.rb +1 -1
- data/terraforming.gemspec +2 -1
- metadata +25 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81391c43ae75be098888ffb552b0862b5eb84ff3
|
4
|
+
data.tar.gz: 2b3697639b6a79b2ad1bd9f3ad2e668cda9d36be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daf32d71dc7f775cef0faa84393dc92b7928273a07fe105fb8caa9fe2cda864d061f7fbd6189fab963194d2816dd49f0e19ac82903c4bf07f74e19727194a600
|
7
|
+
data.tar.gz: b025806af68fff47061a5160a3018a271ef5d9ef6e0d55630d9d3f7fb218de2c3d4df146507956d256fef8d337007d8899edaa233aa8350dcd9289a08a0ffb7b
|
data/.travis.yml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
3
|
+
- 2.3.0
|
4
|
+
- 2.2.4
|
5
|
+
- 2.1.8
|
5
6
|
- 2.0
|
6
7
|
env:
|
7
8
|
- secure: n0mxwnyjuXI4mJO4mp++2TnsPJ+XgCF/J1U2L5piE5j3xMhSU+5V0JrA1uFlS0Pemb44M7BjgmF9S4G35BwyAQpctpCYhqy9tFa6+Y6nxEv5hCv2cZz7BSAZM6eb+zq20409hxTHRaQOr1DBeE4R5S2PrmOXRqvYfTRv3LNSLFk=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# [v0.7.0](https://github.com/dtan4/terraforming/releases/tag/v0.6.2) (2016-02-16)
|
2
|
+
|
3
|
+
## Resource
|
4
|
+
|
5
|
+
- AWS Internet Gateway #164 (thanks @manabusakai)
|
6
|
+
- AWS Redshift #161 (thanks @manabusakai)
|
7
|
+
|
8
|
+
## Fixed
|
9
|
+
|
10
|
+
- Modify AutoScaling Group tags format #167
|
11
|
+
- Support paging for Route53 records #160 (thanks @seanodonnell)
|
12
|
+
- Support paging for IAM user call #157 (thanks @crazed)
|
13
|
+
|
1
14
|
# [v0.6.2](https://github.com/dtan4/terraforming/releases/tag/v0.6.2) (2015-12-11)
|
2
15
|
|
3
16
|
## Fixed
|
data/README.md
CHANGED
@@ -49,7 +49,7 @@ You need to set AWS credentials.
|
|
49
49
|
```bash
|
50
50
|
export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX
|
51
51
|
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
52
|
-
export
|
52
|
+
export AWS_REGION=xx-yyyy-0
|
53
53
|
```
|
54
54
|
|
55
55
|
You can also specify credential profile in `~/.aws/credentials` by `--profile` option.
|
@@ -76,6 +76,7 @@ Commands:
|
|
76
76
|
terraforming ec2 # EC2
|
77
77
|
terraforming ecc # ElastiCache Cluster
|
78
78
|
terraforming ecsn # ElastiCache Subnet Group
|
79
|
+
terraforming eip # EIP
|
79
80
|
terraforming elb # ELB
|
80
81
|
terraforming iamg # IAM Group
|
81
82
|
terraforming iamgm # IAM Group Membership
|
@@ -86,10 +87,13 @@ Commands:
|
|
86
87
|
terraforming iamrp # IAM Role Policy
|
87
88
|
terraforming iamu # IAM User
|
88
89
|
terraforming iamup # IAM User Policy
|
90
|
+
terraforming igw # Internet Gateway
|
89
91
|
terraforming nacl # Network ACL
|
92
|
+
terraforming nif # Network Interface
|
90
93
|
terraforming r53r # Route53 Record
|
91
94
|
terraforming r53z # Route53 Hosted Zone
|
92
95
|
terraforming rds # RDS
|
96
|
+
terraforming rs # Redshift
|
93
97
|
terraforming rt # Route Table
|
94
98
|
terraforming rta # Route Table Association
|
95
99
|
terraforming s3 # S3
|
@@ -326,7 +330,7 @@ $ docker run \
|
|
326
330
|
--name terraforming \
|
327
331
|
-e AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX \
|
328
332
|
-e AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \
|
329
|
-
-e
|
333
|
+
-e AWS_REGION=xx-yyyy-0 \
|
330
334
|
quay.io/dtan4/terraforming:latest \
|
331
335
|
terraforming s3
|
332
336
|
```
|
data/lib/terraforming.rb
CHANGED
@@ -29,9 +29,11 @@ require "terraforming/resource/iam_role"
|
|
29
29
|
require "terraforming/resource/iam_role_policy"
|
30
30
|
require "terraforming/resource/iam_user"
|
31
31
|
require "terraforming/resource/iam_user_policy"
|
32
|
+
require "terraforming/resource/internet_gateway"
|
32
33
|
require "terraforming/resource/network_acl"
|
33
34
|
require "terraforming/resource/network_interface"
|
34
35
|
require "terraforming/resource/rds"
|
36
|
+
require "terraforming/resource/redshift"
|
35
37
|
require "terraforming/resource/route_table"
|
36
38
|
require "terraforming/resource/route_table_association"
|
37
39
|
require "terraforming/resource/route53_record"
|
data/lib/terraforming/cli.rb
CHANGED
@@ -95,6 +95,11 @@ module Terraforming
|
|
95
95
|
execute(Terraforming::Resource::IAMUserPolicy, options)
|
96
96
|
end
|
97
97
|
|
98
|
+
desc "igw", "Internet Gateway"
|
99
|
+
def igw
|
100
|
+
execute(Terraforming::Resource::InternetGateway, options)
|
101
|
+
end
|
102
|
+
|
98
103
|
desc "nacl", "Network ACL"
|
99
104
|
def nacl
|
100
105
|
execute(Terraforming::Resource::NetworkACL, options)
|
@@ -120,6 +125,11 @@ module Terraforming
|
|
120
125
|
execute(Terraforming::Resource::RDS, options)
|
121
126
|
end
|
122
127
|
|
128
|
+
desc "rs", "Redshift"
|
129
|
+
def rs
|
130
|
+
execute(Terraforming::Resource::Redshift, options)
|
131
|
+
end
|
132
|
+
|
123
133
|
desc "rt", "Route Table"
|
124
134
|
def rt
|
125
135
|
execute(Terraforming::Resource::RouteTable, options)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class InternetGateway
|
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/internet_gateway")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
internet_gateways.inject({}) do |resources, internet_gateway|
|
24
|
+
next resources if internet_gateway.attachments.empty?
|
25
|
+
|
26
|
+
attributes = {
|
27
|
+
"id" => internet_gateway.internet_gateway_id,
|
28
|
+
"vpc_id" => internet_gateway.attachments[0].vpc_id,
|
29
|
+
"tags.#" => internet_gateway.tags.length.to_s,
|
30
|
+
}
|
31
|
+
resources["aws_internet_gateway.#{module_name_of(internet_gateway)}"] = {
|
32
|
+
"type" => "aws_internet_gateway",
|
33
|
+
"primary" => {
|
34
|
+
"id" => internet_gateway.internet_gateway_id,
|
35
|
+
"attributes" => attributes
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
resources
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def internet_gateways
|
46
|
+
@client.describe_internet_gateways.internet_gateways
|
47
|
+
end
|
48
|
+
|
49
|
+
def module_name_of(internet_gateway)
|
50
|
+
normalize_module_name(name_from_tag(internet_gateway, internet_gateway.internet_gateway_id))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class Redshift
|
4
|
+
include Terraforming::Util
|
5
|
+
|
6
|
+
def self.tf(client: Aws::Redshift::Client.new)
|
7
|
+
self.new(client).tf
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.tfstate(client: Aws::Redshift::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/redshift")
|
20
|
+
end
|
21
|
+
|
22
|
+
def tfstate
|
23
|
+
clusters.inject({}) do |resources, cluster|
|
24
|
+
attributes = {
|
25
|
+
"cluster_identifier" => cluster.cluster_identifier,
|
26
|
+
"cluster_type" => cluster.number_of_nodes == 1 ? "single-node" : "multi-node",
|
27
|
+
"node_type" => cluster.node_type,
|
28
|
+
"master_password" => "xxxxxxxx",
|
29
|
+
"master_username" => cluster.master_username,
|
30
|
+
"availability_zone" => cluster.availability_zone,
|
31
|
+
"preferred_maintenance_window" => cluster.preferred_maintenance_window,
|
32
|
+
"cluster_parameter_group_name" => cluster.cluster_parameter_groups[0].parameter_group_name,
|
33
|
+
"automated_snapshot_retention_period" => cluster.automated_snapshot_retention_period.to_s,
|
34
|
+
"port" => cluster.endpoint.port.to_s,
|
35
|
+
"cluster_version" => cluster.cluster_version,
|
36
|
+
"allow_version_upgrade" => cluster.allow_version_upgrade.to_s,
|
37
|
+
"number_of_nodes" => cluster.number_of_nodes.to_s,
|
38
|
+
"publicly_accessible" => cluster.publicly_accessible.to_s,
|
39
|
+
"encrypted" => cluster.encrypted.to_s,
|
40
|
+
"skip_final_snapshot" => "true",
|
41
|
+
}
|
42
|
+
attributes["database_name"] = cluster.db_name if cluster.db_name
|
43
|
+
|
44
|
+
resources["aws_redshift_cluster.#{module_name_of(cluster)}"] = {
|
45
|
+
"type" => "aws_redshift_cluster",
|
46
|
+
"primary" => {
|
47
|
+
"id" => cluster.cluster_identifier,
|
48
|
+
"attributes" => attributes
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
resources
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def clusters
|
59
|
+
@client.describe_clusters.clusters
|
60
|
+
end
|
61
|
+
|
62
|
+
def module_name_of(cluster)
|
63
|
+
normalize_module_name(cluster.cluster_identifier)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -60,7 +60,9 @@ module Terraforming
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def record_sets_of(hosted_zone)
|
63
|
-
@client.list_resource_record_sets(hosted_zone_id: zone_id_of(hosted_zone)).
|
63
|
+
@client.list_resource_record_sets(hosted_zone_id: zone_id_of(hosted_zone)).map do |response|
|
64
|
+
response.data.resource_record_sets
|
65
|
+
end.flatten
|
64
66
|
end
|
65
67
|
|
66
68
|
def records
|
@@ -15,13 +15,14 @@ resource "aws_autoscaling_group" "<%= module_name_of(group) %>" {
|
|
15
15
|
vpc_zone_identifier = <%= vpc_zone_identifier_of(group).inspect %>
|
16
16
|
<%- end -%>
|
17
17
|
|
18
|
-
tag {
|
19
18
|
<% group.tags.each do |tag| -%>
|
19
|
+
tag {
|
20
20
|
key = "<%= tag.key %>"
|
21
21
|
value = "<%= tag.value %>"
|
22
22
|
propagate_at_launch = <%= tag.propagate_at_launch.to_s %>
|
23
|
-
<% end -%>
|
24
23
|
}
|
24
|
+
|
25
|
+
<% end -%>
|
25
26
|
}
|
26
27
|
|
27
28
|
<% end -%>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% internet_gateways.each do |internet_gateway| -%>
|
2
|
+
<% unless internet_gateway.attachments.empty? -%>
|
3
|
+
resource "aws_internet_gateway" "<%= module_name_of(internet_gateway) %>" {
|
4
|
+
vpc_id = "<%= internet_gateway.attachments[0].vpc_id %>"
|
5
|
+
|
6
|
+
tags {
|
7
|
+
<% internet_gateway.tags.each do |tag| -%>
|
8
|
+
"<%= tag.key %>" = "<%= tag.value %>"
|
9
|
+
<% end -%>
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
<% end -%>
|
14
|
+
<% end -%>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% clusters.each do |cluster| -%>
|
2
|
+
resource "aws_redshift_cluster" "<%= cluster.cluster_identifier %>" {
|
3
|
+
cluster_identifier = "<%= cluster.cluster_identifier %>"
|
4
|
+
<%- if cluster.db_name -%>
|
5
|
+
database_name = "<%= cluster.db_name %>"
|
6
|
+
<%- end -%>
|
7
|
+
cluster_type = "<%= cluster.number_of_nodes == 1 ? "single-node" : "multi-node" %>"
|
8
|
+
node_type = "<%= cluster.node_type %>"
|
9
|
+
master_password = "xxxxxxxx"
|
10
|
+
master_username = "<%= cluster.master_username %>"
|
11
|
+
availability_zone = "<%= cluster.availability_zone %>"
|
12
|
+
preferred_maintenance_window = "<%= cluster.preferred_maintenance_window %>"
|
13
|
+
cluster_parameter_group_name = "<%= cluster.cluster_parameter_groups[0].parameter_group_name %>"
|
14
|
+
automated_snapshot_retention_period = "<%= cluster.automated_snapshot_retention_period %>"
|
15
|
+
port = "<%= cluster.endpoint.port %>"
|
16
|
+
cluster_version = "<%= cluster.cluster_version %>"
|
17
|
+
allow_version_upgrade = "<%= cluster.allow_version_upgrade %>"
|
18
|
+
number_of_nodes = "<%= cluster.number_of_nodes %>"
|
19
|
+
publicly_accessible = "<%= cluster.publicly_accessible %>"
|
20
|
+
encrypted = "<%= cluster.encrypted %>"
|
21
|
+
skip_final_snapshot = "true"
|
22
|
+
}
|
23
|
+
<% end -%>
|
data/lib/terraforming/version.rb
CHANGED
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.7"
|
23
23
|
spec.add_dependency "oj"
|
24
24
|
spec.add_dependency "ox"
|
25
25
|
spec.add_dependency "thor"
|
@@ -30,5 +30,6 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "guard-rspec"
|
31
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
32
|
spec.add_development_dependency "rspec", "~> 3.2"
|
33
|
+
spec.add_development_dependency "simplecov", "~> 0.11.1"
|
33
34
|
spec.add_development_dependency "terminal-notifier-guard"
|
34
35
|
end
|
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.
|
4
|
+
version: 0.7.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:
|
11
|
+
date: 2016-02-16 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.7
|
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.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: oj
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '3.2'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.11.1
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.11.1
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: terminal-notifier-guard
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,9 +217,11 @@ files:
|
|
203
217
|
- lib/terraforming/resource/iam_role_policy.rb
|
204
218
|
- lib/terraforming/resource/iam_user.rb
|
205
219
|
- lib/terraforming/resource/iam_user_policy.rb
|
220
|
+
- lib/terraforming/resource/internet_gateway.rb
|
206
221
|
- lib/terraforming/resource/network_acl.rb
|
207
222
|
- lib/terraforming/resource/network_interface.rb
|
208
223
|
- lib/terraforming/resource/rds.rb
|
224
|
+
- lib/terraforming/resource/redshift.rb
|
209
225
|
- lib/terraforming/resource/route53_record.rb
|
210
226
|
- lib/terraforming/resource/route53_zone.rb
|
211
227
|
- lib/terraforming/resource/route_table.rb
|
@@ -232,9 +248,11 @@ files:
|
|
232
248
|
- lib/terraforming/template/tf/iam_role_policy.erb
|
233
249
|
- lib/terraforming/template/tf/iam_user.erb
|
234
250
|
- lib/terraforming/template/tf/iam_user_policy.erb
|
251
|
+
- lib/terraforming/template/tf/internet_gateway.erb
|
235
252
|
- lib/terraforming/template/tf/network_acl.erb
|
236
253
|
- lib/terraforming/template/tf/network_interface.erb
|
237
254
|
- lib/terraforming/template/tf/rds.erb
|
255
|
+
- lib/terraforming/template/tf/redshift.erb
|
238
256
|
- lib/terraforming/template/tf/route53_record.erb
|
239
257
|
- lib/terraforming/template/tf/route53_zone.erb
|
240
258
|
- lib/terraforming/template/tf/route_table.erb
|
@@ -268,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
286
|
version: '0'
|
269
287
|
requirements: []
|
270
288
|
rubyforge_project:
|
271
|
-
rubygems_version: 2.
|
289
|
+
rubygems_version: 2.5.1
|
272
290
|
signing_key:
|
273
291
|
specification_version: 4
|
274
292
|
summary: Export existing AWS resources to Terraform style (tf, tfstate)
|