Skip to content

Commit 9faf1dc

Browse files
authored
fix(rdb): read replica: fix default value in doc (#2313)
* fix(rdb): read replica: fix default value for `same_zone` * test(rdb): read replica: test default value for `same_zone`
1 parent d5219b9 commit 9faf1dc

File tree

3 files changed

+648
-319
lines changed

3 files changed

+648
-319
lines changed

docs/resources/rdb_read_replica.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ The following arguments are supported:
7070
CIDR notation. The IP network address within the private subnet is determined by the IP Address Management (IPAM)
7171
service if not set.
7272

73-
- `same_zone` - (Defaults to `false`) Defines whether to create the replica in the same availability zone as the main instance nodes or not.
73+
- `same_zone` - (Defaults to `true`) Defines whether to create the replica in the same availability zone as the main instance nodes or not.
7474

75-
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions)
75+
- `region` - (Defaults to [provider](../index.md#arguments-reference) `region`) The [region](../guides/regions_and_zones.md#regions)
7676
in which the Database read replica should be created.
7777

7878
## Attributes Reference

scaleway/resource_rdb_read_replica_test.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ func TestAccScalewayRdbReadReplica_DifferentZone(t *testing.T) {
260260
resource "scaleway_rdb_read_replica" "different_zone" {
261261
instance_id = scaleway_rdb_instance.different_zone.id
262262
region = scaleway_rdb_instance.different_zone.region
263-
same_zone = false
264263
private_network {
265264
private_network_id = scaleway_vpc_private_network.different_zone.id
266265
}
@@ -269,7 +268,7 @@ func TestAccScalewayRdbReadReplica_DifferentZone(t *testing.T) {
269268
testAccCheckRdbReadReplicaExists(tt, "scaleway_rdb_read_replica.different_zone"),
270269
testAccCheckScalewayVPCPrivateNetworkExists(tt, "scaleway_vpc_private_network.different_zone"),
271270
resource.TestCheckResourceAttrPair("scaleway_rdb_read_replica.different_zone", "instance_id", "scaleway_rdb_instance.different_zone", "id"),
272-
resource.TestCheckResourceAttr("scaleway_rdb_read_replica.different_zone", "same_zone", "false"),
271+
resource.TestCheckResourceAttr("scaleway_rdb_read_replica.different_zone", "same_zone", "true"),
273272
testAccCheckScalewayResourceIDPersisted("scaleway_rdb_read_replica.different_zone", &readReplicaID),
274273
),
275274
},
@@ -303,6 +302,39 @@ func TestAccScalewayRdbReadReplica_DifferentZone(t *testing.T) {
303302
testAccCheckScalewayVPCPrivateNetworkExists(tt, "scaleway_vpc_private_network.different_zone"),
304303
resource.TestCheckResourceAttrPair("scaleway_rdb_read_replica.different_zone", "instance_id", "scaleway_rdb_instance.different_zone", "id"),
305304
resource.TestCheckResourceAttr("scaleway_rdb_read_replica.different_zone", "same_zone", "true"),
305+
testAccCheckScalewayResourceIDPersisted("scaleway_rdb_read_replica.different_zone", &readReplicaID),
306+
),
307+
},
308+
{
309+
Config: `
310+
resource "scaleway_vpc_private_network" "different_zone" {
311+
name = "test-rdb-rr-different-zone"
312+
}
313+
314+
resource "scaleway_rdb_instance" "different_zone" {
315+
name = "test-rdb-rr-different-zone"
316+
node_type = "db-dev-s"
317+
engine = "PostgreSQL-14"
318+
is_ha_cluster = false
319+
disable_backup = true
320+
user_name = "my_initial_user"
321+
password = "thiZ_is_v&ry_s3cret"
322+
tags = [ "terraform-test", "scaleway_rdb_read_replica", "different-zone" ]
323+
}
324+
325+
resource "scaleway_rdb_read_replica" "different_zone" {
326+
instance_id = scaleway_rdb_instance.different_zone.id
327+
region = scaleway_rdb_instance.different_zone.region
328+
same_zone = false
329+
private_network {
330+
private_network_id = scaleway_vpc_private_network.different_zone.id
331+
}
332+
}`,
333+
Check: resource.ComposeTestCheckFunc(
334+
testAccCheckRdbReadReplicaExists(tt, "scaleway_rdb_read_replica.different_zone"),
335+
testAccCheckScalewayVPCPrivateNetworkExists(tt, "scaleway_vpc_private_network.different_zone"),
336+
resource.TestCheckResourceAttrPair("scaleway_rdb_read_replica.different_zone", "instance_id", "scaleway_rdb_instance.different_zone", "id"),
337+
resource.TestCheckResourceAttr("scaleway_rdb_read_replica.different_zone", "same_zone", "false"),
306338
testAccCheckScalewayResourceIDChanged("scaleway_rdb_read_replica.different_zone", &readReplicaID),
307339
),
308340
},

0 commit comments

Comments
 (0)