Skip to content

Commit 4ee7cb8

Browse files
author
Suzana Nesic
committed
adding replica removal validation
Signed-off-by: Suzana Nesic <[email protected]>
1 parent a32d270 commit 4ee7cb8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: hooks/post_plan.py

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def _validate_version_upgrade(self) -> None:
100100
continue
101101
current_version = u.change.before["engine_version"]
102102
desired_version = u.change.after["engine_version"]
103+
db_name = u.change.after["identifier"]
103104
if current_version != desired_version:
104105
valid_upgrade_targets = self.aws_api.get_rds_valid_upgrade_targets(
105106
u.change.before["engine"], current_version
@@ -120,6 +121,11 @@ def _validate_version_upgrade(self) -> None:
120121
self.errors.append(
121122
"To enable major version upgrade, allow_major_version_upgrade attribute must be set to True"
122123
)
124+
# Read replica removal validation
125+
if len(u.change.after["replicas"]) > 0:
126+
self.errors.append(
127+
f"The primary database, {db_name}, has a read replica associated with it. Please remove the replica before upgrading the primary database"
128+
)
123129

124130
def _validate_deletion_protection_not_enabled_on_destroy(self) -> None:
125131
for u in self.aws_db_instance_deletions:

0 commit comments

Comments
 (0)