Skip to content

Commit 8127e29

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

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
@@ -102,6 +102,7 @@ def _validate_version_upgrade(self) -> None:
102102
continue
103103
current_version = u.change.before["engine_version"]
104104
desired_version = u.change.after["engine_version"]
105+
db_name = u.change.after["identifier"]
105106
if current_version != desired_version:
106107
valid_update_versions = self.aws_api.get_rds_valid_update_versions(
107108
u.change.before["engine"], current_version
@@ -128,6 +129,11 @@ def _validate_version_upgrade(self) -> None:
128129
self.errors.append(
129130
"To enable major version ugprades, allow_major_version_upgrade attribute must be set to True"
130131
)
132+
# Read replica removal validation
133+
if len(u.change.after["replicas"]) > 0:
134+
self.errors.append(
135+
f"The primary database, {db_name}, has a read replica associated with it. Please remove the replica before upgrading the primary database"
136+
)
131137

132138
def _validate_deletion_protection_not_enabled_on_destroy(self) -> None:
133139
for u in self.aws_db_instance_deletions:

0 commit comments

Comments
 (0)