Skip to content

Commit

Permalink
restore_to_point_in_time
Browse files Browse the repository at this point in the history
  • Loading branch information
jpluta committed Jun 7, 2024
1 parent e531807 commit 7aebb69
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ No modules.
| <a name="input_replica_availability_zone"></a> [replica\_availability\_zone](#input\_replica\_availability\_zone) | The availability zone of the replica instance. | `string` | `null` | no |
| <a name="input_replica_enabled"></a> [replica\_enabled](#input\_replica\_enabled) | If true, the DB replica is created. | `bool` | `false` | no |
| <a name="input_replica_name"></a> [replica\_name](#input\_replica\_name) | The replica instance identifier. | `string` | `null` | no |
| <a name="input_restore_to_point_in_time"></a> [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | value | <pre>object({<br> restore_time = optional(string),<br> source_db_instance_identifier = optional(string),<br> source_db_instance_automated_backups_arn = optional(string),<br> source_dbi_resource_id = optional(string),<br> use_latest_restorable_time = optional(string)<br> })</pre> | `{}` | no |
| <a name="input_role_associations"></a> [role\_associations](#input\_role\_associations) | A map of the database instance associations with an IAM Role. | `map(string)` | `{}` | no |
| <a name="input_skip_final_snapshot"></a> [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB instance is deleted. | `bool` | `true` | no |
| <a name="input_snapshot_identifier"></a> [snapshot\_identifier](#input\_snapshot\_identifier) | Specifies whether or not to create this database from a snapshot. | `string` | `null` | no |
Expand Down
12 changes: 12 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ resource "aws_db_instance" "main" {
tags = var.tags
username = var.username
vpc_security_group_ids = var.vpc_security_group_ids

dynamic "restore_to_point_in_time" {
for_each = var.snapshot_identifier == null && length(var.restore_to_point_in_time) > 0 ? [1] : []

content {
restore_time = lookup(var.restore_to_point_in_time, "restore_time", null)
source_db_instance_identifier = lookup(var.restore_to_point_in_time, "source_db_instance_identifier", null)
source_db_instance_automated_backups_arn = lookup(var.restore_to_point_in_time, "source_db_instance_automated_backups_arn", null)
source_dbi_resource_id = lookup(var.restore_to_point_in_time, "source_dbi_resource_id", null)
use_latest_restorable_time = lookup(var.restore_to_point_in_time, "use_latest_restorable_time", null)
}
}
}

resource "aws_db_instance_role_association" "main" {
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ variable "replica_enabled" {
default = false
}

variable "restore_to_point_in_time" {
description = "value"
type = object({
restore_time = optional(string),
source_db_instance_identifier = optional(string),
source_db_instance_automated_backups_arn = optional(string),
source_dbi_resource_id = optional(string),
use_latest_restorable_time = optional(string)
})
default = {}
}

variable "role_associations" {
description = "A map of the database instance associations with an IAM Role."
type = map(string)
Expand Down

0 comments on commit 7aebb69

Please sign in to comment.