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): creating an existing parameter group is refused (#2009)
Jeff Hellerb5d7c69f34f0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex caf419aa..a4543509 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).### Fixed+- **RDS — creating an existing parameter group is refused** — `CreateDBParameterGroup` and `CreateDBClusterParameterGroup` with a name already in use replaced the group with an empty one, dropping its parameters; they now return `DBParameterGroupAlreadyExists`, as AWS does. Contributed by @skialpine.- **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 c218815d..f111e23d 100644--- a/ministack/services/rds.py+++ b/ministack/services/rds.py@@ -6465,6 +6465,8 @@ def _create_param_group(p):name = _p(p, "DBParameterGroupName")if not name:return _error("MissingParameter", "DBParameterGroupName is required", 400)+ if name in _param_groups:+ return _error("DBParameterGroupAlreadyExists", f"Parameter group {name} already exists", 400)family = _p(p, "DBParameterGroupFamily") or "postgres15"desc = _p(p, "Description") or namearn = f"arn:aws:rds:{get_region()}:{get_account_id()}:pg:{name}"@@ -6593,6 +6595,8 @@ def _create_db_cluster_param_group(p):name = _p(p, "DBClusterParameterGroupName")if not name:return _error("MissingParameter", "DBClusterParameterGroupName is required", 400)+ if name in _db_cluster_param_groups:+ return _error("DBParameterGroupAlreadyExists", f"Parameter group {name} already exists", 400)family = _p(p, "DBParameterGroupFamily") or "aurora-postgresql15"desc = _p(p, "Description") or namearn = f"arn:aws:rds:{get_region()}:{get_account_id()}:cluster-pg:{name}"diff --git a/tests/test_rds.py b/tests/test_rds.pyindex 7b1f430e..566f2dec 100644--- a/tests/test_rds.py+++ b/tests/test_rds.py@@ -501,6 +501,30 @@ def test_rds_cluster_parameter_group(rds):assert groups[0]["DBClusterParameterGroupName"] == "test-cpg"rds.delete_db_cluster_parameter_group(DBClusterParameterGroupName="test-cpg")+def test_rds_create_parameter_group_refuses_an_existing_name(rds):+ """AWS refuses a second create of a parameter group; it must not replace the group with an empty one."""+ name = f"pg-dup-{_uuid_mod.uuid4().hex[:8]}"+ rds.create_db_parameter_group(DBParameterGroupName=name, DBParameterGroupFamily="mysql8.0", Description="d")+ rds.create_db_cluster_parameter_group(DBClusterParameterGroupName=name,+ DBParameterGroupFamily="aurora-mysql8.0", Description="d")+ rds.modify_db_parameter_group(DBParameterGroupName=name, Parameters=[+ {"ParameterName": "max_connections", "ParameterValue": "100", "ApplyMethod": "immediate"}])+ try:+ for create in (+ lambda: rds.create_db_parameter_group(DBParameterGroupName=name,+ DBParameterGroupFamily="mysql8.0", Description="d"),+ lambda: rds.create_db_cluster_parameter_group(DBClusterParameterGroupName=name,+ DBParameterGroupFamily="aurora-mysql8.0", Description="d"),+ ):+ with pytest.raises(ClientError) as exc:+ create()+ assert exc.value.response["Error"]["Code"] == "DBParameterGroupAlreadyExists"+ params = rds.describe_db_parameters(DBParameterGroupName=name, Source="user")["Parameters"]+ assert [(p["ParameterName"], p["ParameterValue"]) for p in params] == [("max_connections", "100")]+ finally:+ rds.delete_db_parameter_group(DBParameterGroupName=name)+ rds.delete_db_cluster_parameter_group(DBClusterParameterGroupName=name)+def test_rds_modify_db_parameter_group(rds):rds.create_db_parameter_group(DBParameterGroupName="test-mpg",