Skip to content

Commit 71b51fd

Browse files
authored
Fix: Fix issue with replica state key and random IDs (#141)
1 parent 76244bd commit 71b51fd

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

docs/upgrading_to_sql_db_4.0.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ The new `read_replicas` variable is used to manage all replica configuration. In
4242

4343
- You must have `read_replica_size` objects inside `read_replicas`
4444
- You must use the full `zone` id which includes the region e.g. `europe-west1-c` instead of `c`
45+
- You must not have used `random_instance_name`
46+
47+
**Important:** If you have enabled `random_instance_name` then you will need to manually migrate state because the migration script and module does not include the random string as part of the replica state key.
4548

4649
```diff
4750
module "test" {

modules/mysql/read_replica.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
locals {
1818
replicas = {
19-
for x in var.read_replicas : "${local.master_instance_name}-replica${var.read_replica_name_suffix}${x.name}" => x
19+
for x in var.read_replicas : "${var.name}-replica${var.read_replica_name_suffix}${x.name}" => x
2020
}
2121
}
2222

modules/postgresql/read_replica.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
locals {
1818
replicas = {
19-
for x in var.read_replicas : "${local.master_instance_name}-replica${var.read_replica_name_suffix}${x.name}" => x
19+
for x in var.read_replicas : "${var.name}-replica${var.read_replica_name_suffix}${x.name}" => x
2020
}
2121
}
2222

0 commit comments

Comments
 (0)