Skip to content

Commit 79df43d

Browse files
committed
move dynamo tables into modules
1 parent fed9476 commit 79df43d

File tree

3 files changed

+205
-358
lines changed

3 files changed

+205
-358
lines changed

terraform/envs/prod/main.tf

Lines changed: 23 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -60,41 +60,8 @@ module "lambda_warmer" {
6060
source = "github.com/acm-uiuc/terraform-modules/lambda-warmer?ref=v0.1.1"
6161
function_to_warm = "infra-core-api-lambda"
6262
}
63-
import {
64-
id = "${var.ProjectId}-membership-external-v3"
65-
to = aws_dynamodb_table.external_membership
66-
}
67-
68-
import {
69-
id = "${var.ProjectId}-iam-grouproles"
70-
to = aws_dynamodb_table.iam_group_roles
71-
}
72-
73-
import {
74-
id = "${var.ProjectId}-iam-userroles"
75-
to = aws_dynamodb_table.iam_user_roles
76-
}
77-
78-
import {
79-
id = "${var.ProjectId}-events"
80-
to = aws_dynamodb_table.events
81-
}
82-
83-
import {
84-
id = "${var.ProjectId}-stripe-links"
85-
to = aws_dynamodb_table.stripe_links
86-
}
87-
88-
import {
89-
id = "${var.ProjectId}-linkry"
90-
to = aws_dynamodb_table.linkry_records
91-
}
92-
93-
import {
94-
id = "${var.ProjectId}-cache"
95-
to = aws_dynamodb_table.cache
96-
}
9763

64+
// This section last: moved records into modules
9865
moved {
9966
from = aws_dynamodb_table.app_audit_log
10067
to = module.dynamo.aws_dynamodb_table.app_audit_log
@@ -121,161 +88,38 @@ moved {
12188
to = module.dynamo.aws_dynamodb_table.room_requests_status
12289
}
12390

124-
125-
resource "aws_dynamodb_table" "external_membership" {
126-
billing_mode = "PAY_PER_REQUEST"
127-
name = "${var.ProjectId}-membership-external-v3"
128-
deletion_protection_enabled = true
129-
hash_key = "memberList"
130-
range_key = "netId"
131-
point_in_time_recovery {
132-
enabled = true
133-
}
134-
attribute {
135-
name = "netId"
136-
type = "S"
137-
}
138-
139-
attribute {
140-
name = "memberList"
141-
type = "S"
142-
}
143-
144-
global_secondary_index {
145-
name = "invertedIndex"
146-
hash_key = "netId"
147-
range_key = "memberList"
148-
projection_type = "KEYS_ONLY"
149-
}
150-
151-
152-
global_secondary_index {
153-
name = "keysOnlyIndex"
154-
hash_key = "memberList"
155-
projection_type = "KEYS_ONLY"
156-
}
157-
91+
moved {
92+
from = aws_dynamodb_table.external_membership
93+
to = module.dynamo.aws_dynamodb_table.external_membership
15894
}
15995

160-
resource "aws_dynamodb_table" "iam_group_roles" {
161-
billing_mode = "PAY_PER_REQUEST"
162-
name = "${var.ProjectId}-iam-grouproles"
163-
deletion_protection_enabled = true
164-
hash_key = "groupUuid"
165-
point_in_time_recovery {
166-
enabled = true
167-
}
168-
attribute {
169-
name = "groupUuid"
170-
type = "S"
171-
}
96+
moved {
97+
from = aws_dynamodb_table.iam_group_roles
98+
to = module.dynamo.aws_dynamodb_table.iam_group_roles
17299
}
173100

174-
resource "aws_dynamodb_table" "iam_user_roles" {
175-
billing_mode = "PAY_PER_REQUEST"
176-
name = "${var.ProjectId}-iam-userroles"
177-
deletion_protection_enabled = true
178-
hash_key = "userEmail"
179-
point_in_time_recovery {
180-
enabled = true
181-
}
182-
attribute {
183-
name = "userEmail"
184-
type = "S"
185-
}
101+
moved {
102+
from = aws_dynamodb_table.iam_user_roles
103+
to = module.dynamo.aws_dynamodb_table.iam_user_roles
186104
}
187105

188-
189-
resource "aws_dynamodb_table" "events" {
190-
billing_mode = "PAY_PER_REQUEST"
191-
name = "${var.ProjectId}-events"
192-
deletion_protection_enabled = true
193-
hash_key = "id"
194-
point_in_time_recovery {
195-
enabled = true
196-
}
197-
attribute {
198-
name = "id"
199-
type = "S"
200-
}
201-
attribute {
202-
name = "host"
203-
type = "S"
204-
}
205-
global_secondary_index {
206-
name = "HostIndex"
207-
hash_key = "host"
208-
projection_type = "ALL"
209-
}
106+
moved {
107+
from = aws_dynamodb_table.events
108+
to = module.dynamo.aws_dynamodb_table.events
210109
}
211110

212-
resource "aws_dynamodb_table" "stripe_links" {
213-
billing_mode = "PAY_PER_REQUEST"
214-
name = "${var.ProjectId}-stripe-links"
215-
deletion_protection_enabled = true
216-
hash_key = "userId"
217-
range_key = "linkId"
218-
219-
point_in_time_recovery {
220-
enabled = true
221-
}
222-
attribute {
223-
name = "userId"
224-
type = "S"
225-
}
226-
227-
attribute {
228-
name = "linkId"
229-
type = "S"
230-
}
231-
global_secondary_index {
232-
name = "LinkIdIndex"
233-
hash_key = "linkId"
234-
projection_type = "ALL"
235-
}
111+
moved {
112+
from = aws_dynamodb_table.stripe_links
113+
to = module.dynamo.aws_dynamodb_table.stripe_links
236114
}
237115

238-
resource "aws_dynamodb_table" "linkry_records" {
239-
billing_mode = "PAY_PER_REQUEST"
240-
name = "${var.ProjectId}-linkry"
241-
deletion_protection_enabled = true
242-
hash_key = "slug"
243-
range_key = "access"
244-
245-
point_in_time_recovery {
246-
enabled = true
247-
}
248-
attribute {
249-
name = "slug"
250-
type = "S"
251-
}
252-
attribute {
253-
name = "access"
254-
type = "S"
255-
}
256-
257-
global_secondary_index {
258-
name = "AccessIndex"
259-
hash_key = "access"
260-
range_key = "slug"
261-
projection_type = "ALL"
262-
}
116+
moved {
117+
from = aws_dynamodb_table.linkry_records
118+
to = module.dynamo.aws_dynamodb_table.linkry_records
263119
}
264120

265-
resource "aws_dynamodb_table" "cache" {
266-
billing_mode = "PAY_PER_REQUEST"
267-
name = "${var.ProjectId}-cache"
268-
deletion_protection_enabled = true
269-
hash_key = "primaryKey"
270-
point_in_time_recovery {
271-
enabled = false
272-
}
273-
attribute {
274-
name = "primaryKey"
275-
type = "S"
276-
}
277-
ttl {
278-
attribute_name = "expireAt"
279-
enabled = true
280-
}
121+
122+
moved {
123+
from = aws_dynamodb_table.cache
124+
to = module.dynamo.aws_dynamodb_table.cache
281125
}

0 commit comments

Comments
 (0)