terraforming 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +1 -0
- data/lib/terraforming.rb +2 -0
- data/lib/terraforming/cli.rb +5 -0
- data/lib/terraforming/resource/dynamo_db.rb +282 -0
- data/lib/terraforming/resource/elasti_cache_cluster.rb +4 -0
- data/lib/terraforming/resource/security_group.rb +7 -0
- data/lib/terraforming/template/tf/dynamo_db.erb +66 -0
- data/lib/terraforming/template/tf/elasti_cache_cluster.erb +14 -11
- data/lib/terraforming/template/tf/iam_instance_profile.erb +2 -0
- data/lib/terraforming/template/tf/security_group.erb +6 -0
- data/lib/terraforming/version.rb +1 -1
- data/terraforming.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71530b97fa8db15ab2f9efc06acbf7ef9b136d6e7d61a74f1a78292541752daf
|
4
|
+
data.tar.gz: 240fe8b14101cbed18a41a89a02f2e734776e199ad192b132fccff6f9f46cb11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8b5e77dff8f227f471aa1a80ef8b39fb7e1fb709254979a947bc39d5e528d6db9ccba1ef2aa05e9485429fa07896883f03ca2af8d0ad61efd2aee7492f04c6d
|
7
|
+
data.tar.gz: 1c66dadaaaceaeae99c1e00f44679419fcd40f13a8ac529dfa8db11f1ebe04220b61466d51f3ea24614c8c5e8cc159d8470fa2092527352aab49bc6f076e3e9e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# [v0.18.0](https://github.com/dtan4/terraforming/releases/tag/v0.18.0) (2019-05-11)
|
2
|
+
|
3
|
+
## Resource
|
4
|
+
|
5
|
+
- AWS DynamoDB table [#440](https://github.com/dtan4/terraforming/pull/440) (thanks @laxmiprasanna-gunna)
|
6
|
+
|
7
|
+
## Fixed / Updated
|
8
|
+
|
9
|
+
- Rename symbol of DynamoDB [#457](https://github.com/dtan4/terraforming/pull/457)
|
10
|
+
- Add IPv6 support to AWS Security Group (`terraforming sg`) [#438](https://github.com/dtan4/terraforming/pull/438) (thanks @babbottscott)
|
11
|
+
- Render notification_topic_arn when exporting ElastiCache clusters [#436](https://github.com/dtan4/terraforming/pull/436) (thanks @mozamimy)
|
12
|
+
- Fix nil check of AWS IAM instance profiles (`terraforming iamip`) [#415](https://github.com/dtan4/terraforming/pull/415) (thanks @savankumargudaas)
|
13
|
+
|
14
|
+
## Fixed / Updated
|
15
|
+
|
16
|
+
- Support Ruby from 2.3 to 2.6
|
17
|
+
- Support the latest EFS client [#453](https://github.com/dtan4/terraforming/pull/453)
|
18
|
+
- Fix cross-account security group reference [#389](https://github.com/dtan4/terraforming/pull/389) (thanks @seren)
|
19
|
+
|
1
20
|
# [v0.17.0](https://github.com/dtan4/terraforming/releases/tag/v0.17.0) (2019-04-21)
|
2
21
|
|
3
22
|
## Fixed / Updated
|
data/README.md
CHANGED
@@ -89,6 +89,7 @@ Commands:
|
|
89
89
|
terraforming dbpg # Database Parameter Group
|
90
90
|
terraforming dbsg # Database Security Group
|
91
91
|
terraforming dbsn # Database Subnet Group
|
92
|
+
terraforming ddb # DynamoDB
|
92
93
|
terraforming ec2 # EC2
|
93
94
|
terraforming ecc # ElastiCache Cluster
|
94
95
|
terraforming ecsn # ElastiCache Subnet Group
|
data/lib/terraforming.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "aws-sdk-autoscaling"
|
2
2
|
require "aws-sdk-cloudwatch"
|
3
|
+
require "aws-sdk-dynamodb"
|
3
4
|
require "aws-sdk-ec2"
|
4
5
|
require "aws-sdk-efs"
|
5
6
|
require "aws-sdk-elasticache"
|
@@ -29,6 +30,7 @@ require "terraforming/resource/cloud_watch_alarm"
|
|
29
30
|
require "terraforming/resource/db_parameter_group"
|
30
31
|
require "terraforming/resource/db_security_group"
|
31
32
|
require "terraforming/resource/db_subnet_group"
|
33
|
+
require "terraforming/resource/dynamo_db"
|
32
34
|
require "terraforming/resource/ec2"
|
33
35
|
require "terraforming/resource/eip"
|
34
36
|
require "terraforming/resource/elasti_cache_cluster"
|
data/lib/terraforming/cli.rb
CHANGED
@@ -40,6 +40,11 @@ module Terraforming
|
|
40
40
|
execute(Terraforming::Resource::DBSubnetGroup, options)
|
41
41
|
end
|
42
42
|
|
43
|
+
desc "ddb", "DynamoDB"
|
44
|
+
def ddb
|
45
|
+
execute(Terraforming::Resource::DynamoDB, options)
|
46
|
+
end
|
47
|
+
|
43
48
|
desc "ec2", "EC2"
|
44
49
|
def ec2
|
45
50
|
execute(Terraforming::Resource::EC2, options)
|
@@ -0,0 +1,282 @@
|
|
1
|
+
module Terraforming
|
2
|
+
module Resource
|
3
|
+
class DynamoDB
|
4
|
+
include Terraforming::Util
|
5
|
+
def self.tf(client: Aws::DynamoDB::Client.new)
|
6
|
+
self.new(client).tf
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.tfstate(client: Aws::DynamoDB::Client.new)
|
10
|
+
self.new(client).tfstate
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(client)
|
14
|
+
@client = client
|
15
|
+
end
|
16
|
+
|
17
|
+
def tf
|
18
|
+
apply_template(@client, "tf/dynamo_db")
|
19
|
+
end
|
20
|
+
|
21
|
+
def tfstate
|
22
|
+
tables.inject({}) do |resources, dynamo_db_table|
|
23
|
+
attributes = {
|
24
|
+
"arn" => dynamo_db_table["table_arn"],
|
25
|
+
"id" => dynamo_db_table["table_name"],
|
26
|
+
"name" => dynamo_db_table["table_name"],
|
27
|
+
"read_capacity" => dynamo_db_table["provisioned_throughput"]["read_capacity_units"].to_s,
|
28
|
+
"stream_arn" => dynamo_db_table["latest_stream_arn"].to_s,
|
29
|
+
"stream_label" => dynamo_db_table["latest_stream_label"].to_s,
|
30
|
+
"write_capacity" => dynamo_db_table["provisioned_throughput"]["write_capacity_units"].to_s
|
31
|
+
}
|
32
|
+
|
33
|
+
attributes.merge!(attribute_definitions(dynamo_db_table))
|
34
|
+
attributes.merge!(global_indexes(dynamo_db_table))
|
35
|
+
attributes.merge!(local_indexes(dynamo_db_table))
|
36
|
+
attributes.merge!(key_schema(dynamo_db_table))
|
37
|
+
attributes.merge!(point_in_time_summary(dynamo_db_table))
|
38
|
+
attributes.merge!(sse_description(dynamo_db_table))
|
39
|
+
attributes.merge!(stream_specification(dynamo_db_table))
|
40
|
+
attributes.merge!(tags_of(dynamo_db_table))
|
41
|
+
attributes.merge!(ttl_of(dynamo_db_table))
|
42
|
+
|
43
|
+
resources["aws_dynamodb_table.#{module_name_of(dynamo_db_table)}"] = {
|
44
|
+
"type" => "aws_dynamodb_table",
|
45
|
+
"primary" => {
|
46
|
+
"id" => dynamo_db_table.table_name,
|
47
|
+
"attributes" => attributes,
|
48
|
+
"meta" => {
|
49
|
+
"schema_version" => "1"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
resources
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def tables
|
60
|
+
tables = []
|
61
|
+
dynamo_db_tables.each do |table|
|
62
|
+
attributes = @client.describe_table({
|
63
|
+
table_name: table
|
64
|
+
}).table
|
65
|
+
tables << attributes
|
66
|
+
end
|
67
|
+
return tables
|
68
|
+
end
|
69
|
+
|
70
|
+
def attribute_definitions(dynamo_db_table)
|
71
|
+
attributes = { "attribute.#" => dynamo_db_table["attribute_definitions"].length.to_s}
|
72
|
+
dynamo_db_table["attribute_definitions"].each do |attr_defn|
|
73
|
+
attributes.merge!(attributes_definitions_of(attr_defn))
|
74
|
+
end
|
75
|
+
attributes
|
76
|
+
end
|
77
|
+
|
78
|
+
def attributes_definitions_of(attr_defn)
|
79
|
+
hashcode = attribute_hashcode(attr_defn)
|
80
|
+
attributes = {
|
81
|
+
"attribute.#{hashcode}.name" => attr_defn.attribute_name,
|
82
|
+
"attribute.#{hashcode}.type" => attr_defn.attribute_type,
|
83
|
+
}
|
84
|
+
attributes
|
85
|
+
end
|
86
|
+
|
87
|
+
def attribute_hashcode(attr_defn)
|
88
|
+
hashcode = Zlib.crc32(attr_defn.attribute_name+"-")
|
89
|
+
end
|
90
|
+
|
91
|
+
def global_indexes(dynamo_db_table)
|
92
|
+
attributes = {}
|
93
|
+
if dynamo_db_table["global_secondary_indexes"]
|
94
|
+
attributes = { "global_secondary_index.#" => dynamo_db_table["global_secondary_indexes"].length.to_s}
|
95
|
+
dynamo_db_table["global_secondary_indexes"].each do |global_sec_index|
|
96
|
+
attributes.merge!(global_secondary_indexes_of(global_sec_index))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
return attributes
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def global_secondary_indexes_of(global_sec_index)
|
104
|
+
attributes = global_indexes_of(global_sec_index).merge!(global_index_non_key_attributes(global_sec_index))
|
105
|
+
end
|
106
|
+
|
107
|
+
def global_indexes_of(global_sec_index)
|
108
|
+
hashcode = global_index_hashcode(global_sec_index)
|
109
|
+
attributes = {
|
110
|
+
"global_secondary_index.#{hashcode}.hash_key" => find_key(global_sec_index,"HASH"),
|
111
|
+
"global_secondary_index.#{hashcode}.name" => global_sec_index.index_name,
|
112
|
+
"global_secondary_index.#{hashcode}.projection_type" => global_sec_index.projection.projection_type,
|
113
|
+
"global_secondary_index.#{hashcode}.range_key" => find_key(global_sec_index,"RANGE"),
|
114
|
+
"global_secondary_index.#{hashcode}.read_capacity" => global_sec_index.provisioned_throughput.read_capacity_units.to_s ,
|
115
|
+
"global_secondary_index.#{hashcode}.write_capacity" => global_sec_index.provisioned_throughput.write_capacity_units.to_s,
|
116
|
+
}
|
117
|
+
attributes
|
118
|
+
end
|
119
|
+
|
120
|
+
def find_key(index,key_type)
|
121
|
+
index["key_schema"].each do |schema|
|
122
|
+
if schema.key_type == key_type
|
123
|
+
return schema.attribute_name
|
124
|
+
else
|
125
|
+
return ""
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def global_index_non_key_attributes(global_sec_index)
|
131
|
+
attributes = {}
|
132
|
+
if !global_sec_index["projection"]["non_key_attributes"].nil?
|
133
|
+
hashcode = global_index_hashcode(global_sec_index)
|
134
|
+
attributes = {"global_secondary_index.#{hashcode}.non_key_attributes.#" => global_sec_index["projection"]["non_key_attributes"].length.to_s}
|
135
|
+
(0..global_sec_index["projection"]["non_key_attributes"].length.to_i-1).each do |index|
|
136
|
+
attributes.merge!({"global_secondary_index.#{hashcode}.non_key_attributes.#{index}" => global_sec_index["projection"]["non_key_attributes"][index]})
|
137
|
+
end
|
138
|
+
end
|
139
|
+
attributes
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def global_index_hashcode(global_sec_index)
|
144
|
+
Zlib.crc32(global_sec_index["index_name"]+"-")
|
145
|
+
end
|
146
|
+
|
147
|
+
def local_indexes(dynamo_db_table)
|
148
|
+
attributes = {}
|
149
|
+
if dynamo_db_table["local_secondary_indexes"]
|
150
|
+
attributes = {"local_secondary_index.#" => dynamo_db_table["local_secondary_indexes"].length.to_s}
|
151
|
+
dynamo_db_table["local_secondary_indexes"].each do |local_sec_index|
|
152
|
+
attributes.merge!(local_secondary_indexes_of(local_sec_index))
|
153
|
+
end
|
154
|
+
end
|
155
|
+
return attributes
|
156
|
+
end
|
157
|
+
|
158
|
+
def local_secondary_indexes_of(local_sec_index)
|
159
|
+
attributes = {}
|
160
|
+
hashcode = local_index_hashcode(local_sec_index)
|
161
|
+
attributes.merge!("local_secondary_index.#{hashcode}.range_key" => find_key(local_sec_index,"RANGE")) if !find_key(local_sec_index,"RANGE").empty?
|
162
|
+
attributes.merge!({
|
163
|
+
"local_secondary_index.#{hashcode}.name" => local_sec_index.index_name,
|
164
|
+
"local_secondary_index.#{hashcode}.projection_type" => local_sec_index.projection.projection_type,
|
165
|
+
})
|
166
|
+
attributes.merge!(local_index_non_key_attributes(local_sec_index))
|
167
|
+
attributes
|
168
|
+
end
|
169
|
+
|
170
|
+
def local_index_non_key_attributes(local_sec_index)
|
171
|
+
attributes = {}
|
172
|
+
if !local_sec_index["projection"]["non_key_attributes"].nil?
|
173
|
+
hashcode = local_index_hashcode(local_sec_index)
|
174
|
+
attributes = {"local_secondary_index.#{hashcode}.non_key_attributes.#" => local_sec_index["projection"]["non_key_attributes"].length.to_s}
|
175
|
+
(0..local_sec_index["projection"]["non_key_attributes"].length.to_i-1).each do |index|
|
176
|
+
attributes.merge!({"local_secondary_index.#{hashcode}.non_key_attributes.#{index}" => local_sec_index["projection"]["non_key_attributes"][index]})
|
177
|
+
end
|
178
|
+
end
|
179
|
+
attributes
|
180
|
+
end
|
181
|
+
|
182
|
+
def local_index_hashcode(local_index)
|
183
|
+
Zlib.crc32(local_index["index_name"]+"-")
|
184
|
+
end
|
185
|
+
|
186
|
+
def key_schema(dynamo_db_table)
|
187
|
+
attributes = {}
|
188
|
+
if dynamo_db_table["key_schema"]
|
189
|
+
attributes = {"key_schema.#" => dynamo_db_table["key_schema"].length.to_s}
|
190
|
+
if !find_key(dynamo_db_table,"HASH").empty?
|
191
|
+
attributes.merge!({"hash_key" => find_key(dynamo_db_table,"HASH")})
|
192
|
+
end
|
193
|
+
end
|
194
|
+
attributes
|
195
|
+
end
|
196
|
+
|
197
|
+
def point_in_time_summary(dynamo_db_table)
|
198
|
+
resp = @client.describe_continuous_backups({
|
199
|
+
table_name: dynamo_db_table["table_name"]
|
200
|
+
})
|
201
|
+
if resp.continuous_backups_description.point_in_time_recovery_description.point_in_time_recovery_status == "ENABLED"
|
202
|
+
attributes = {"point_in_time_recovery.#" => 1.to_s}
|
203
|
+
attributes.merge!({"point_in_time_recovery.0.enabled" => true.to_s})
|
204
|
+
else
|
205
|
+
attributes = {"point_in_time_recovery.#" => 0.to_s}
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def sse_description(dynamo_db_table)
|
210
|
+
attributes = {}
|
211
|
+
if dynamo_db_table.sse_description
|
212
|
+
if dynamo_db_table.sse_description.status == "ENABLED"
|
213
|
+
attributes = {"server_side_encryption.#" => 1.to_s}
|
214
|
+
attributes.merge!({"server_side_encryption.0.enabled" => true.to_s})
|
215
|
+
end
|
216
|
+
else
|
217
|
+
attributes.merge!({"server_side_encryption.#" => 0.to_s})
|
218
|
+
end
|
219
|
+
attributes
|
220
|
+
end
|
221
|
+
|
222
|
+
def stream_specification(dynamo_db_table)
|
223
|
+
attributes = {}
|
224
|
+
if dynamo_db_table.stream_specification
|
225
|
+
attributes = {"stream_view_type" => dynamo_db_table.stream_specification.stream_view_type} if dynamo_db_table.stream_specification.stream_enabled
|
226
|
+
end
|
227
|
+
attributes
|
228
|
+
end
|
229
|
+
|
230
|
+
def ttl_of(dynamo_db_table)
|
231
|
+
attributes = {}
|
232
|
+
ttl = ttl_values(dynamo_db_table)
|
233
|
+
if !ttl.empty?
|
234
|
+
hashcode = ttl_hashcode(ttl.first)
|
235
|
+
attributes = {"ttl.#" => 1.to_s}
|
236
|
+
attributes["ttl.#{hashcode}.attribute_name"] = ttl.first
|
237
|
+
attributes["ttl.#{hashcode}.enabled"] = true.to_s
|
238
|
+
end
|
239
|
+
return attributes
|
240
|
+
end
|
241
|
+
|
242
|
+
def ttl_hashcode(attribute)
|
243
|
+
Zlib.crc32(attribute)
|
244
|
+
end
|
245
|
+
|
246
|
+
def tags_of(dynamo_db_table)
|
247
|
+
attributes = {}
|
248
|
+
tags = tags(dynamo_db_table)
|
249
|
+
if !tags.empty?
|
250
|
+
attributes = { "tags.%" => tags.length.to_s }
|
251
|
+
tags.each do |tag|
|
252
|
+
attributes["tags.#{tag.key}"] = tag.value
|
253
|
+
end
|
254
|
+
end
|
255
|
+
attributes
|
256
|
+
end
|
257
|
+
|
258
|
+
def dynamo_db_tables
|
259
|
+
a = @client.list_tables.map(&:table_names).flatten
|
260
|
+
end
|
261
|
+
|
262
|
+
def ttl_values(dynamo_db_table)
|
263
|
+
ttl = @client.describe_time_to_live({
|
264
|
+
table_name: dynamo_db_table.table_name
|
265
|
+
}).time_to_live_description
|
266
|
+
if ttl.time_to_live_status == "ENABLED"
|
267
|
+
return [ttl.attribute_name]
|
268
|
+
else
|
269
|
+
return []
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def tags(dynamo_db_table)
|
274
|
+
resp = @client.list_tags_of_resource({resource_arn: dynamo_db_table.table_arn}).tags
|
275
|
+
end
|
276
|
+
|
277
|
+
def module_name_of(dynamo_db_table)
|
278
|
+
normalize_module_name(dynamo_db_table['table_name'])
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
@@ -42,6 +42,10 @@ module Terraforming
|
|
42
42
|
cache_cluster.cache_nodes[0].endpoint.port.to_s
|
43
43
|
end
|
44
44
|
|
45
|
+
if cache_cluster.notification_configuration
|
46
|
+
attributes["notification_topic_arn"] = cache_cluster.notification_configuration.topic_arn
|
47
|
+
end
|
48
|
+
|
45
49
|
resources["aws_elasticache_cluster.#{module_name_of(cache_cluster)}"] = {
|
46
50
|
"type" => "aws_elasticache_cluster",
|
47
51
|
"primary" => {
|
@@ -92,6 +92,7 @@ module Terraforming
|
|
92
92
|
"#{type}.#{hashcode}.to_port" => (permission.to_port || 0).to_s,
|
93
93
|
"#{type}.#{hashcode}.protocol" => permission.ip_protocol,
|
94
94
|
"#{type}.#{hashcode}.cidr_blocks.#" => permission.ip_ranges.length.to_s,
|
95
|
+
"#{type}.#{hashcode}.ipv6_cidr_blocks.#" => permission.ipv_6_ranges.length.to_s,
|
95
96
|
"#{type}.#{hashcode}.prefix_list_ids.#" => permission.prefix_list_ids.length.to_s,
|
96
97
|
"#{type}.#{hashcode}.security_groups.#" => security_groups.length.to_s,
|
97
98
|
"#{type}.#{hashcode}.self" => self_referenced_permission?(security_group, permission).to_s,
|
@@ -101,6 +102,10 @@ module Terraforming
|
|
101
102
|
attributes["#{type}.#{hashcode}.cidr_blocks.#{index}"] = range.cidr_ip
|
102
103
|
end
|
103
104
|
|
105
|
+
permission.ipv_6_ranges.each_with_index do |range, index|
|
106
|
+
attributes["#{type}.#{hashcode}.ipv6_cidr_blocks.#{index}"] = range.cidr_ipv_6
|
107
|
+
end
|
108
|
+
|
104
109
|
permission.prefix_list_ids.each_with_index do |prefix_list, index|
|
105
110
|
attributes["#{type}.#{hashcode}.prefix_list_ids.#{index}"] = prefix_list.prefix_list_id
|
106
111
|
end
|
@@ -136,6 +141,7 @@ module Terraforming
|
|
136
141
|
permissions.each do |permission|
|
137
142
|
master_permission.user_id_group_pairs.concat(permission.user_id_group_pairs)
|
138
143
|
master_permission.ip_ranges.concat(permission.ip_ranges)
|
144
|
+
master_permission.ipv_6_ranges.concat(permission.ipv_6_ranges)
|
139
145
|
end
|
140
146
|
|
141
147
|
master_permission
|
@@ -149,6 +155,7 @@ module Terraforming
|
|
149
155
|
"#{self_referenced_permission?(security_group, permission)}-"
|
150
156
|
|
151
157
|
permission.ip_ranges.each { |range| string << "#{range.cidr_ip}-" }
|
158
|
+
permission.ipv_6_ranges.each { |range| string << "#{range.cidr_ipv_6}-" }
|
152
159
|
security_groups_in(permission, security_group).each { |group| string << "#{group}-" }
|
153
160
|
|
154
161
|
Zlib.crc32(string)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<%- tables.each do |table| -%>
|
2
|
+
resource "aws_dynamodb_table" "<%= table.table_name -%>" {
|
3
|
+
name = "<%= table.table_name -%>"
|
4
|
+
read_capacity = <%= table.provisioned_throughput.read_capacity_units %>
|
5
|
+
write_capacity = <%= table.provisioned_throughput.write_capacity_units %>
|
6
|
+
<%- table.key_schema.each do |key| -%>
|
7
|
+
<%= key.key_type.downcase -%>_key = <%= key.attribute_name.inspect %>
|
8
|
+
<%- end %>
|
9
|
+
<%- table.attribute_definitions.each do |attribute| -%>
|
10
|
+
attribute {
|
11
|
+
name = "<%= attribute.attribute_name -%>"
|
12
|
+
type = "<%= attribute.attribute_type -%>"
|
13
|
+
}
|
14
|
+
<%- end -%>
|
15
|
+
<%- ttl_values(table).each do |attr| -%>
|
16
|
+
ttl {
|
17
|
+
attribute_name = <%= attr.inspect %>
|
18
|
+
enabled = true
|
19
|
+
}
|
20
|
+
<%- end -%>
|
21
|
+
<%- Array(table.global_secondary_indexes).each do |index| -%>
|
22
|
+
global_secondary_index {
|
23
|
+
name = "<%= index.index_name -%>"
|
24
|
+
<%- index.key_schema.each do |key| -%>
|
25
|
+
<%= key.key_type.downcase -%>_key = "<%= key.attribute_name -%>"
|
26
|
+
<%- end -%>
|
27
|
+
read_capacity = <%= index.provisioned_throughput.read_capacity_units %>
|
28
|
+
write_capacity = <%= index.provisioned_throughput.write_capacity_units %>
|
29
|
+
projection_type = "<%= index.projection.projection_type %>"
|
30
|
+
<%- keys = index.projection.non_key_attributes -%>
|
31
|
+
<%- if Array(keys).size > 0 -%>
|
32
|
+
non_key_attributes = <%= keys.inspect -%>
|
33
|
+
<%- end %>
|
34
|
+
}
|
35
|
+
<%- end -%>
|
36
|
+
<%- Array(table.local_secondary_indexes).each do |index| -%>
|
37
|
+
local_secondary_index {
|
38
|
+
name = "<%= index.index_name -%>"
|
39
|
+
<%- index.key_schema.each do |key| -%>
|
40
|
+
<%- if key.key_type.downcase == "range" -%>
|
41
|
+
<%= key.key_type.downcase -%>_key = "<%= key.attribute_name -%>"
|
42
|
+
<%- end -%>
|
43
|
+
<%- end -%>
|
44
|
+
projection_type = "<%= index.projection.projection_type -%>"
|
45
|
+
<%- keys = index.projection.non_key_attributes -%>
|
46
|
+
<%- if Array(keys).size > 0 -%>
|
47
|
+
non_key_attributes = <%= keys.inspect -%>
|
48
|
+
<%- end %>
|
49
|
+
}
|
50
|
+
<%- end -%>
|
51
|
+
<%- tags(table).each do |tag| -%>
|
52
|
+
tags {
|
53
|
+
<%= tag.key %> = "<%= tag.value -%>"
|
54
|
+
}
|
55
|
+
<%- end -%>
|
56
|
+
<%- if table.stream_specification -%>
|
57
|
+
stream_enabled = <%= table.stream_specification.stream_enabled %>
|
58
|
+
stream_view_type = <%= table.stream_specification.stream_view_type.inspect %>
|
59
|
+
<%- end -%>
|
60
|
+
<%- if table.sse_description -%>
|
61
|
+
server_side_encryption {
|
62
|
+
enabled = true
|
63
|
+
}
|
64
|
+
<%- end -%>
|
65
|
+
}
|
66
|
+
<%- end -%>
|
@@ -1,21 +1,24 @@
|
|
1
1
|
<% cache_clusters.each do |cache_cluster| -%>
|
2
2
|
resource "aws_elasticache_cluster" "<%= module_name_of(cache_cluster) %>" {
|
3
|
-
cluster_id
|
4
|
-
engine
|
5
|
-
engine_version
|
6
|
-
node_type
|
7
|
-
num_cache_nodes
|
8
|
-
parameter_group_name
|
3
|
+
cluster_id = "<%= cache_cluster.cache_cluster_id %>"
|
4
|
+
engine = "<%= cache_cluster.engine %>"
|
5
|
+
engine_version = "<%= cache_cluster.engine_version %>"
|
6
|
+
node_type = "<%= cache_cluster.cache_node_type %>"
|
7
|
+
num_cache_nodes = <%= cache_cluster.num_cache_nodes %>
|
8
|
+
parameter_group_name = "<%= cache_cluster.cache_parameter_group.cache_parameter_group_name %>"
|
9
9
|
<%- if cache_cluster.configuration_endpoint -%>
|
10
|
-
port
|
10
|
+
port = <%= cache_cluster.configuration_endpoint.port %>
|
11
11
|
<%- else -%>
|
12
|
-
port
|
12
|
+
port = <%= cache_cluster.cache_nodes[0].endpoint.port %>
|
13
13
|
<%- end -%>
|
14
14
|
<%- if cluster_in_vpc?(cache_cluster) -%>
|
15
|
-
subnet_group_name
|
16
|
-
security_group_ids
|
15
|
+
subnet_group_name = "<%= cache_cluster.cache_subnet_group_name %>"
|
16
|
+
security_group_ids = <%= security_group_ids_of(cache_cluster).inspect %>
|
17
17
|
<%- else -%>
|
18
|
-
security_group_names
|
18
|
+
security_group_names = <%= security_group_names_of(cache_cluster).inspect %>
|
19
|
+
<%- end -%>
|
20
|
+
<%- if cache_cluster.notification_configuration -%>
|
21
|
+
notification_topic_arn = "<%= cache_cluster.notification_configuration.topic_arn %>"
|
19
22
|
<%- end -%>
|
20
23
|
}
|
21
24
|
|
@@ -2,7 +2,9 @@
|
|
2
2
|
resource "aws_iam_instance_profile" "<%= module_name_of(profile) %>" {
|
3
3
|
name = "<%= profile.instance_profile_name %>"
|
4
4
|
path = "<%= profile.path %>"
|
5
|
+
<%- if profile.roles[0] != nil -%>
|
5
6
|
role = "<%= profile.roles[0].role_name %>"
|
7
|
+
<%- end -%>
|
6
8
|
}
|
7
9
|
|
8
10
|
<% end -%>
|
@@ -16,6 +16,9 @@ resource "aws_security_group" "<%= module_name_of(security_group) %>" {
|
|
16
16
|
<%- if permission.ip_ranges.length > 0 -%>
|
17
17
|
cidr_blocks = <%= permission.ip_ranges.map { |range| range.cidr_ip }.inspect %>
|
18
18
|
<%- end -%>
|
19
|
+
<%- if permission.ipv_6_ranges.length > 0 -%>
|
20
|
+
ipv6_cidr_blocks = <%= permission.ipv_6_ranges.map { |range| range.cidr_ipv_6 }.inspect %>
|
21
|
+
<%- end -%>
|
19
22
|
<%- if permission.user_id_group_pairs.length > 0 -%>
|
20
23
|
<%- self_referenced = self_referenced_permission?(security_group, permission) -%>
|
21
24
|
security_groups = <%= security_groups.inspect %>
|
@@ -36,6 +39,9 @@ resource "aws_security_group" "<%= module_name_of(security_group) %>" {
|
|
36
39
|
<%- if permission.ip_ranges.length > 0 -%>
|
37
40
|
cidr_blocks = <%= permission.ip_ranges.map { |range| range.cidr_ip }.inspect %>
|
38
41
|
<%- end -%>
|
42
|
+
<%- if permission.ipv_6_ranges.length > 0 -%>
|
43
|
+
ipv6_cidr_blocks = <%= permission.ipv_6_ranges.map { |range| range.cidr_ipv_6 }.inspect %>
|
44
|
+
<%- end -%>
|
39
45
|
<%- if permission.user_id_group_pairs.length > 0 -%>
|
40
46
|
<%- self_referenced = self_referenced_permission?(security_group, permission) -%>
|
41
47
|
security_groups = <%= security_groups_in(permission, security_group).reject { |group_id| group_id == security_group.group_id }.inspect %>
|
data/lib/terraforming/version.rb
CHANGED
data/terraforming.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_dependency "aws-sdk-autoscaling", "~> 1"
|
23
23
|
spec.add_dependency "aws-sdk-cloudwatch", "~> 1"
|
24
|
+
spec.add_dependency "aws-sdk-dynamodb", "~> 1.18"
|
24
25
|
spec.add_dependency "aws-sdk-ec2", "~> 1"
|
25
26
|
spec.add_dependency "aws-sdk-efs", "~> 1", ">= 1.13.0"
|
26
27
|
spec.add_dependency "aws-sdk-elasticache", "~> 1"
|
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
|
+
version: 0.18.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: 2019-
|
11
|
+
date: 2019-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-autoscaling
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-sdk-dynamodb
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.18'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.18'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: aws-sdk-ec2
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -340,6 +354,7 @@ files:
|
|
340
354
|
- lib/terraforming/resource/db_parameter_group.rb
|
341
355
|
- lib/terraforming/resource/db_security_group.rb
|
342
356
|
- lib/terraforming/resource/db_subnet_group.rb
|
357
|
+
- lib/terraforming/resource/dynamo_db.rb
|
343
358
|
- lib/terraforming/resource/ec2.rb
|
344
359
|
- lib/terraforming/resource/efs_file_system.rb
|
345
360
|
- lib/terraforming/resource/eip.rb
|
@@ -383,6 +398,7 @@ files:
|
|
383
398
|
- lib/terraforming/template/tf/db_parameter_group.erb
|
384
399
|
- lib/terraforming/template/tf/db_security_group.erb
|
385
400
|
- lib/terraforming/template/tf/db_subnet_group.erb
|
401
|
+
- lib/terraforming/template/tf/dynamo_db.erb
|
386
402
|
- lib/terraforming/template/tf/ec2.erb
|
387
403
|
- lib/terraforming/template/tf/eip.erb
|
388
404
|
- lib/terraforming/template/tf/elasti_cache_cluster.erb
|