Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support restoring to a specific time #216

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Available targets:
| <a name="input_reader_dns_name"></a> [reader\_dns\_name](#input\_reader\_dns\_name) | Name of the reader endpoint CNAME record to create in the parent DNS zone specified by `zone_id`. If left empty, the name will be auto-asigned using the format `replicas.var.name` | `string` | `""` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_replication_source_identifier"></a> [replication\_source\_identifier](#input\_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 |
| <a name="input_restore_to_point_in_time"></a> [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | List point-in-time recovery options. Only valid actions are `source_cluster_identifier`, `restore_type` and `use_latest_restorable_time` | <pre>list(object({<br> source_cluster_identifier = string<br> restore_type = string<br> use_latest_restorable_time = bool<br> }))</pre> | `[]` | no |
| <a name="input_restore_to_point_in_time"></a> [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | List of point-in-time recovery options. Valid parameters are:<br><br>`source_cluster_identifier`<br> Identifier of the source database cluster from which to restore.<br> default: "120m"<br>`restore_type`:<br> Type of restore to be performed. Valid options are "full-copy" and "copy-on-write".<br> default: "copy-on-write"<br>`use_latest_restorable_time`:<br> Set to true to restore the database cluster to the latest restorable backup time. Conflicts with `restore_to_time`.<br> default: true<br>`restore_to_time`:<br> Date and time in UTC format to restore the database cluster to. Conflicts with `use_latest_restorable_time`.<br> default: null | <pre>list(object({<br> source_cluster_identifier = string<br> restore_type = string<br> use_latest_restorable_time = bool<br> restore_to_time = string<br> }))</pre> | `[]` | no |
| <a name="input_retention_period"></a> [retention\_period](#input\_retention\_period) | Number of days to retain backups for | `number` | `5` | no |
| <a name="input_s3_import"></a> [s3\_import](#input\_s3\_import) | Restore from a Percona Xtrabackup in S3. The `bucket_name` is required to be in the same region as the resource. | <pre>object({<br> bucket_name = string<br> bucket_prefix = string<br> ingestion_role = string<br> source_engine = string<br> source_engine_version = string<br> })</pre> | `null` | no |
| <a name="input_scaling_configuration"></a> [scaling\_configuration](#input\_scaling\_configuration) | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` | <pre>list(object({<br> auto_pause = bool<br> max_capacity = number<br> min_capacity = number<br> seconds_until_auto_pause = number<br> timeout_action = string<br> }))</pre> | `[]` | no |
Expand Down
2 changes: 1 addition & 1 deletion docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
| <a name="input_reader_dns_name"></a> [reader\_dns\_name](#input\_reader\_dns\_name) | Name of the reader endpoint CNAME record to create in the parent DNS zone specified by `zone_id`. If left empty, the name will be auto-asigned using the format `replicas.var.name` | `string` | `""` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_replication_source_identifier"></a> [replication\_source\_identifier](#input\_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 |
| <a name="input_restore_to_point_in_time"></a> [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | List point-in-time recovery options. Only valid actions are `source_cluster_identifier`, `restore_type` and `use_latest_restorable_time` | <pre>list(object({<br> source_cluster_identifier = string<br> restore_type = string<br> use_latest_restorable_time = bool<br> }))</pre> | `[]` | no |
| <a name="input_restore_to_point_in_time"></a> [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | List of point-in-time recovery options. Valid parameters are:<br><br>`source_cluster_identifier`<br> Identifier of the source database cluster from which to restore.<br> default: "120m"<br>`restore_type`:<br> Type of restore to be performed. Valid options are "full-copy" and "copy-on-write".<br> default: "copy-on-write"<br>`use_latest_restorable_time`:<br> Set to true to restore the database cluster to the latest restorable backup time. Conflicts with `restore_to_time`.<br> default: true<br>`restore_to_time`:<br> Date and time in UTC format to restore the database cluster to. Conflicts with `use_latest_restorable_time`.<br> default: null | <pre>list(object({<br> source_cluster_identifier = string<br> restore_type = string<br> use_latest_restorable_time = bool<br> restore_to_time = string<br> }))</pre> | `[]` | no |
| <a name="input_retention_period"></a> [retention\_period](#input\_retention\_period) | Number of days to retain backups for | `number` | `5` | no |
| <a name="input_s3_import"></a> [s3\_import](#input\_s3\_import) | Restore from a Percona Xtrabackup in S3. The `bucket_name` is required to be in the same region as the resource. | <pre>object({<br> bucket_name = string<br> bucket_prefix = string<br> ingestion_role = string<br> source_engine = string<br> source_engine_version = string<br> })</pre> | `null` | no |
| <a name="input_scaling_configuration"></a> [scaling\_configuration](#input\_scaling\_configuration) | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` | <pre>list(object({<br> auto_pause = bool<br> max_capacity = number<br> min_capacity = number<br> seconds_until_auto_pause = number<br> timeout_action = string<br> }))</pre> | `[]` | no |
Expand Down
7 changes: 4 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ resource "aws_rds_cluster" "primary" {
dynamic "restore_to_point_in_time" {
for_each = var.restore_to_point_in_time
content {
source_cluster_identifier = lookup(restore_to_point_in_time.value, "source_cluster_identifier", "120m")
restore_type = lookup(restore_to_point_in_time.value, "restore_type", "copy-on-write")
use_latest_restorable_time = lookup(restore_to_point_in_time.value, "use_latest_restorable_time", true)
source_cluster_identifier = restore_to_point_in_time.value.source_cluster_identifier
restore_type = restore_to_point_in_time.value.restore_type
use_latest_restorable_time = restore_to_point_in_time.value.use_latest_restorable_time
restore_to_time = restore_to_point_in_time.value.restore_to_time
}
}

Expand Down
18 changes: 15 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,23 @@ variable "timeouts_configuration" {
variable "restore_to_point_in_time" {
type = list(object({
source_cluster_identifier = string
restore_type = string
use_latest_restorable_time = bool
restore_type = optional(string, "copy-on-write")
use_latest_restorable_time = optional(bool, true)
restore_to_time = optional(string, null)
}))
default = []
description = "List point-in-time recovery options. Only valid actions are `source_cluster_identifier`, `restore_type` and `use_latest_restorable_time`"
description = <<-EOT
List of point-in-time recovery options. Valid parameters are:

`source_cluster_identifier`
Identifier of the source database cluster from which to restore.
`restore_type`:
Type of restore to be performed. Valid options are "full-copy" and "copy-on-write".
`use_latest_restorable_time`:
Set to true to restore the database cluster to the latest restorable backup time. Conflicts with `restore_to_time`.
`restore_to_time`:
Date and time in UTC format to restore the database cluster to. Conflicts with `use_latest_restorable_time`.
EOT
}

variable "allowed_cidr_blocks" {
Expand Down