Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
fix(rds): a backup retention period of 0 turns binary logging off (#2008)
Jeff Heller772bf989798f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 23459e19..caf419aa 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).### Fixed+- **RDS — a backup retention period of 0 turns binary logging off** — on RDS for MySQL, `BackupRetentionPeriod=0` turns binary logging off; MiniStack's MySQL 8.0/8.4 instances kept the image default, binary logging on. Such an instance now starts with binary logging off. Contributed by @skialpine.- **IoT — `CreateThingGroup` on an existing name returns the group when nothing differs** — a repeated `CreateThingGroup` always failed with `ResourceAlreadyExistsException`. It now returns the existing group's name, ARN and id when the description, attributes (in any order), parent and tags match, and answers 409 with AWS's message otherwise, leaving the group unchanged, as AWS does. An `AWS::IoT::ThingGroup` that names an existing group still fails its stack, with or without matching properties, now with AWS's name-conflict message. Contributed by @iot-rocket.- **IoT — just-in-time registration under a CA in `SNI_ONLY` mode** — a device certificate signed by a CA registered with `certificateMode` `SNI_ONLY` and auto-registration enabled was refused on its first mTLS connect, so only `DEFAULT` CAs auto-registered. Such a CA now registers the certificate `PENDING_ACTIVATION` and publishes the registered event when the device's TLS ClientHello names the account's endpoint (its DescribeEndpoint prefix in any region) or a host the gateway serves (`localhost`, a compose service name, `MINISTACK_HOST`), and does nothing without a server name. Under a `DEFAULT` CA, a server name with another account's endpoint prefix or a name the gateway does not serve (`mqtt.example.com`) no longer auto-registers, as on AWS. Contributed by @iot-rocket.diff --git a/ministack/services/rds.py b/ministack/services/rds.pyindex 2f86873d..c218815d 100644--- a/ministack/services/rds.py+++ b/ministack/services/rds.py@@ -2457,6 +2457,10 @@ def _start_rds_container_for_instance(db_id, instance):container_kwargs["tmpfs"] = {data_path: f"rw,noexec,nosuid,size={RDS_TMPFS_SIZE}",}+ if _is_mysql_engine(engine) and (+ options := _mysql_server_options(instance.get("BackupRetentionPeriod", 1))+ ):+ container_kwargs["command"] = optionstry:container = _run_rds_container(@@ -2619,6 +2623,12 @@ def _is_mysql_engine(engine):return any(e in engine for e in ("mysql", "aurora-mysql", "mariadb"))+def _mysql_server_options(backup_retention_period):+ """Server options for a standalone MySQL/MariaDB instance. As on RDS, a+ backup retention period of 0 turns binary logging off."""+ return [] if int(backup_retention_period) > 0 else ["--skip-log-bin"]++def _is_postgres_engine(engine):return any(e in engine for e in ("postgres", "aurora-postgresql"))@@ -4775,6 +4785,10 @@ def _create_db_instance_impl(p):container_kwargs["tmpfs"] = {data_path: f"rw,noexec,nosuid,size={RDS_TMPFS_SIZE}",}+ if _is_mysql_engine(engine) and (+ options := _mysql_server_options(_p(p, "BackupRetentionPeriod") or "1")+ ):+ container_kwargs["command"] = optionscontainer = _run_rds_container(docker_client, engine, container_kwargs,tls_names=[endpoint_host or "",diff --git a/tests/test_rds.py b/tests/test_rds.pyindex 937a39d7..7b1f430e 100644--- a/tests/test_rds.py+++ b/tests/test_rds.py@@ -8186,6 +8186,30 @@ def _aurora_connect(endpoint, user="admin", password=PASSWORD, database=DATABASE)[email protected]_plane+def test_rds_mysql_binary_logging_follows_backup_retention(rds):+ """On RDS a backup retention period of 0 turns binary logging off."""+ suffix = uuid.uuid4().hex[:8]+ expected = {f"binlog-off-{suffix}": 0, f"binlog-on-{suffix}": 1}+ try:+ for db_id, retention in zip(expected, (0, 1)):+ rds.create_db_instance(+ DBInstanceIdentifier=db_id, Engine="mysql", EngineVersion="8.0",+ DBInstanceClass="db.t3.micro", AllocatedStorage=20, DBName=DATABASE,+ MasterUsername="admin", MasterUserPassword=PASSWORD,+ BackupRetentionPeriod=retention,+ )+ for db_id, log_bin in expected.items():+ conn = _aurora_connect(_wait_for_instance(rds, db_id)["Endpoint"])+ with conn.cursor() as cur:+ cur.execute("SELECT @@log_bin")+ assert cur.fetchone()[0] == log_bin+ conn.close()+ finally:+ for db_id in expected:+ rds.delete_db_instance(DBInstanceIdentifier=db_id, SkipFinalSnapshot=True)++@contextlib.contextmanagerdef _live_cluster(rds, engine_version=None):suffix = uuid.uuid4().hex[:10]