This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
/
dynamo_db.erb
66 lines (66 loc) · 2.38 KB
/
dynamo_db.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<%- tables.each do |table| -%>
resource "aws_dynamodb_table" "<%= table.table_name -%>" {
name = "<%= table.table_name -%>"
read_capacity = <%= table.provisioned_throughput.read_capacity_units %>
write_capacity = <%= table.provisioned_throughput.write_capacity_units %>
<%- table.key_schema.each do |key| -%>
<%= key.key_type.downcase -%>_key = <%= key.attribute_name.inspect %>
<%- end %>
<%- table.attribute_definitions.each do |attribute| -%>
attribute {
name = "<%= attribute.attribute_name -%>"
type = "<%= attribute.attribute_type -%>"
}
<%- end -%>
<%- ttl_values(table).each do |attr| -%>
ttl {
attribute_name = <%= attr.inspect %>
enabled = true
}
<%- end -%>
<%- Array(table.global_secondary_indexes).each do |index| -%>
global_secondary_index {
name = "<%= index.index_name -%>"
<%- index.key_schema.each do |key| -%>
<%= key.key_type.downcase -%>_key = "<%= key.attribute_name -%>"
<%- end -%>
read_capacity = <%= index.provisioned_throughput.read_capacity_units %>
write_capacity = <%= index.provisioned_throughput.write_capacity_units %>
projection_type = "<%= index.projection.projection_type %>"
<%- keys = index.projection.non_key_attributes -%>
<%- if Array(keys).size > 0 -%>
non_key_attributes = <%= keys.inspect -%>
<%- end %>
}
<%- end -%>
<%- Array(table.local_secondary_indexes).each do |index| -%>
local_secondary_index {
name = "<%= index.index_name -%>"
<%- index.key_schema.each do |key| -%>
<%- if key.key_type.downcase == "range" -%>
<%= key.key_type.downcase -%>_key = "<%= key.attribute_name -%>"
<%- end -%>
<%- end -%>
projection_type = "<%= index.projection.projection_type -%>"
<%- keys = index.projection.non_key_attributes -%>
<%- if Array(keys).size > 0 -%>
non_key_attributes = <%= keys.inspect -%>
<%- end %>
}
<%- end -%>
<%- tags(table).each do |tag| -%>
tags {
<%= tag.key %> = "<%= tag.value -%>"
}
<%- end -%>
<%- if table.stream_specification -%>
stream_enabled = <%= table.stream_specification.stream_enabled %>
stream_view_type = <%= table.stream_specification.stream_view_type.inspect %>
<%- end -%>
<%- if table.sse_description -%>
server_side_encryption {
enabled = true
}
<%- end -%>
}
<%- end -%>