Skip to content

Commit

Permalink
[terraform] add PITR to dynamodb tables
Browse files Browse the repository at this point in the history
Summary: enabled point in time recovery for all tables except identity workflows and nonces. wasn't sure which tables for other services should have this feature so enabled for all of them

Test Plan: confirmed with terraform plan that these changes would enable PITR in production only

Reviewers: bartek, kamil

Reviewed By: bartek

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D13203
  • Loading branch information
vdhanan committed Sep 3, 2024
1 parent 1d31bb5 commit 30e894e
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions services/terraform/modules/shared/dynamodb.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
pitr_enabled = terraform.workspace == "production" ? true : false
}

resource "aws_dynamodb_table" "backup-service-backup" {
name = "backup-service-backup"
hash_key = "userID"
Expand Down Expand Up @@ -26,6 +30,10 @@ resource "aws_dynamodb_table" "backup-service-backup" {
projection_type = "INCLUDE"
non_key_attributes = ["userKeys", "siweBackupMsg"]
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "backup-service-log" {
Expand All @@ -43,6 +51,10 @@ resource "aws_dynamodb_table" "backup-service-log" {
name = "logID"
type = "N"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "blob-service-blobs" {
Expand Down Expand Up @@ -77,6 +89,10 @@ resource "aws_dynamodb_table" "blob-service-blobs" {
range_key = "last_modified"
projection_type = "KEYS_ONLY"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "tunnelbroker-undelivered-messages" {
Expand All @@ -94,6 +110,10 @@ resource "aws_dynamodb_table" "tunnelbroker-undelivered-messages" {
name = "messageID"
type = "S"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "tunnelbroker-device-tokens" {
Expand All @@ -116,6 +136,10 @@ resource "aws_dynamodb_table" "tunnelbroker-device-tokens" {
hash_key = "deviceToken"
projection_type = "KEYS_ONLY"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "identity-users" {
Expand Down Expand Up @@ -174,6 +198,10 @@ resource "aws_dynamodb_table" "identity-users" {
hash_key = "usernameLower"
projection_type = "KEYS_ONLY"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "identity-devices" {
Expand Down Expand Up @@ -219,6 +247,10 @@ resource "aws_dynamodb_table" "identity-devices" {
range_key = "loginTime"
projection_type = "KEYS_ONLY"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "identity-tokens" {
Expand All @@ -236,6 +268,10 @@ resource "aws_dynamodb_table" "identity-tokens" {
name = "signingPublicKey"
type = "S"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "identity-nonces" {
Expand Down Expand Up @@ -304,6 +340,10 @@ resource "aws_dynamodb_table" "identity-reserved-usernames" {
hash_key = "userID"
projection_type = "KEYS_ONLY"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "identity-one-time-keys" {
Expand All @@ -321,6 +361,10 @@ resource "aws_dynamodb_table" "identity-one-time-keys" {
name = "timestamp#keyNumber"
type = "S"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "feature-flags" {
Expand All @@ -338,6 +382,10 @@ resource "aws_dynamodb_table" "feature-flags" {
name = "feature"
type = "S"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

resource "aws_dynamodb_table" "reports-service-reports" {
Expand All @@ -349,4 +397,8 @@ resource "aws_dynamodb_table" "reports-service-reports" {
name = "reportID"
type = "S"
}

point_in_time_recovery {
enabled = local.pitr_enabled
}
}

0 comments on commit 30e894e

Please sign in to comment.