diff --git a/README.md b/README.md index fa940d66..2dce735f 100644 --- a/README.md +++ b/README.md @@ -438,7 +438,7 @@ Available targets: | [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 | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [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 | -| [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` |
list(object({
source_cluster_identifier = string
restore_type = string
use_latest_restorable_time = bool
}))
| `[]` | no | +| [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | List of point-in-time recovery options. Valid parameters are:

`source_cluster_identifier`
Identifier of the source database cluster from which to restore.
default: "120m"
`restore_type`:
Type of restore to be performed. Valid options are "full-copy" and "copy-on-write".
default: "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`.
default: true
`restore_to_time`:
Date and time in UTC format to restore the database cluster to. Conflicts with `use_latest_restorable_time`.
default: null |
list(object({
source_cluster_identifier = string
restore_type = string
use_latest_restorable_time = bool
restore_to_time = string
}))
| `[]` | no | | [retention\_period](#input\_retention\_period) | Number of days to retain backups for | `number` | `5` | no | | [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. |
object({
bucket_name = string
bucket_prefix = string
ingestion_role = string
source_engine = string
source_engine_version = string
})
| `null` | no | | [scaling\_configuration](#input\_scaling\_configuration) | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` |
list(object({
auto_pause = bool
max_capacity = number
min_capacity = number
seconds_until_auto_pause = number
timeout_action = string
}))
| `[]` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 0f10c3c1..117e4f04 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -124,7 +124,7 @@ | [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 | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [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 | -| [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` |
list(object({
source_cluster_identifier = string
restore_type = string
use_latest_restorable_time = bool
}))
| `[]` | no | +| [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | List of point-in-time recovery options. Valid parameters are:

`source_cluster_identifier`
Identifier of the source database cluster from which to restore.
default: "120m"
`restore_type`:
Type of restore to be performed. Valid options are "full-copy" and "copy-on-write".
default: "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`.
default: true
`restore_to_time`:
Date and time in UTC format to restore the database cluster to. Conflicts with `use_latest_restorable_time`.
default: null |
list(object({
source_cluster_identifier = string
restore_type = string
use_latest_restorable_time = bool
restore_to_time = string
}))
| `[]` | no | | [retention\_period](#input\_retention\_period) | Number of days to retain backups for | `number` | `5` | no | | [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. |
object({
bucket_name = string
bucket_prefix = string
ingestion_role = string
source_engine = string
source_engine_version = string
})
| `null` | no | | [scaling\_configuration](#input\_scaling\_configuration) | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` |
list(object({
auto_pause = bool
max_capacity = number
min_capacity = number
seconds_until_auto_pause = number
timeout_action = string
}))
| `[]` | no | diff --git a/main.tf b/main.tf index c4722628..d7262009 100644 --- a/main.tf +++ b/main.tf @@ -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 } } diff --git a/variables.tf b/variables.tf index 0bdc0e56..f32950ed 100644 --- a/variables.tf +++ b/variables.tf @@ -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" {