Skip to content

Commit 9d70697

Browse files
committed
fix: add customizable final_snapshot_identifier
to be able to have multiple db apply/destroy lifecycles in the same account
1 parent 8e51980 commit 9d70697

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
| <a name="input_engine"></a> [engine](#input\_engine) | The name of the database engine to be used for this DB cluster. Defaults to `docdb`. Valid values: `docdb` | `string` | `"docdb"` | no |
7272
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | The version number of the database engine to use | `string` | `"3.6.0"` | no |
7373
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
74+
| <a name="input_final_snapshot_identifier"></a> [final\_snapshot\_identifier](#input\_final\_snapshot\_identifier) | Name of the final DB snapshot, if skip_final_snapshot is false. | `string` | `""` | no |
7475
| <a name="input_external_security_group_id_list"></a> [external\_security\_group\_id\_list](#input\_external\_security\_group\_id\_list) | List of external security group IDs to attach to the Document DB | `list(string)` | `[]` | no |
7576
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
7677
| <a name="input_instance_class"></a> [instance\_class](#input\_instance\_class) | The instance class to use. For more details, see https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-class-specs | `string` | `"db.r4.large"` | no |

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ resource "aws_docdb_cluster" "default" {
6464
backup_retention_period = var.retention_period
6565
preferred_backup_window = var.preferred_backup_window
6666
preferred_maintenance_window = var.preferred_maintenance_window
67-
final_snapshot_identifier = lower(module.this.id)
67+
final_snapshot_identifier = var.final_snapshot_identifier != "" ? var.final_snapshot_identifier : lower(module.this.id)
6868
skip_final_snapshot = var.skip_final_snapshot
6969
deletion_protection = var.deletion_protection
7070
apply_immediately = var.apply_immediately

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ variable "snapshot_identifier" {
8181
description = "Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot"
8282
}
8383

84+
variable "final_snapshot_identifier" {
85+
type = string
86+
default = ""
87+
description = "Name of the final DB snapshot, if skip_final_snapshot is false."
88+
}
89+
8490
variable "db_port" {
8591
type = number
8692
default = 27017

0 commit comments

Comments
 (0)