Skip to content

Commit 1094cf4

Browse files
committed
move imported dynamo to its own module
1 parent e499df0 commit 1094cf4

File tree

4 files changed

+138
-252
lines changed

4 files changed

+138
-252
lines changed

terraform/envs/prod/main.tf

Lines changed: 18 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -51,143 +51,32 @@ module "sqs_queues" {
5151
resource_prefix = var.ProjectId
5252
}
5353

54-
import {
55-
to = aws_dynamodb_table.app_audit_log
56-
id = "${var.ProjectId}-audit-log"
54+
module "dynamo" {
55+
source = "../../modules/dynamo"
56+
ProjectId = var.ProjectId
5757
}
58-
59-
resource "aws_dynamodb_table" "app_audit_log" {
60-
billing_mode = "PAY_PER_REQUEST"
61-
name = "${var.ProjectId}-audit-log"
62-
deletion_protection_enabled = true
63-
hash_key = "module"
64-
range_key = "createdAt"
65-
point_in_time_recovery {
66-
enabled = true
67-
}
68-
attribute {
69-
name = "module"
70-
type = "S"
71-
}
72-
attribute {
73-
name = "createdAt"
74-
type = "N"
75-
}
76-
ttl {
77-
attribute_name = "expiresAt"
78-
enabled = true
79-
}
58+
moved {
59+
from = aws_dynamodb_table.app_audit_log
60+
to = module.dynamo.aws_dynamodb_table.app_audit_log
8061
}
8162

82-
module "lambda_warmer" {
83-
source = "github.com/acm-uiuc/terraform-modules/lambda-warmer?ref=v0.1.1"
84-
function_to_warm = "infra-core-api-lambda"
63+
moved {
64+
from = aws_dynamodb_table.membership_provisioning_log
65+
to = module.dynamo.aws_dynamodb_table.membership_provisioning_log
8566
}
8667

87-
// Membership Logs
88-
import {
89-
to = aws_dynamodb_table.membership_provisioning_log
90-
id = "${var.ProjectId}-membership-provisioning"
91-
}
92-
resource "aws_dynamodb_table" "membership_provisioning_log" {
93-
billing_mode = "PAY_PER_REQUEST"
94-
name = "${var.ProjectId}-membership-provisioning"
95-
deletion_protection_enabled = true
96-
hash_key = "email"
97-
point_in_time_recovery {
98-
enabled = true
99-
}
100-
attribute {
101-
name = "email"
102-
type = "S"
103-
}
104-
}
10568

106-
// API Keys
107-
import {
108-
to = aws_dynamodb_table.api_keys
109-
id = "${var.ProjectId}-keys"
110-
}
111-
resource "aws_dynamodb_table" "api_keys" {
112-
billing_mode = "PAY_PER_REQUEST"
113-
name = "${var.ProjectId}-keys"
114-
deletion_protection_enabled = true
115-
hash_key = "keyId"
116-
point_in_time_recovery {
117-
enabled = true
118-
}
119-
attribute {
120-
name = "keyId"
121-
type = "S"
122-
}
123-
ttl {
124-
attribute_name = "expiresAt"
125-
enabled = true
126-
}
69+
moved {
70+
from = aws_dynamodb_table.api_keys
71+
to = module.dynamo.aws_dynamodb_table.api_keys
12772
}
12873

129-
// Room Requests
130-
import {
131-
to = aws_dynamodb_table.room_requests
132-
id = "${var.ProjectId}-room-requests"
133-
}
134-
import {
135-
to = aws_dynamodb_table.room_requests_status
136-
id = "${var.ProjectId}-room-requests-status"
137-
}
138-
resource "aws_dynamodb_table" "room_requests" {
139-
billing_mode = "PAY_PER_REQUEST"
140-
name = "${var.ProjectId}-room-requests"
141-
deletion_protection_enabled = true
142-
hash_key = "semesterId"
143-
range_key = "userId#requestId"
144-
point_in_time_recovery {
145-
enabled = true
146-
}
147-
attribute {
148-
name = "userId#requestId"
149-
type = "S"
150-
}
151-
attribute {
152-
name = "requestId"
153-
type = "S"
154-
}
155-
attribute {
156-
name = "semesterId"
157-
type = "S"
158-
}
159-
global_secondary_index {
160-
name = "RequestIdIndex"
161-
hash_key = "requestId"
162-
projection_type = "ALL"
163-
}
74+
moved {
75+
from = aws_dynamodb_table.room_requests
76+
to = module.dynamo.aws_dynamodb_table.room_requests
16477
}
16578

166-
resource "aws_dynamodb_table" "room_requests_status" {
167-
billing_mode = "PAY_PER_REQUEST"
168-
name = "${var.ProjectId}-room-requests-status"
169-
deletion_protection_enabled = true
170-
hash_key = "requestId"
171-
range_key = "createdAt#status"
172-
point_in_time_recovery {
173-
enabled = true
174-
}
175-
attribute {
176-
name = "createdAt#status"
177-
type = "S"
178-
}
179-
attribute {
180-
name = "requestId"
181-
type = "S"
182-
}
183-
attribute {
184-
name = "semesterId"
185-
type = "S"
186-
}
187-
global_secondary_index {
188-
name = "SemesterId"
189-
hash_key = "semesterId"
190-
range_key = "requestId"
191-
projection_type = "ALL"
192-
}
79+
moved {
80+
from = aws_dynamodb_table.room_requests_status
81+
to = module.dynamo.aws_dynamodb_table.room_requests_status
19382
}

terraform/envs/qa/main.tf

Lines changed: 3 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -36,131 +36,11 @@ module "sqs_queues" {
3636
resource_prefix = var.ProjectId
3737
}
3838

39-
resource "aws_dynamodb_table" "app_audit_log" {
40-
billing_mode = "PAY_PER_REQUEST"
41-
name = "${var.ProjectId}-audit-log"
42-
deletion_protection_enabled = true
43-
hash_key = "module"
44-
range_key = "createdAt"
45-
point_in_time_recovery {
46-
enabled = true
47-
}
48-
attribute {
49-
name = "module"
50-
type = "S"
51-
}
52-
attribute {
53-
name = "createdAt"
54-
type = "N"
55-
}
56-
ttl {
57-
attribute_name = "expiresAt"
58-
enabled = true
59-
}
60-
}
61-
6239
module "lambda_warmer" {
6340
source = "github.com/acm-uiuc/terraform-modules/lambda-warmer?ref=v0.1.1"
6441
function_to_warm = "infra-core-api-lambda"
6542
}
66-
67-
68-
// Membership Logs
69-
resource "aws_dynamodb_table" "membership_provisioning_log" {
70-
billing_mode = "PAY_PER_REQUEST"
71-
name = "${var.ProjectId}-membership-provisioning"
72-
deletion_protection_enabled = true
73-
hash_key = "email"
74-
point_in_time_recovery {
75-
enabled = true
76-
}
77-
attribute {
78-
name = "email"
79-
type = "S"
80-
}
81-
}
82-
83-
// API Keys
84-
resource "aws_dynamodb_table" "api_keys" {
85-
billing_mode = "PAY_PER_REQUEST"
86-
name = "${var.ProjectId}-keys"
87-
deletion_protection_enabled = true
88-
hash_key = "keyId"
89-
point_in_time_recovery {
90-
enabled = true
91-
}
92-
attribute {
93-
name = "keyId"
94-
type = "S"
95-
}
96-
ttl {
97-
attribute_name = "expiresAt"
98-
enabled = true
99-
}
100-
}
101-
102-
// Room Requests
103-
import {
104-
to = aws_dynamodb_table.room_requests
105-
id = "${var.ProjectId}-room-requests"
106-
}
107-
import {
108-
to = aws_dynamodb_table.room_requests_status
109-
id = "${var.ProjectId}-room-requests-status"
110-
}
111-
resource "aws_dynamodb_table" "room_requests" {
112-
billing_mode = "PAY_PER_REQUEST"
113-
name = "${var.ProjectId}-room-requests"
114-
deletion_protection_enabled = true
115-
hash_key = "semesterId"
116-
range_key = "userId#requestId"
117-
point_in_time_recovery {
118-
enabled = true
119-
}
120-
attribute {
121-
name = "userId#requestId"
122-
type = "S"
123-
}
124-
attribute {
125-
name = "requestId"
126-
type = "S"
127-
}
128-
attribute {
129-
name = "semesterId"
130-
type = "S"
131-
}
132-
global_secondary_index {
133-
name = "RequestIdIndex"
134-
hash_key = "requestId"
135-
projection_type = "ALL"
136-
}
137-
}
138-
139-
resource "aws_dynamodb_table" "room_requests_status" {
140-
billing_mode = "PAY_PER_REQUEST"
141-
name = "${var.ProjectId}-room-requests-status"
142-
deletion_protection_enabled = true
143-
hash_key = "requestId"
144-
range_key = "createdAt#status"
145-
point_in_time_recovery {
146-
enabled = true
147-
}
148-
attribute {
149-
name = "createdAt#status"
150-
type = "S"
151-
}
152-
attribute {
153-
name = "requestId"
154-
type = "S"
155-
}
156-
attribute {
157-
name = "semesterId"
158-
type = "S"
159-
}
160-
global_secondary_index {
161-
name = "SemesterId"
162-
hash_key = "semesterId"
163-
range_key = "requestId"
164-
projection_type = "ALL"
165-
}
43+
module "dynamo" {
44+
source = "../../modules/dynamo"
45+
ProjectId = var.ProjectId
16646
}

0 commit comments

Comments
 (0)