Skip to content

Commit 466df86

Browse files
committed
feat: add deletion protection for ddb tables
1 parent 4ae682e commit 466df86

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

main.tf

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ module "node_servers" {
167167
resource "aws_dynamodb_table" "state" {
168168
count = local.enabled ? 1 : 0
169169

170-
name = "${module.teleport_cluster_label.id}-state"
171-
billing_mode = "PAY_PER_REQUEST"
170+
name = "${module.teleport_cluster_label.id}-state"
171+
billing_mode = "PAY_PER_REQUEST"
172+
deletion_protection_enabled = var.ddb_deletion_protection_enabled
173+
172174
hash_key = "HashKey"
173175
range_key = "FullPath"
174176
stream_enabled = "true"
@@ -206,10 +208,12 @@ resource "aws_dynamodb_table" "state" {
206208
resource "aws_dynamodb_table" "events" {
207209
count = local.enabled ? 1 : 0
208210

209-
name = "${module.teleport_cluster_label.id}-events"
210-
billing_mode = "PAY_PER_REQUEST"
211-
hash_key = "SessionID"
212-
range_key = "EventIndex"
211+
name = "${module.teleport_cluster_label.id}-events"
212+
billing_mode = "PAY_PER_REQUEST"
213+
deletion_protection_enabled = var.ddb_deletion_protection_enabled
214+
215+
hash_key = "SessionID"
216+
range_key = "EventIndex"
213217

214218
point_in_time_recovery {
215219
enabled = true
@@ -263,9 +267,11 @@ resource "aws_dynamodb_table" "events" {
263267
resource "aws_dynamodb_table" "locks" {
264268
count = local.enabled ? 1 : 0
265269

266-
name = "${module.teleport_cluster_label.id}-locks"
267-
billing_mode = "PAY_PER_REQUEST"
268-
hash_key = "Lock"
270+
name = "${module.teleport_cluster_label.id}-locks"
271+
billing_mode = "PAY_PER_REQUEST"
272+
deletion_protection_enabled = var.ddb_deletion_protection_enabled
273+
274+
hash_key = "Lock"
269275

270276

271277
lifecycle {

variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ variable "logs_bucket_name" {
5757
default = ""
5858
}
5959

60+
# ---------------------------------------------------------------------- ddb ---
61+
62+
variable "ddb_deletion_protection_enabled" {
63+
type = bool
64+
description = "Toggle deletion protection mode for all DynamoDB tables"
65+
default = true
66+
}
67+
6068
# ---------------------------------------------------------------------- dns ---
6169

6270
variable "dns_parent_zone_id" {

0 commit comments

Comments
 (0)