Skip to content

Commit e2a95be

Browse files
committed
feat: add support for restore_to_point_in_time
1 parent 6174afa commit e2a95be

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ Terraform documentation is generated automatically using [pre-commit hooks](http
8989
| Name | Version |
9090
|------|---------|
9191
| terraform | >= 0.12.6 |
92-
| aws | >= 3.8 |
92+
| aws | >= 3.19 |
9393
| random | >= 2.2 |
9494

9595
## Providers
9696

9797
| Name | Version |
9898
|------|---------|
99-
| aws | >= 3.8 |
99+
| aws | >= 3.19 |
100100
| random | >= 2.2 |
101101

102102
## Inputs
@@ -157,6 +157,7 @@ Terraform documentation is generated automatically using [pre-commit hooks](http
157157
| replica\_scale\_min | Minimum number of replicas to allow scaling for | `number` | `2` | no |
158158
| replica\_scale\_out\_cooldown | Cooldown in seconds before allowing further scaling operations after a scale out | `number` | `300` | no |
159159
| replication\_source\_identifier | ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica. | `string` | `""` | no |
160+
| restore\_to\_point\_in\_time | Map of nested attributes for cloning Aurora cluster. | `map(string)` | `{}` | no |
160161
| scaling\_configuration | Map of nested attributes with scaling properties. Only valid when engine\_mode is set to `serverless` | `map(string)` | `{}` | no |
161162
| security\_group\_description | The description of the security group. If value is set to empty string it will contain cluster name in the description. | `string` | `"Managed by Terraform"` | no |
162163
| skip\_final\_snapshot | Should a final snapshot be created on cluster destroy | `bool` | `false` | no |

main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ resource "aws_rds_cluster" "this" {
5757
port = local.port
5858
db_subnet_group_name = local.db_subnet_group_name
5959
vpc_security_group_ids = compact(concat(aws_security_group.this.*.id, var.vpc_security_group_ids))
60-
snapshot_identifier = var.snapshot_identifier
60+
snapshot_identifier = length(keys(var.restore_to_point_in_time)) == 0 ? var.snapshot_identifier : null
6161
storage_encrypted = var.storage_encrypted
6262
apply_immediately = var.apply_immediately
6363
db_cluster_parameter_group_name = var.db_cluster_parameter_group_name
@@ -80,6 +80,17 @@ resource "aws_rds_cluster" "this" {
8080
}
8181
}
8282

83+
dynamic "restore_to_point_in_time" {
84+
for_each = length(keys(var.restore_to_point_in_time)) == 0 ? [] : [var.restore_to_point_in_time]
85+
86+
content {
87+
source_cluster_identifier = lookup(restore_to_point_in_time.value, "source_cluster_identifier", null)
88+
restore_type = lookup(restore_to_point_in_time.value, "restore_type", null)
89+
use_latest_restorable_time = lookup(restore_to_point_in_time.value, "use_latest_restorable_time", null)
90+
restore_to_time = lookup(restore_to_point_in_time.value, "restore_to_time", null)
91+
}
92+
}
93+
8394
tags = var.tags
8495
}
8596

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ variable "scaling_configuration" {
196196
default = {}
197197
}
198198

199+
variable "restore_to_point_in_time" {
200+
description = "Map of nested attributes for cloning Aurora cluster."
201+
type = map(string)
202+
default = {}
203+
}
204+
199205
variable "snapshot_identifier" {
200206
description = "DB snapshot to create this database from"
201207
type = string

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_version = ">= 0.12.6"
33

44
required_providers {
5-
aws = ">= 3.8"
5+
aws = ">= 3.19"
66
random = ">= 2.2"
77
}
88
}

0 commit comments

Comments
 (0)