Skip to content

Commit ede7165

Browse files
drama17const-bon
authored andcommitted
Add final_snapshot_identifier argument (#7)
1 parent 5f582aa commit ede7165

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

main.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ module "label" {
88
tags = "${var.tags}"
99
}
1010

11+
module "final_snapshot_label" {
12+
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.2.1"
13+
namespace = "${var.namespace}"
14+
name = "${var.name}"
15+
stage = "${var.stage}"
16+
delimiter = "${var.delimiter}"
17+
attributes = ["${compact(concat(var.attributes, list("final", "snapshot", "${md5(timestamp())}")))}"]
18+
}
19+
20+
1121
resource "aws_db_instance" "default" {
1222
identifier = "${module.label.id}"
1323
name = "${var.database_name}"
@@ -35,7 +45,7 @@ resource "aws_db_instance" "default" {
3545
backup_retention_period = "${var.backup_retention_period}"
3646
backup_window = "${var.backup_window}"
3747
tags = "${module.label.tags}"
38-
final_snapshot_identifier = "${var.final_snapshot_identifier}"
48+
final_snapshot_identifier = "${length(var.final_snapshot_identifier) > 0 ? var.final_snapshot_identifier : module.final_snapshot_label.id}"
3949
}
4050

4151
resource "aws_db_parameter_group" "default" {

variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,7 @@ variable "snapshot_identifier" {
160160
}
161161

162162
variable "final_snapshot_identifier" {
163+
description = "Identifier e.g.: some-db-final-snapshot-2015-06-26-06-05"
164+
type = "string"
163165
default = ""
164166
}

0 commit comments

Comments
 (0)