Skip to content

Commit 3618ba3

Browse files
authored
Drop support for blue_green_update (#113)
* feat: drop support for blue_green_update * refactor: use Self as return type * chore: bump version to 0.6.2 Signed-off-by: Di Wang <[email protected]>
1 parent cb29b3f commit 3618ba3

File tree

7 files changed

+33
-34
lines changed

7 files changed

+33
-34
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM quay.io/redhat-services-prod/app-sre-tenant/er-base-terraform-main/er-base-terraform-main:tf-1.6.6-py-3.12-v0.3.4-1@sha256:1579e58702182a02b55a0841254d188a6b99ff42c774279890567338c863a31b AS base
22
# keep in sync with pyproject.toml
3-
LABEL konflux.additional-tags="0.6.1"
3+
LABEL konflux.additional-tags="0.6.2"
44

55
FROM base AS builder
66
COPY --from=ghcr.io/astral-sh/uv:0.5.25@sha256:a73176b27709bff700a1e3af498981f31a83f27552116f21ae8371445f0be710 /uv /bin/uv

er_aws_rds/input.py

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Sequence
2-
from typing import Any, Literal
2+
from typing import Any, Literal, Self
33

44
from external_resources_io.input import AppInterfaceProvision
55
from pydantic import (
@@ -193,7 +193,7 @@ def db_name(self) -> str | None:
193193
return self.name
194194

195195
@model_validator(mode="after")
196-
def az_belongs_to_region(self) -> "Rds":
196+
def az_belongs_to_region(self) -> Self:
197197
"""Check if a the AZ belongs to a region"""
198198
if self.availability_zone:
199199
az_region = self.availability_zone[:-1]
@@ -207,14 +207,14 @@ def az_belongs_to_region(self) -> "Rds":
207207
return self
208208

209209
@model_validator(mode="after")
210-
def unset_az_if_multi_region(self) -> "Rds":
210+
def unset_az_if_multi_region(self) -> Self:
211211
"""Remove az for multi_region instances"""
212212
if self.multi_az:
213213
self.availability_zone = None
214214
return self
215215

216216
@model_validator(mode="after")
217-
def unset_replica_or_snapshot_not_allowed_attrs(self) -> "Rds":
217+
def unset_replica_or_snapshot_not_allowed_attrs(self) -> Self:
218218
"""
219219
Some attributes are not allowed if the instance is a read replica or is created from a snapshot.
220220
@@ -228,7 +228,7 @@ def unset_replica_or_snapshot_not_allowed_attrs(self) -> "Rds":
228228
return self
229229

230230
@model_validator(mode="after")
231-
def replication(self) -> "Rds":
231+
def replication(self) -> Self:
232232
"""replica_source and replicate_source_db are mutually excluive"""
233233
if not self.replica_source:
234234
return self
@@ -257,7 +257,7 @@ def replication(self) -> "Rds":
257257
return self
258258

259259
@model_validator(mode="after")
260-
def validate_parameter_group_parameters(self) -> "Rds":
260+
def validate_parameter_group_parameters(self) -> Self:
261261
"""Validate that every parameter complies with our requirements"""
262262
if not self.parameter_group:
263263
return self
@@ -271,7 +271,7 @@ def validate_parameter_group_parameters(self) -> "Rds":
271271
return self
272272

273273
@model_validator(mode="after")
274-
def parameter_groups(self) -> "Rds":
274+
def parameter_groups(self) -> Self:
275275
"""
276276
Sets the right parameter group names. The instance identifier is used as prefix on each pg.
277277
@@ -317,7 +317,7 @@ def is_read_replica(self) -> bool:
317317
return self.replica_source is not None or self.replicate_source_db is not None
318318

319319
@model_validator(mode="after")
320-
def enhanced_monitoring_attributes(self) -> "Rds":
320+
def enhanced_monitoring_attributes(self) -> Self:
321321
"""
322322
Enhanced monitoring validation:
323323
@@ -340,21 +340,17 @@ def enhanced_monitoring_attributes(self) -> "Rds":
340340
return self
341341

342342
@model_validator(mode="after")
343-
def kms_key_id_remove_alias_prefix(self) -> "Rds":
343+
def kms_key_id_remove_alias_prefix(self) -> Self:
344344
"""Remove alias prefix from kms_key_id"""
345345
if self.kms_key_id:
346346
self.kms_key_id = self.kms_key_id.removeprefix("alias/")
347347
return self
348348

349349
@model_validator(mode="after")
350-
def blue_green_update_requirements(self) -> "Rds":
351-
if (
352-
self.blue_green_update
353-
and self.blue_green_update.enabled
354-
and self.snapshot_identifier
355-
):
350+
def _validate_blue_green_update(self) -> Self:
351+
if self.blue_green_update and self.blue_green_update.enabled:
356352
raise ValueError(
357-
"Blue/Green updates can not be enabled when snapshot_identifier is set"
353+
"blue_green_update is not supported, use blue_green_deployment instead"
358354
)
359355
return self
360356

module/basic_instance.tftest.hcl

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ variables {
2121
performance_insights_enabled = true
2222
deletion_protection = true
2323
ca_cert_identifier = "rds-ca-rsa2048-g1"
24-
blue_green_update = { enabled = true }
2524
db_name = "custom_database"
2625
}
2726

module/main.tf

+8-14
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,14 @@ resource "aws_db_event_subscription" "this" {
8686
}
8787

8888
resource "aws_db_instance" "this" {
89-
allocated_storage = try(var.rds_instance.allocated_storage, null)
90-
allow_major_version_upgrade = try(var.rds_instance.allow_major_version_upgrade, null)
91-
apply_immediately = try(var.rds_instance.apply_immediately, null)
92-
auto_minor_version_upgrade = try(var.rds_instance.auto_minor_version_upgrade, null)
93-
availability_zone = try(var.rds_instance.availability_zone, null)
94-
backup_retention_period = try(var.rds_instance.backup_retention_period, null)
95-
backup_target = try(var.rds_instance.backup_target, null)
96-
backup_window = try(var.rds_instance.backup_window, null)
97-
dynamic "blue_green_update" {
98-
for_each = try(length(var.rds_instance.blue_green_update), 0) > 0 ? [var.rds_instance.blue_green_update.enabled] : []
99-
content {
100-
enabled = try(var.rds_instance.blue_green_update.enabled, null)
101-
}
102-
}
89+
allocated_storage = try(var.rds_instance.allocated_storage, null)
90+
allow_major_version_upgrade = try(var.rds_instance.allow_major_version_upgrade, null)
91+
apply_immediately = try(var.rds_instance.apply_immediately, null)
92+
auto_minor_version_upgrade = try(var.rds_instance.auto_minor_version_upgrade, null)
93+
availability_zone = try(var.rds_instance.availability_zone, null)
94+
backup_retention_period = try(var.rds_instance.backup_retention_period, null)
95+
backup_target = try(var.rds_instance.backup_target, null)
96+
backup_window = try(var.rds_instance.backup_window, null)
10397
ca_cert_identifier = try(var.rds_instance.ca_cert_identifier, null)
10498
character_set_name = try(var.rds_instance.character_set_name, null)
10599
copy_tags_to_snapshot = try(var.rds_instance.copy_tags_to_snapshot, null)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "er-aws-rds"
3-
version = "0.6.1"
3+
version = "0.6.2"
44
description = "ERv2 module for managing AWS rds instances"
55
authors = [{ name = "AppSRE", email = "[email protected]" }]
66
license = { text = "Apache 2.0" }

tests/test_input_validation.py

+10
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,13 @@ def test_timeouts() -> None:
280280
model = AppInterfaceInput.model_validate(mod_input)
281281
assert model.data.timeouts is not None
282282
assert model.data.timeouts.create == "60m"
283+
284+
285+
def test_validate_blue_green_update() -> None:
286+
"""Test blue_green_update"""
287+
mod_input = input_data({"data": {"blue_green_update": {"enabled": True}}})
288+
with pytest.raises(
289+
ValidationError,
290+
match=r"blue_green_update is not supported, use blue_green_deployment instead",
291+
):
292+
AppInterfaceInput.model_validate(mod_input)

uv.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)