Skip to content

Commit ff0768a

Browse files
feat(RDS): add a resource pg table restore (#6992)
* feat(RDS): add a resource pg table restore * l
1 parent abe2063 commit ff0768a

File tree

4 files changed

+408
-0
lines changed

4 files changed

+408
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
subcategory: "Relational Database Service (RDS)"
3+
layout: "huaweicloud"
4+
page_title: "HuaweiCloud: huaweicloud_rds_pg_table_restore"
5+
description: |-
6+
Manages an RDS instance PostgreSQL table restore resource within HuaweiCloud.
7+
---
8+
9+
# huaweicloud_rds_pg_table_restore
10+
11+
Manages an RDS instance PostgreSQL table restore resource within HuaweiCloud.
12+
13+
## Example Usage
14+
15+
```hcl
16+
variable "instance_id" {}
17+
18+
resource "huaweicloud_rds_pg_table_restore" "test" {
19+
instance_id = var.instance_id
20+
restore_time = 1754954459000
21+
22+
databases {
23+
database = "test1"
24+
25+
schemas {
26+
schema = "test1"
27+
28+
tables {
29+
old_name = "table1"
30+
new_name = "table1_update"
31+
}
32+
}
33+
}
34+
}
35+
```
36+
37+
## Argument Reference
38+
39+
The following arguments are supported:
40+
41+
* `region` - (Optional, String, ForceNew) The region in which the RDS instance exists. If omitted, the
42+
provider-level region will be used. Changing this creates a new resource.
43+
44+
* `instance_id` - (Required, String, NonUpdatable) Specifies the ID of RDS PostgreSQL instance.
45+
46+
* `restore_time` - (Required, Int, NonUpdatable) Specifies the restoration time point. A timestamp in milliseconds is used.
47+
48+
* `databases` - (Required, List, NonUpdatable) Specifies the list of databases to restore.
49+
The [databases](#databases_struct) structure is documented below.
50+
51+
<a name="databases_struct"></a>
52+
The `databases` block supports:
53+
54+
* `database` - (Required, String, NonUpdatable) Specifies the name of the database that contains the tables to restore.
55+
56+
* `schemas` - (Required, List, NonUpdatable) Specifies a list of schemas within the database.
57+
The [schemas](#schemas_struct) structure is documented below.
58+
59+
<a name="schemas_struct"></a>
60+
The `schemas` block supports:
61+
62+
* `schema` - (Required, String, NonUpdatable) Specifies the name of the schema containing the tables to be restored.
63+
64+
* `tables` - (Required, List, NonUpdatable) Specifies a list of tables to be restored.
65+
The [tables](#tables_struct) structure is documented below.
66+
67+
<a name="tables_struct"></a>
68+
The `tables` block supports:
69+
70+
* `old_name` - (Required, String, NonUpdatable) Specifies the name of the table before restoration.
71+
72+
* `new_name` - (Required, String, NonUpdatable) Specifies the name of the table after restoration.
73+
74+
## Attribute Reference
75+
76+
In addition to all arguments above, the following attribute is exported:
77+
78+
* `id` - The resource ID. The value is the restore job ID.
79+
80+
## Timeouts
81+
82+
This resource provides the following timeouts configuration options:
83+
84+
* `create` - Default is 60 minutes.

huaweicloud/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,7 @@ func Provider() *schema.Provider {
24482448
"huaweicloud_rds_pg_hba": rds.ResourcePgHba(),
24492449
"huaweicloud_rds_pg_sql_limit": rds.ResourcePgSqlLimit(),
24502450
"huaweicloud_rds_pg_plugin_parameter": rds.ResourcePgPluginParameter(),
2451+
"huaweicloud_rds_pg_table_restore": rds.ResourceRdsPgTableRestore(),
24512452
"huaweicloud_rds_lts_config": rds.ResourceRdsLtsConfig(),
24522453
"huaweicloud_rds_recycling_policy": rds.ResourceRecyclingPolicy(),
24532454
"huaweicloud_rds_primary_instance_dr_capability": rds.ResourcePrimaryInstanceDrCapability(),
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package rds
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
9+
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
10+
)
11+
12+
func TestAccResourceRdsPgTableRestore_basic(t *testing.T) {
13+
resource.ParallelTest(t, resource.TestCase{
14+
PreCheck: func() {
15+
acceptance.TestAccPreCheck(t)
16+
acceptance.TestAccPreCheckRdsInstanceId(t)
17+
},
18+
ProviderFactories: acceptance.TestAccProviderFactories,
19+
CheckDestroy: nil,
20+
Steps: []resource.TestStep{
21+
{
22+
Config: testAccRdsInstancePgTableRestoreConfig_basic(),
23+
},
24+
},
25+
})
26+
}
27+
28+
func testAccRdsInstancePgTableRestoreConfig_basic() string {
29+
return fmt.Sprintf(`
30+
data "huaweicloud_rds_restore_time_ranges" "test" {
31+
instance_id = "%[1]s"
32+
}
33+
34+
resource "huaweicloud_rds_pg_table_restore" "test" {
35+
instance_id = "%[1]s"
36+
restore_time = data.huaweicloud_rds_restore_time_ranges.test.restore_time[0].start_time
37+
38+
databases {
39+
database = "test1"
40+
41+
schemas {
42+
schema = "test1"
43+
44+
tables {
45+
old_name = "table1"
46+
new_name = "table1_test_update"
47+
}
48+
}
49+
}
50+
`, acceptance.HW_RDS_INSTANCE_ID)
51+
}

0 commit comments

Comments
 (0)