Skip to content

Commit a90f423

Browse files
ozbillwangantonbabenko
authored andcommitted
Add deletion protection argument (terraform-aws-modules#83)
* Add-deletion_protection-argument * Add-deletion_protection-argument
1 parent 4c390c9 commit a90f423

File tree

10 files changed

+33
-0
lines changed

10 files changed

+33
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ module "db" {
6464
# Snapshot name upon DB deletion
6565
final_snapshot_identifier = "demodb"
6666
67+
# Database Deletion Protection
68+
deletion_protection = true
69+
6770
parameters = [
6871
{
6972
name = "character_set_client"

examples/complete-mssql/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@ module "db" {
6060
license_model = "license-included"
6161

6262
timezone = "Central Standard Time"
63+
64+
# Database Deletion Protection
65+
deletion_protection = true
6366
}

examples/complete-mysql/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ module "db" {
6868
# Snapshot name upon DB deletion
6969
final_snapshot_identifier = "demodb"
7070

71+
# Database Deletion Protection
72+
deletion_protection = true
73+
7174
options = [
7275
{
7376
option_name = "MARIADB_AUDIT_PLUGIN"

examples/complete-oracle/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@ module "db" {
6666

6767
# See here for support character sets https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.OracleCharacterSets.html
6868
character_set_name = "AL32UTF8"
69+
70+
# Database Deletion Protection
71+
deletion_protection = true
6972
}

examples/complete-postgres/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,7 @@ module "db" {
6767

6868
# Snapshot name upon DB deletion
6969
final_snapshot_identifier = "demodb"
70+
71+
# Database Deletion Protection
72+
deletion_protection = true
7073
}

examples/enhanced-monitoring/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,6 @@ module "db" {
8282
major_engine_version = "5.7"
8383
monitoring_interval = "30"
8484
monitoring_role_arn = "${aws_iam_role.rds_enhanced_monitoring.arn}"
85+
# Database Deletion Protection
86+
deletion_protection = true
8587
}

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,7 @@ module "db_instance" {
104104

105105
timeouts = "${var.timeouts}"
106106

107+
deletion_protection = "${var.deletion_protection}"
108+
107109
tags = "${var.tags}"
108110
}

modules/db_instance/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ resource "aws_db_instance" "this" {
6969

7070
timeouts = "${var.timeouts}"
7171

72+
deletion_protection = "${var.deletion_protection}"
73+
7274
tags = "${merge(var.tags, map("Name", format("%s", var.identifier)))}"
7375
}
7476

@@ -125,5 +127,7 @@ resource "aws_db_instance" "this_mssql" {
125127

126128
timeouts = "${var.timeouts}"
127129

130+
deletion_protection = "${var.deletion_protection}"
131+
128132
tags = "${merge(var.tags, map("Name", format("%s", var.identifier)))}"
129133
}

modules/db_instance/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,8 @@ variable "timeouts" {
208208
delete = "40m"
209209
}
210210
}
211+
212+
variable "deletion_protection" {
213+
description = "The database can't be deleted when this value is set to true."
214+
default = false
215+
}

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,8 @@ variable "timeouts" {
258258
delete = "40m"
259259
}
260260
}
261+
262+
variable "deletion_protection" {
263+
description = "The database can't be deleted when this value is set to true."
264+
default = false
265+
}

0 commit comments

Comments
 (0)