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 1 commit
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
Prev Previous commit
Next Next commit
docs: update docs
  • Loading branch information
wai-wong-edb committed Jan 11, 2024

Verified

This commit was signed with the committer’s verified signature.
commit 8aef25bcc6670b322194b632a9b06ee204570c2a
2 changes: 1 addition & 1 deletion docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ output "faraway_replica_ids" {
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 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' and 'private_networking' cannot be changed and have to match the source 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 field restore_cluster_id=p-123456789 in the config after the restore has completed
Expand Down
2 changes: 1 addition & 1 deletion pkg/plan_modifier/restore_cluster_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (m customRestoreClusterIdModifier) PlanModifyString(ctx context.Context, re
if !req.PlanValue.IsNull() {
resp.Diagnostics.AddWarning(
"You are restoring a cluster",
"You are restoring a cluster. The config fields 'cloud_provider', 'pg_type', 'pg_version' and 'private_networking' cannot be changed and have to match the source cluster. After restoring the cluster, please remove fields 'restore_cluster_id','restore_from_deleted' and 'restore_point' from the config",
"You are restoring a cluster. The config fields 'cloud_provider', 'pg_type', 'pg_version', 'pg_config' and 'private_networking' cannot be changed and have to match the source cluster. After restoring the cluster, please remove fields 'restore_cluster_id','restore_from_deleted' and 'restore_point' from the config",
)
}
}
2 changes: 1 addition & 1 deletion templates/resources/cluster.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Please visit the [examples page](https://github.com/EnterpriseDB/terraform-provi
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 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' and 'private_networking' cannot be changed and have to match the source 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 field restore_cluster_id=p-123456789 in the config after the restore has completed
Expand Down