Skip to content

Commit e499df0

Browse files
committed
Import resources into terraform
1 parent 3ac8945 commit e499df0

File tree

3 files changed

+139
-84
lines changed

3 files changed

+139
-84
lines changed

cloudformation/main.yml

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -341,71 +341,6 @@ Resources:
341341
Projection:
342342
ProjectionType: "KEYS_ONLY"
343343

344-
345-
RoomRequestsTable:
346-
Type: "AWS::DynamoDB::Table"
347-
DeletionPolicy: "Retain"
348-
UpdateReplacePolicy: "Retain"
349-
Properties:
350-
BillingMode: "PAY_PER_REQUEST"
351-
TableName: infra-core-api-room-requests
352-
DeletionProtectionEnabled: true
353-
PointInTimeRecoverySpecification:
354-
PointInTimeRecoveryEnabled: !If [IsProd, true, false]
355-
AttributeDefinitions:
356-
- AttributeName: userId#requestId
357-
AttributeType: S
358-
- AttributeName: requestId
359-
AttributeType: S
360-
- AttributeName: semesterId
361-
AttributeType: S
362-
KeySchema:
363-
- AttributeName: semesterId
364-
KeyType: HASH
365-
- AttributeName: userId#requestId
366-
KeyType: RANGE
367-
GlobalSecondaryIndexes:
368-
- IndexName: RequestIdIndex
369-
KeySchema:
370-
- AttributeName: requestId
371-
KeyType: HASH
372-
Projection:
373-
ProjectionType: ALL
374-
375-
RoomRequestUpdatesTable:
376-
Type: "AWS::DynamoDB::Table"
377-
DeletionPolicy: "Retain"
378-
UpdateReplacePolicy: "Retain"
379-
Properties:
380-
BillingMode: "PAY_PER_REQUEST"
381-
TableName: infra-core-api-room-requests-status
382-
DeletionProtectionEnabled: true
383-
PointInTimeRecoverySpecification:
384-
PointInTimeRecoveryEnabled: !If [IsProd, true, false]
385-
AttributeDefinitions:
386-
- AttributeName: requestId
387-
AttributeType: S
388-
- AttributeName: semesterId
389-
AttributeType: S
390-
- AttributeName: createdAt#status
391-
AttributeType: S
392-
KeySchema:
393-
- AttributeName: requestId
394-
KeyType: HASH
395-
- AttributeName: createdAt#status
396-
KeyType: RANGE
397-
GlobalSecondaryIndexes:
398-
- IndexName: SemesterId
399-
KeySchema:
400-
- AttributeName: semesterId
401-
KeyType: HASH
402-
- AttributeName: requestId
403-
KeyType: RANGE
404-
Projection:
405-
ProjectionType: ALL
406-
407-
408-
409344
IamGroupRolesTable:
410345
Type: "AWS::DynamoDB::Table"
411346
DeletionPolicy: "Retain"
@@ -496,6 +431,8 @@ Resources:
496431

497432
LinkryRecordsTable:
498433
Type: "AWS::DynamoDB::Table"
434+
DeletionPolicy: "Retain"
435+
UpdateReplacePolicy: "Retain"
499436
Properties:
500437
BillingMode: "PAY_PER_REQUEST"
501438
TableName: "infra-core-api-linkry"

terraform/envs/prod/main.tf

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ provider "aws" {
2424
region = "us-east-1"
2525
default_tags {
2626
tags = {
27-
project = var.ProjectId
27+
project = var.ProjectId
28+
terraform_managed = true
2829
}
2930
}
3031
}
@@ -124,3 +125,69 @@ resource "aws_dynamodb_table" "api_keys" {
124125
enabled = true
125126
}
126127
}
128+
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+
}
164+
}
165+
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+
}
193+
}

terraform/envs/qa/main.tf

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ provider "aws" {
2121
region = "us-east-1"
2222
default_tags {
2323
tags = {
24-
project = var.ProjectId
24+
project = var.ProjectId
25+
terraform_managed = true
2526
}
2627
}
2728
}
28-
import {
29-
to = aws_cloudwatch_log_group.main_app_logs
30-
id = "/aws/lambda/${var.ProjectId}-lambda"
31-
}
29+
3230
resource "aws_cloudwatch_log_group" "main_app_logs" {
3331
name = "/aws/lambda/${var.ProjectId}-lambda"
3432
retention_in_days = var.LogRetentionDays
@@ -38,11 +36,6 @@ module "sqs_queues" {
3836
resource_prefix = var.ProjectId
3937
}
4038

41-
import {
42-
to = aws_dynamodb_table.app_audit_log
43-
id = "${var.ProjectId}-audit-log"
44-
}
45-
4639
resource "aws_dynamodb_table" "app_audit_log" {
4740
billing_mode = "PAY_PER_REQUEST"
4841
name = "${var.ProjectId}-audit-log"
@@ -73,10 +66,6 @@ module "lambda_warmer" {
7366

7467

7568
// Membership Logs
76-
import {
77-
to = aws_dynamodb_table.membership_provisioning_log
78-
id = "${var.ProjectId}-membership-provisioning"
79-
}
8069
resource "aws_dynamodb_table" "membership_provisioning_log" {
8170
billing_mode = "PAY_PER_REQUEST"
8271
name = "${var.ProjectId}-membership-provisioning"
@@ -92,10 +81,6 @@ resource "aws_dynamodb_table" "membership_provisioning_log" {
9281
}
9382

9483
// API Keys
95-
import {
96-
to = aws_dynamodb_table.api_keys
97-
id = "${var.ProjectId}-api-keys"
98-
}
9984
resource "aws_dynamodb_table" "api_keys" {
10085
billing_mode = "PAY_PER_REQUEST"
10186
name = "${var.ProjectId}-keys"
@@ -113,3 +98,69 @@ resource "aws_dynamodb_table" "api_keys" {
11398
enabled = true
11499
}
115100
}
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+
}
166+
}

0 commit comments

Comments
 (0)