Skip to content

Commit 43e7a81

Browse files
committed
import all dynamodb tables into terraform
1 parent ccce212 commit 43e7a81

File tree

3 files changed

+310
-138
lines changed

3 files changed

+310
-138
lines changed

cloudformation/main.yml

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -305,144 +305,6 @@ Resources:
305305
FunctionResponseTypes:
306306
- ReportBatchItemFailures
307307

308-
IamGroupRolesTable:
309-
Type: "AWS::DynamoDB::Table"
310-
DeletionPolicy: "Retain"
311-
UpdateReplacePolicy: "Retain"
312-
Properties:
313-
BillingMode: "PAY_PER_REQUEST"
314-
TableName: infra-core-api-iam-grouproles
315-
DeletionProtectionEnabled: true
316-
PointInTimeRecoverySpecification:
317-
PointInTimeRecoveryEnabled: false
318-
AttributeDefinitions:
319-
- AttributeName: groupUuid
320-
AttributeType: S
321-
KeySchema:
322-
- AttributeName: groupUuid
323-
KeyType: HASH
324-
325-
IamUserRolesTable:
326-
Type: "AWS::DynamoDB::Table"
327-
DeletionPolicy: "Retain"
328-
UpdateReplacePolicy: "Retain"
329-
Properties:
330-
BillingMode: "PAY_PER_REQUEST"
331-
TableName: infra-core-api-iam-userroles
332-
DeletionProtectionEnabled: true
333-
PointInTimeRecoverySpecification:
334-
PointInTimeRecoveryEnabled: false
335-
AttributeDefinitions:
336-
- AttributeName: userEmail
337-
AttributeType: S
338-
KeySchema:
339-
- AttributeName: userEmail
340-
KeyType: HASH
341-
342-
EventRecordsTable:
343-
Type: "AWS::DynamoDB::Table"
344-
DeletionPolicy: "Retain"
345-
UpdateReplacePolicy: "Retain"
346-
Properties:
347-
BillingMode: "PAY_PER_REQUEST"
348-
TableName: infra-core-api-events
349-
DeletionProtectionEnabled: true
350-
PointInTimeRecoverySpecification:
351-
PointInTimeRecoveryEnabled: !If [IsProd, true, false]
352-
AttributeDefinitions:
353-
- AttributeName: id
354-
AttributeType: S
355-
- AttributeName: host
356-
AttributeType: S
357-
KeySchema:
358-
- AttributeName: id
359-
KeyType: HASH
360-
GlobalSecondaryIndexes:
361-
- IndexName: HostIndex
362-
KeySchema:
363-
- AttributeName: host
364-
KeyType: HASH
365-
Projection:
366-
ProjectionType: ALL
367-
368-
StripeLinksTable:
369-
Type: "AWS::DynamoDB::Table"
370-
DeletionPolicy: "Retain"
371-
UpdateReplacePolicy: "Retain"
372-
Properties:
373-
BillingMode: "PAY_PER_REQUEST"
374-
TableName: infra-core-api-stripe-links
375-
DeletionProtectionEnabled: true
376-
PointInTimeRecoverySpecification:
377-
PointInTimeRecoveryEnabled: false
378-
AttributeDefinitions:
379-
- AttributeName: userId
380-
AttributeType: S
381-
- AttributeName: linkId
382-
AttributeType: S
383-
KeySchema:
384-
- AttributeName: userId
385-
KeyType: "HASH"
386-
- AttributeName: linkId
387-
KeyType: "RANGE"
388-
GlobalSecondaryIndexes:
389-
- IndexName: LinkIdIndex
390-
KeySchema:
391-
- AttributeName: linkId
392-
KeyType: "HASH"
393-
Projection:
394-
ProjectionType: "ALL"
395-
396-
LinkryRecordsTable:
397-
Type: "AWS::DynamoDB::Table"
398-
DeletionPolicy: "Retain"
399-
UpdateReplacePolicy: "Retain"
400-
Properties:
401-
BillingMode: "PAY_PER_REQUEST"
402-
TableName: "infra-core-api-linkry"
403-
DeletionProtectionEnabled: !If [IsProd, true, false] # TODO: remove this
404-
PointInTimeRecoverySpecification:
405-
PointInTimeRecoveryEnabled: !If [IsProd, true, false]
406-
AttributeDefinitions:
407-
- AttributeName: "slug"
408-
AttributeType: "S"
409-
- AttributeName: "access"
410-
AttributeType: "S"
411-
KeySchema:
412-
- AttributeName: "slug"
413-
KeyType: "HASH"
414-
- AttributeName: "access"
415-
KeyType: "RANGE"
416-
GlobalSecondaryIndexes:
417-
- IndexName: "AccessIndex"
418-
KeySchema:
419-
- AttributeName: "access"
420-
KeyType: "HASH"
421-
- AttributeName: "slug"
422-
KeyType: "RANGE"
423-
Projection:
424-
ProjectionType: "ALL"
425-
426-
CacheRecordsTable:
427-
Type: "AWS::DynamoDB::Table"
428-
DeletionPolicy: "Retain"
429-
UpdateReplacePolicy: "Retain"
430-
Properties:
431-
BillingMode: "PAY_PER_REQUEST"
432-
TableName: infra-core-api-cache
433-
DeletionProtectionEnabled: true
434-
PointInTimeRecoverySpecification:
435-
PointInTimeRecoveryEnabled: false
436-
AttributeDefinitions:
437-
- AttributeName: primaryKey
438-
AttributeType: S
439-
KeySchema:
440-
- AttributeName: primaryKey
441-
KeyType: HASH
442-
TimeToLiveSpecification:
443-
AttributeName: "expireAt"
444-
Enabled: true
445-
446308
AppFrontendS3Bucket:
447309
Type: AWS::S3::Bucket
448310
Properties:

terraform/envs/prod/main.tf

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,38 @@ import {
6060
id = "${var.ProjectId}-membership-external-v3"
6161
to = aws_dynamodb_table.external_membership
6262
}
63+
64+
import {
65+
id = "${var.ProjectId}-iam-grouproles"
66+
to = aws_dynamodb_table.iam_group_roles
67+
}
68+
69+
import {
70+
id = "${var.ProjectId}-iam-userroles"
71+
to = aws_dynamodb_table.iam_user_roles
72+
}
73+
74+
import {
75+
id = "${var.ProjectId}-events"
76+
to = aws_dynamodb_table.events
77+
}
78+
79+
import {
80+
id = "${var.ProjectId}-stripe-links"
81+
to = aws_dynamodb_table.stripe_links
82+
}
83+
84+
import {
85+
id = "${var.ProjectId}-linkry"
86+
to = aws_dynamodb_table.linkry_records
87+
}
88+
89+
import {
90+
id = "${var.ProjectId}-cache"
91+
to = aws_dynamodb_table.cache
92+
}
93+
94+
6395
resource "aws_dynamodb_table" "external_membership" {
6496
billing_mode = "PAY_PER_REQUEST"
6597
name = "${var.ProjectId}-membership-external-v3"
@@ -94,3 +126,126 @@ resource "aws_dynamodb_table" "external_membership" {
94126
}
95127

96128
}
129+
130+
resource "aws_dynamodb_table" "iam_group_roles" {
131+
billing_mode = "PAY_PER_REQUEST"
132+
name = "${var.ProjectId}-iam-grouproles"
133+
deletion_protection_enabled = true
134+
hash_key = "groupUuid"
135+
point_in_time_recovery {
136+
enabled = true
137+
}
138+
attribute {
139+
name = "groupUuid"
140+
type = "S"
141+
}
142+
}
143+
144+
resource "aws_dynamodb_table" "iam_user_roles" {
145+
billing_mode = "PAY_PER_REQUEST"
146+
name = "${var.ProjectId}-iam-userroles"
147+
deletion_protection_enabled = true
148+
hash_key = "userEmail"
149+
point_in_time_recovery {
150+
enabled = true
151+
}
152+
attribute {
153+
name = "userEmail"
154+
type = "S"
155+
}
156+
}
157+
158+
159+
resource "aws_dynamodb_table" "events" {
160+
billing_mode = "PAY_PER_REQUEST"
161+
name = "${var.ProjectId}-events"
162+
deletion_protection_enabled = true
163+
hash_key = "id"
164+
point_in_time_recovery {
165+
enabled = true
166+
}
167+
attribute {
168+
name = "id"
169+
type = "S"
170+
}
171+
attribute {
172+
name = "host"
173+
type = "S"
174+
}
175+
global_secondary_index {
176+
name = "HostIndex"
177+
hash_key = "host"
178+
projection_type = "ALL"
179+
}
180+
}
181+
182+
resource "aws_dynamodb_table" "stripe_links" {
183+
billing_mode = "PAY_PER_REQUEST"
184+
name = "${var.ProjectId}-stripe-links"
185+
deletion_protection_enabled = true
186+
hash_key = "userId"
187+
range_key = "linkId"
188+
189+
point_in_time_recovery {
190+
enabled = true
191+
}
192+
attribute {
193+
name = "userId"
194+
type = "S"
195+
}
196+
197+
attribute {
198+
name = "linkId"
199+
type = "S"
200+
}
201+
global_secondary_index {
202+
name = "LinkIdIndex"
203+
hash_key = "linkId"
204+
projection_type = "ALL"
205+
}
206+
}
207+
208+
resource "aws_dynamodb_table" "linkry_records" {
209+
billing_mode = "PAY_PER_REQUEST"
210+
name = "${var.ProjectId}-linkry"
211+
deletion_protection_enabled = true
212+
hash_key = "slug"
213+
range_key = "access"
214+
215+
point_in_time_recovery {
216+
enabled = true
217+
}
218+
attribute {
219+
name = "slug"
220+
type = "S"
221+
}
222+
attribute {
223+
name = "access"
224+
type = "S"
225+
}
226+
227+
global_secondary_index {
228+
name = "AccessIndex"
229+
hash_key = "access"
230+
range_key = "slug"
231+
projection_type = "ALL"
232+
}
233+
}
234+
235+
resource "aws_dynamodb_table" "cache" {
236+
billing_mode = "PAY_PER_REQUEST"
237+
name = "${var.ProjectId}-cache"
238+
deletion_protection_enabled = true
239+
hash_key = "primaryKey"
240+
point_in_time_recovery {
241+
enabled = true
242+
}
243+
attribute {
244+
name = "primaryKey"
245+
type = "S"
246+
}
247+
ttl {
248+
attribute_name = "expiresAt"
249+
enabled = true
250+
}
251+
}

0 commit comments

Comments
 (0)