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

feat: restore pg cluster implementation #418

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .wordlist-en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ IAM
IOPS
InstanceType
MPL
pgvector
PGD
Postgres
aws
Expand All @@ -27,6 +28,7 @@ gp
hh
highcpu
iam
init
io
ip
nestedatt
Expand All @@ -37,7 +39,10 @@ pgextended
pgBouncer
pgvector
postgres
prj
ssd
terraform
tfstate
ultradisk
uncomment
uri
23 changes: 22 additions & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ resource "biganimal_cluster" "single_node_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down Expand Up @@ -218,6 +222,10 @@ resource "biganimal_cluster" "ha_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand All @@ -238,6 +246,16 @@ output "faraway_replica_ids" {

-> Please use the `biganimal_pgd` resource to manage the Distributed High Availability clusters.

## Restoring a cluster

Here are the steps to restore a cluster:
1. Use an example config in the examples folder, uncomment the following fields restore_cluster_id=p-123456789, restore_from_deleted=true and enter your cluster id you want to restore and set to true respectively(for restoring an active cluster, set to false)
2. Use commands "terraform init" and "terraform import biganimal_cluster.single_node_cluster prj_123456789/p-123456789/import-from-deleted" to import a deleted cluster into terraform(use "terraform import biganimal_cluster.single_node_cluster prj_123456789/p-123456789" to import an active cluster)
3. Use command "terraform plan" to compare and diff your config with the imported cluster(source cluster) and edit config where appropriate. You can also use "terraform show" to see the source cluster which you can copy and paste the field values into your config. The config fields "cloud_provider", "pg_type", "pg_version", "pg_config" and "private_networking" cannot be changed and have to match the source cluster
4. Remove state by deleting the file terraform.tfstate or use the commands terraform state rm 'biganimal_cluster.single_node_cluster' and terraform state rm 'random_password.password'
5. Use command "terraform init" and "terraform apply" to restore the cluster, it will show a warning saying you are trying to restore a cluster
6. Remove or comment the fields "restore_cluster_id", "restore_from_deleted" and restore_point in the config after the restore has completed

<!-- schema generated by tfplugindocs -->
## Schema

Expand All @@ -258,14 +276,17 @@ output "faraway_replica_ids" {
- `backup_retention_period` (String) Backup retention period. For example, "7d", "2w", or "3m".
- `cluster_architecture` (Block, Optional) Cluster architecture. See [Supported cluster types](https://www.enterprisedb.com/docs/biganimal/latest/overview/02_high_availability/) for details. (see [below for nested schema](#nestedblock--cluster_architecture))
- `csp_auth` (Boolean) Is authentication handled by the cloud service provider. Available for AWS only, See [Authentication](https://www.enterprisedb.com/docs/biganimal/latest/getting_started/creating_a_cluster/#authentication) for details.
- `from_deleted` (Boolean) For restoring a cluster. Specifies if the cluster you want to restore is deleted
- `import_from_deleted` (Boolean) Used by the import function only to import a deleted cluster
- `maintenance_window` (Attributes) Custom maintenance window. (see [below for nested schema](#nestedatt--maintenance_window))
- `pe_allowed_principal_ids` (Set of String) Cloud provider subscription/account ID, need to be specified when cluster is deployed on BigAnimal's cloud account.
- `pg_bouncer` (Attributes) Pg bouncer. (see [below for nested schema](#nestedatt--pg_bouncer))
- `pg_config` (Block Set) Database configuration parameters. See [Modifying database configuration parameters](https://www.enterprisedb.com/docs/biganimal/latest/using_cluster/03_modifying_your_cluster/05_db_configuration_parameters/) for details. (see [below for nested schema](#nestedblock--pg_config))
- `pgvector` (Boolean) Is pgvector extension enabled. Adds support for vector storage and vector similarity search to Postgres.
- `private_networking` (Boolean) Is private networking enabled.
- `read_only_connections` (Boolean) Is read only connection enabled.
- `restore_cluster_id` (String) For restoring a cluster. Specifies the cluster id to restore
- `restore_from_deleted` (Boolean) For restoring a cluster. Specifies if the cluster you want to restore is from deleted
- `restore_point` (String) For restoring a cluster. Specifies restore point e.g. 2006-01-02T15:04:05-0700. Leave empty to restore from latest point
- `service_account_ids` (Set of String) A Google Cloud Service Account is used for logs. If you leave this blank, then you will be unable to access log details for this cluster. Required when cluster is deployed on BigAnimal's cloud account.
- `storage` (Block, Optional) Storage. (see [below for nested schema](#nestedblock--storage))
- `superuser_access` (Boolean) Enable to grant superuser access to the edb_admin role.
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/faraway_replica.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -106,7 +106,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions docs/resources/pgd.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -113,7 +113,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -281,7 +281,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -383,7 +383,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -557,7 +557,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -656,7 +656,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -824,7 +824,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -926,7 +926,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -1100,7 +1100,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -1199,7 +1199,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -1367,7 +1367,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down Expand Up @@ -1473,7 +1473,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions examples/resources/biganimal_cluster/ha/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ resource "biganimal_cluster" "ha_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ resource "biganimal_cluster" "single_node_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ resource "biganimal_cluster" "single_node_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ resource "biganimal_cluster" "single_node_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ resource "biganimal_cluster" "single_node_cluster" {
start_time = "03:00"
}

# pe_allowed_principal_ids = [
# <example_value> # ex: "9334e5e6-7f47-aE61-5A4F-ee067daeEf4A"
# ]

pg_type = "epas"
pg_version = "15"
private_networking = false
Expand All @@ -96,9 +100,9 @@ resource "biganimal_cluster" "single_node_cluster" {
# ]
}

# pe_allowed_principal_ids = [
# <example_value> # ex: "9334e5e6-7f47-aE61-5A4F-ee067daeEf4A"
# ]
# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ resource "biganimal_cluster" "single_node_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ resource "biganimal_cluster" "single_node_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down
4 changes: 4 additions & 0 deletions examples/resources/biganimal_cluster/single_node/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ resource "biganimal_cluster" "single_node_cluster" {
# },
# ]
}

# restore_cluster_id = "p-123456789" # uncomment to restore cluster
# restore_from_deleted = true
# restore_point = "2006-01-02T15:04:05-0700"
}

output "password" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/biganimal_faraway_replica/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "3.5.1"
version = "3.6.0"
}
}
}
Expand Down
Loading
Loading