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
feat(cfn): DBSubnetGroup (#2032)
Nahuel Nuceraf1c13b225937
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8a2cb903..07370816 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,6 +23,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).- **Cognito — app client secret hashes** — clients created with `GenerateSecret=true` require a valid `SecretHash` on signup, confirmation and password recovery, and `SECRET_HASH` on authentication and challenge responses. Missing or incorrect hashes return `NotAuthorizedException` before user changes, email delivery or Lambda triggers. Clients without a secret reject a supplied hash on self-service and initial authentication calls, while refresh and challenge responses ignore it, as on AWS. Refresh authentication verifies the token owner's username, or `sub` when the pool uses `UsernameAttributes`, and custom challenge sessions cannot be answered through a different client. The checks apply in both `AUTH` modes.### Added+- **CloudFormation — `AWS::RDS::DBSubnetGroup`, `AWS::RDS::DBParameterGroup`, `AWS::RDS::DBClusterParameterGroup` and `AWS::SecretsManager::SecretTargetAttachment`** — templates with these types, which the CDK `rds.DatabaseInstance` and `rds.DatabaseCluster` constructs emit, were refused with `Unrecognized resource types`. They now create, update and delete through the RDS and Secrets Manager APIs: `Ref` returns the group name or, for the attachment, the secret ARN; `Fn::GetAtt` gives `DBSubnetGroupArn`, `DBParameterGroupName` and `DBParameterGroupArn`; a parameter CloudFormation cannot apply immediately goes `pending-reboot`; and the attachment writes `engine`, `host`, `port` and `dbname` into the secret JSON and removes them when it is deleted. Reported by @fabio-andre-rodrigues.- **Aurora DSQL — partial indexes** — `CREATE INDEX ASYNC ... WHERE predicate` was refused `0A000` although the service supports it since 2026-09-15; the predicate now reaches the backend and builds a real partial index (unique partial indexes scope uniqueness to the rows they cover). A predicate calling a volatile function fails at submit with `42P17` "functions in index predicate must be marked IMMUTABLE", and a subquery with `0A000`, instead of coming back as a failed job; both are checked in the order the live service uses (eu-central-1, 2026-10-04). Contributed by @vivedo.- **Aurora DSQL — `dsql.enable_batched_nestloop` and the reserved `dsql.` prefix** — the session setting added with batched nested-loop joins (2026-09-11) shows `on` before any `SET`, `RESET` returns to `on`, and a non-Boolean value (through `SET` or `set_config`) or a value list is refused `22023` in the service's wording. Any other `dsql.*` name is refused `42602` with the service's "reserved prefix" detail, and `work_mem`, `statement_timeout` and `default_statistics_target` can no longer be set (`0A000`), as on the live service. Plans stay Postgres-shaped: no `Nested Loop (Batched Join)` node. Contributed by @vivedo.- **Aurora DSQL — extended statistics limits** — `CREATE STATISTICS` reached the backend without a cap; a sixth object on a table now fails with the service's `54000` "more than 5 extended statistics per table are not allowed", after the statement's own errors and with `IF NOT EXISTS` on an existing name still a no-op. Statistics targets above 100 are refused (`22023`) and `ALTER TABLE ... ALTER COLUMN ... SET STATISTICS` is refused (`0A000`), in the service's wordings. Contributed by @vivedo.diff --git a/ministack/services/cloudformation/provisioners.py b/ministack/services/cloudformation/provisioners.pyindex 1299183c..b170034a 100644--- a/ministack/services/cloudformation/provisioners.py+++ b/ministack/services/cloudformation/provisioners.py@@ -817,6 +817,8 @@ _CUSTOM_NAME_REPLACEMENT = {"requires_replacement": lambda old, new: any(old.get(p) != new.get(p) for p in _RDS_DB_INSTANCE_CREATE_ONLY + ("Engine",)),},+ "AWS::RDS::DBParameterGroup": {"name": "DBParameterGroupName"},+ "AWS::RDS::DBClusterParameterGroup": {"name": "DBClusterParameterGroupName"},# Type and WorkflowName are "Update requires: Replacement" in the# aws-resource-glue-trigger reference."AWS::Glue::Trigger": {@@ -1124,6 +1126,9 @@ _STACK_TAG_PROPERTY: dict[str, tuple[str, str]] = {"AWS::Logs::LogGroup": ("Tags", "list"),"AWS::OpenSearchService::Domain": ("Tags", "list"),"AWS::RDS::DBInstance": ("Tags", "list"),+ "AWS::RDS::DBClusterParameterGroup": ("Tags", "list"),+ "AWS::RDS::DBParameterGroup": ("Tags", "list"),+ "AWS::RDS::DBSubnetGroup": ("Tags", "list"),"AWS::SNS::Topic": ("Tags", "list"),"AWS::SQS::Queue": ("Tags", "list"),"AWS::SSM::Parameter": ("Tags", "map"),@@ -11009,6 +11014,257 @@ def _rds_db_instance_delete(physical_id, props):]+# ---------------------------------------------------------------------------+# RDS DBSubnetGroup / DBParameterGroup / DBClusterParameterGroup+# ---------------------------------------------------------------------------++def _rds_raise(status, body, resource_type, action):+ text = body.decode("utf-8", errors="replace") if isinstance(body, bytes) else str(body)+ code = re.search(r"<Code>(.*?)</Code>", text)+ message = re.search(r"<Message>(.*?)</Message>", text, re.S)+ raise ValueError(+ f"{resource_type} {action} failed: "+ f"{code.group(1) if code else status}: {message.group(1) if message else text}")+++def _rds_call(fn, params, resource_type, action):+ status, _headers, body = fn(params)+ if status >= 400:+ _rds_raise(status, body, resource_type, action)+++def _rds_sync_tags(arn, old_props, new_props, resource_type):+ old_tags = _tag_map(old_props.get("Tags"))+ new_tags = _tag_map(new_props.get("Tags"))+ removed = sorted(old_tags.keys() - new_tags.keys())+ if removed:+ _rds_call(_rds._remove_tags, {"ResourceName": arn, **_ec_query({"TagKeys": removed})},+ resource_type, "untag")+ changed = {k: v for k, v in new_tags.items() if old_tags.get(k) != v}+ if changed:+ _rds_call(_rds._add_tags, {"ResourceName": arn, **_ec_query({+ "Tags": [{"Key": k, "Value": v} for k, v in changed.items()]})},+ resource_type, "tag")+++def _rds_parameter_values(props):+ return {str(k): str(v).lower() if isinstance(v, bool) else str(v)+ for k, v in (props.get("Parameters") or {}).items()}+++def _rds_set_parameters(fn, name_key, name, values, resource_type, action):+ # CloudFormation uses each parameter's default apply method: a static+ # parameter refused as immediate goes pending-reboot.+ for pname, pvalue in values.items():+ for method in ("immediate", "pending-reboot"):+ status, _headers, body = fn({+ name_key: name,+ "Parameters.member.1.ParameterName": pname,+ "Parameters.member.1.ParameterValue": pvalue,+ "Parameters.member.1.ApplyMethod": method,+ })+ if status < 400:+ break+ if method == "immediate" and b"InvalidParameterCombination" in body:+ continue+ _rds_raise(status, body, resource_type, action)+++def _rds_reset_parameters(fn, name_key, name, names, resource_type, action):+ params = {name_key: name}+ for i, pname in enumerate(names, 1):+ params[f"Parameters.member.{i}.ParameterName"] = pname+ params[f"Parameters.member.{i}.ApplyMethod"] = "immediate"+ _rds_call(fn, params, resource_type, action)+++def _rds_update_parameters(modify_fn, reset_fn, name_key, name, old_props, new_props,+ resource_type):+ old_values = _rds_parameter_values(old_props)+ new_values = _rds_parameter_values(new_props)+ changed = {k: v for k, v in new_values.items() if old_values.get(k) != v}+ if changed:+ _rds_set_parameters(modify_fn, name_key, name, changed, resource_type, "update")+ dropped = sorted(old_values.keys() - new_values.keys())+ if dropped:+ _rds_reset_parameters(reset_fn, name_key, name, dropped, resource_type, "update")+++def _rds_subnet_group_create(logical_id, props, stack_name):+ name = props.get("DBSubnetGroupName") or _physical_name(+ stack_name, logical_id, lowercase=True, max_len=255)+ _rds_call(_rds._create_subnet_group, {+ "DBSubnetGroupName": name,+ **_ec_query({"DBSubnetGroupDescription": props.get("DBSubnetGroupDescription", ""),+ "SubnetIds": props.get("SubnetIds") or []}),+ }, "AWS::RDS::DBSubnetGroup", "create")+ arn = _rds._subnet_groups[name]["DBSubnetGroupArn"]+ _rds_sync_tags(arn, {}, props, "AWS::RDS::DBSubnetGroup")+ return name, {"DBSubnetGroupArn": arn}+++def _rds_subnet_group_update(physical_id, old_props, new_props, stack_name, logical_id=None):+ if physical_id not in _rds._subnet_groups:+ return _rds_subnet_group_create(logical_id or physical_id, new_props, stack_name)+ _rds_call(_rds._modify_subnet_group, {+ "DBSubnetGroupName": physical_id,+ **_ec_query({"DBSubnetGroupDescription": new_props.get("DBSubnetGroupDescription", ""),+ "SubnetIds": new_props.get("SubnetIds") or []}),+ }, "AWS::RDS::DBSubnetGroup", "update")+ arn = _rds._subnet_groups[physical_id]["DBSubnetGroupArn"]+ _rds_sync_tags(arn, old_props, new_props, "AWS::RDS::DBSubnetGroup")+ return physical_id, {"DBSubnetGroupArn": arn}+++def _rds_subnet_group_delete(physical_id, props):+ _rds._delete_subnet_group({"DBSubnetGroupName": physical_id})+++def _rds_param_group_attrs(name):+ return {"DBParameterGroupName": name,+ "DBParameterGroupArn": _rds._param_groups[name]["DBParameterGroupArn"]}+++def _rds_param_group_create(logical_id, props, stack_name):+ name = props.get("DBParameterGroupName") or _physical_name(+ stack_name, logical_id, lowercase=True, max_len=255)+ _rds_call(_rds._create_param_group, {+ "DBParameterGroupName": name,+ "DBParameterGroupFamily": props.get("Family", ""),+ "Description": props.get("Description", ""),+ }, "AWS::RDS::DBParameterGroup", "create")+ _rds_set_parameters(_rds._modify_param_group, "DBParameterGroupName", name,+ _rds_parameter_values(props), "AWS::RDS::DBParameterGroup", "create")+ _rds_sync_tags(_rds._param_groups[name]["DBParameterGroupArn"], {}, props,+ "AWS::RDS::DBParameterGroup")+ return name, _rds_param_group_attrs(name)+++def _rds_param_group_update(physical_id, old_props, new_props, stack_name, logical_id=None):+ if physical_id not in _rds._param_groups:+ return _rds_param_group_create(logical_id or physical_id, new_props, stack_name)+ _rds_update_parameters(_rds._modify_param_group, _rds._reset_param_group,+ "DBParameterGroupName", physical_id, old_props, new_props,+ "AWS::RDS::DBParameterGroup")+ _rds_sync_tags(_rds._param_groups[physical_id]["DBParameterGroupArn"], old_props, new_props,+ "AWS::RDS::DBParameterGroup")+ return physical_id, _rds_param_group_attrs(physical_id)+++def _rds_param_group_delete(physical_id, props):+ _rds._delete_param_group({"DBParameterGroupName": physical_id})+++def _rds_cluster_param_group_create(logical_id, props, stack_name):+ name = props.get("DBClusterParameterGroupName") or _physical_name(+ stack_name, logical_id, lowercase=True, max_len=255)+ _rds_call(_rds._create_db_cluster_param_group, {+ "DBClusterParameterGroupName": name,+ "DBParameterGroupFamily": props.get("Family", ""),+ "Description": props.get("Description", ""),+ }, "AWS::RDS::DBClusterParameterGroup", "create")+ _rds_set_parameters(_rds._modify_db_cluster_param_group, "DBClusterParameterGroupName", name,+ _rds_parameter_values(props), "AWS::RDS::DBClusterParameterGroup", "create")+ _rds_sync_tags(_rds._db_cluster_param_groups[name]["DBClusterParameterGroupArn"], {}, props,+ "AWS::RDS::DBClusterParameterGroup")+ return name, {}+++def _rds_cluster_param_group_update(physical_id, old_props, new_props, stack_name,+ logical_id=None):+ if physical_id not in _rds._db_cluster_param_groups:+ return _rds_cluster_param_group_create(logical_id or physical_id, new_props, stack_name)+ _rds_update_parameters(_rds._modify_db_cluster_param_group, _rds._reset_db_cluster_param_group,+ "DBClusterParameterGroupName", physical_id, old_props, new_props,+ "AWS::RDS::DBClusterParameterGroup")+ _rds_sync_tags(_rds._db_cluster_param_groups[physical_id]["DBClusterParameterGroupArn"],+ old_props, new_props, "AWS::RDS::DBClusterParameterGroup")+ return physical_id, {}+++def _rds_cluster_param_group_delete(physical_id, props):+ _rds._delete_db_cluster_param_group({"DBClusterParameterGroupName": physical_id})+++# ---------------------------------------------------------------------------+# SecretsManager SecretTargetAttachment+# ---------------------------------------------------------------------------++_SM_TARGET_KEYS = ("engine", "host", "port", "dbname")+++def _sm_target_connection(target_type, target_id):+ """The connection keys the attachment writes into the secret JSON."""+ if target_type == "AWS::RDS::DBInstance":+ record = _rds._instances.get(target_id)+ if record:+ endpoint = record.get("Endpoint") or {}+ host, port, dbname = endpoint.get("Address"), endpoint.get("Port"), record.get("DBName")+ elif target_type == "AWS::RDS::DBCluster":+ record = _rds._clusters.get(target_id)+ if record:+ host, port, dbname = record.get("Endpoint"), record.get("Port"), record.get("DatabaseName")+ else:+ raise ValueError(f"AWS::SecretsManager::SecretTargetAttachment: TargetType {target_type} "+ "is not supported")+ if not record:+ raise ValueError(f"AWS::SecretsManager::SecretTargetAttachment: {target_type} "+ f"{target_id} not found")+ engine = record.get("Engine", "")+ for prefix, name in (("aurora-postgresql", "postgres"), ("aurora", "mysql"),+ ("oracle", "oracle"), ("sqlserver", "sqlserver")):+ if engine.startswith(prefix):+ engine = name+ break+ info = {"engine": engine, "host": host, "port": int(port)}+ if dbname:+ info["dbname"] = dbname+ return info+++def _sm_rewrite_secret(secret_id, info, resource_type, action):+ _key, secret = _sm._resolve(secret_id)+ if not secret or secret.get("DeletedDate"):+ if action == "delete":+ return None+ raise ValueError(f"{resource_type} {action} failed: "+ "Secrets Manager can't find the specified secret.")+ current = next((v.get("SecretString") for v in secret["Versions"].values()+ if "AWSCURRENT" in v.get("Stages", [])), None)+ try:+ value = json.loads(current or "{}")+ except ValueError:+ value = None+ if not isinstance(value, dict):+ if action == "delete":+ return None+ raise ValueError(f"{resource_type} {action} failed: the secret value is not a JSON object")+ value = {k: v for k, v in value.items() if k not in _SM_TARGET_KEYS}+ value.update(info)+ resp = _sm._put_secret_value({"SecretId": secret["ARN"], "SecretString": json.dumps(value)})+ if resp[0] >= 400:+ raise ValueError(f"{resource_type} {action} failed: {resp[2]!r}")+ return secret["ARN"]+++def _sm_target_attachment_create(logical_id, props, stack_name):+ info = _sm_target_connection(props.get("TargetType"), props.get("TargetId"))+ arn = _sm_rewrite_secret(props.get("SecretId"), info,+ "AWS::SecretsManager::SecretTargetAttachment", "create")+ return arn, {}+++def _sm_target_attachment_update(physical_id, old_props, new_props, stack_name):+ info = _sm_target_connection(new_props.get("TargetType"), new_props.get("TargetId"))+ arn = _sm_rewrite_secret(physical_id, info,+ "AWS::SecretsManager::SecretTargetAttachment", "update")+ return arn, {}+++def _sm_target_attachment_delete(physical_id, props):+ _sm_rewrite_secret(physical_id, {}, "AWS::SecretsManager::SecretTargetAttachment", "delete")++# ---------------------------------------------------------------------------# AutoScaling Group# ---------------------------------------------------------------------------@@ -13171,6 +13427,10 @@ _REPLACING_PROPERTIES: dict[str, tuple[str, ...]] = {),"AWS::ElastiCache::SubnetGroup": ("CacheSubnetGroupName",),"AWS::ElastiCache::ParameterGroup": ("CacheParameterGroupFamily",),+ "AWS::RDS::DBSubnetGroup": ("DBSubnetGroupName",),+ "AWS::RDS::DBParameterGroup": ("DBParameterGroupName", "Description", "Family"),+ "AWS::RDS::DBClusterParameterGroup": ("DBClusterParameterGroupName", "Description", "Family"),+ "AWS::SecretsManager::SecretTargetAttachment": ("SecretId",),"AWS::ElastiCache::CacheCluster": ("Port", "SnapshotArns", "SnapshotName", "CacheSubnetGroupName", "ClusterName","Engine", "NetworkType",@@ -13977,6 +14237,29 @@ _RESOURCE_HANDLERS = {"AWS::RDS::DBInstance": {"create": _rds_db_instance_create, "update": _rds_db_instance_update,"update_with_logical_id": True, "delete": _rds_db_instance_delete,"snapshot": _rds_db_instance_snapshot},+ "AWS::RDS::DBSubnetGroup": {+ "create": _rds_subnet_group_create,+ "update": _rds_subnet_group_update,+ "update_with_logical_id": True,+ "delete": _rds_subnet_group_delete,+ },+ "AWS::RDS::DBParameterGroup": {+ "create": _rds_param_group_create,+ "update": _rds_param_group_update,+ "update_with_logical_id": True,+ "delete": _rds_param_group_delete,+ },+ "AWS::RDS::DBClusterParameterGroup": {+ "create": _rds_cluster_param_group_create,+ "update": _rds_cluster_param_group_update,+ "update_with_logical_id": True,+ "delete": _rds_cluster_param_group_delete,+ },+ "AWS::SecretsManager::SecretTargetAttachment": {+ "create": _sm_target_attachment_create,+ "update": _sm_target_attachment_update,+ "delete": _sm_target_attachment_delete,+ },"AWS::IoT::TopicRule": {"create": _iot_topic_rule_create,"update": _iot_topic_rule_update,diff --git a/tests/test_cfn.py b/tests/test_cfn.pyindex 5ac8bbf3..bc0d91a6 100644--- a/tests/test_cfn.py+++ b/tests/test_cfn.py@@ -33553,3 +33553,124 @@ def test_cfn_apigwv2_domain_name_and_api_mapping(cfn, apigw):with pytest.raises(ClientError):apigw.get_domain_name(DomainName=domain)+++def _rds_groups_template(uid, *, params, subnet_desc="db subnets", attach=True):+ resources = {+ "Vpc": {"Type": "AWS::EC2::VPC", "Properties": {"CidrBlock": "10.42.0.0/16"}},+ "SubnetA": {"Type": "AWS::EC2::Subnet", "Properties": {+ "VpcId": {"Ref": "Vpc"}, "CidrBlock": "10.42.1.0/24", "AvailabilityZone": "us-east-1a"}},+ "SubnetB": {"Type": "AWS::EC2::Subnet", "Properties": {+ "VpcId": {"Ref": "Vpc"}, "CidrBlock": "10.42.2.0/24", "AvailabilityZone": "us-east-1b"}},+ "Subnets": {"Type": "AWS::RDS::DBSubnetGroup", "Properties": {+ "DBSubnetGroupDescription": subnet_desc,+ "SubnetIds": [{"Ref": "SubnetA"}, {"Ref": "SubnetB"}],+ "Tags": [{"Key": "team", "Value": "db"}]}},+ "Params": {"Type": "AWS::RDS::DBParameterGroup", "Properties": {+ "Description": "instance params", "Family": "mysql8.0", "Parameters": params}},+ "ClusterParams": {"Type": "AWS::RDS::DBClusterParameterGroup", "Properties": {+ "DBClusterParameterGroupName": f"cpg-{uid}", "Description": "cluster params",+ "Family": "aurora-mysql8.0", "Parameters": {"time_zone": "UTC"}}},+ "Secret": {"Type": "AWS::SecretsManager::Secret", "Properties": {+ "GenerateSecretString": {"SecretStringTemplate": '{"username":"admin"}',+ "GenerateStringKey": "password",+ "ExcludeCharacters": "\"@/\\\\"}}},+ "Db": {"Type": "AWS::RDS::DBInstance", "DeletionPolicy": "Delete", "Properties": {+ "DBInstanceIdentifier": f"cfn-groups-{uid}", "Engine": "mysql",+ "DBInstanceClass": "db.t3.micro", "AllocatedStorage": "20", "DBName": "app",+ "MasterUsername": "admin", "MasterUserPassword": "password123",+ "DBSubnetGroupName": {"Ref": "Subnets"}, "DBParameterGroupName": {"Ref": "Params"}}},+ }+ if attach:+ resources["Attach"] = {"Type": "AWS::SecretsManager::SecretTargetAttachment", "Properties": {+ "SecretId": {"Ref": "Secret"}, "TargetId": {"Ref": "Db"},+ "TargetType": "AWS::RDS::DBInstance"}}+ outputs = {+ "SubnetGroup": {"Value": {"Ref": "Subnets"}},+ "SubnetGroupArn": {"Value": {"Fn::GetAtt": ["Subnets", "DBSubnetGroupArn"]}},+ "ParamGroup": {"Value": {"Ref": "Params"}},+ "ParamGroupName": {"Value": {"Fn::GetAtt": ["Params", "DBParameterGroupName"]}},+ "ParamGroupArn": {"Value": {"Fn::GetAtt": ["Params", "DBParameterGroupArn"]}},+ "ClusterParamGroup": {"Value": {"Ref": "ClusterParams"}},+ "SecretArn": {"Value": {"Ref": "Secret"}},+ }+ if attach:+ outputs["Attachment"] = {"Value": {"Ref": "Attach"}}+ return json.dumps({"Resources": resources, "Outputs": outputs})+++def test_cfn_rds_groups_and_secret_target_attachment(cfn, rds, sm):+ """The resources rds.DatabaseInstance emits: a DBSubnetGroup, parameter+ groups and a SecretTargetAttachment that writes the connection keys."""+ uid = _uuid_mod.uuid4().hex[:8]+ stack_name = f"cfn-rds-groups-{uid}"+ cfn.create_stack(StackName=stack_name, TemplateBody=_rds_groups_template(+ uid, params={"max_connections": 100, "sql_mode": "STRICT_ALL_TABLES"}))+ try:+ stack = _wait_stack(cfn, stack_name)+ assert stack["StackStatus"] == "CREATE_COMPLETE", stack.get("StackStatusReason")+ out = {o["OutputKey"]: o["OutputValue"] for o in stack["Outputs"]}++ group = rds.describe_db_subnet_groups(DBSubnetGroupName=out["SubnetGroup"])["DBSubnetGroups"][0]+ assert group["DBSubnetGroupArn"] == out["SubnetGroupArn"]+ assert len(group["Subnets"]) == 2+ tags = rds.list_tags_for_resource(ResourceName=out["SubnetGroupArn"])["TagList"]+ assert {"Key": "team", "Value": "db"} in tags+ assert out["ParamGroup"] == out["ParamGroupName"]+ assert out["ParamGroupArn"].endswith(f":pg:{out['ParamGroup']}")+ user = {p["ParameterName"]: p["ParameterValue"] for p in rds.describe_db_parameters(+ DBParameterGroupName=out["ParamGroup"], Source="user")["Parameters"]}+ assert user == {"max_connections": "100", "sql_mode": "STRICT_ALL_TABLES"}+ assert out["ClusterParamGroup"] == f"cpg-{uid}"+ db = rds.describe_db_instances(DBInstanceIdentifier=f"cfn-groups-{uid}")["DBInstances"][0]+ assert db["DBSubnetGroup"]["DBSubnetGroupName"] == out["SubnetGroup"]++ assert out["Attachment"] == sm.describe_secret(SecretId=out["SecretArn"])["ARN"]+ value = json.loads(sm.get_secret_value(SecretId=out["SecretArn"])["SecretString"])+ assert value["username"] == "admin" and value["password"]+ assert value["engine"] == "mysql"+ assert value["host"] == db["Endpoint"]["Address"]+ assert value["port"] == db["Endpoint"]["Port"]+ assert value["dbname"] == "app"++ cfn.update_stack(StackName=stack_name, TemplateBody=_rds_groups_template(+ uid, params={"max_connections": 200}, subnet_desc="changed", attach=False))+ stack = _wait_stack(cfn, stack_name)+ assert stack["StackStatus"] == "UPDATE_COMPLETE", stack.get("StackStatusReason")+ group = rds.describe_db_subnet_groups(DBSubnetGroupName=out["SubnetGroup"])["DBSubnetGroups"][0]+ assert group["DBSubnetGroupDescription"] == "changed"+ user = {p["ParameterName"]: p["ParameterValue"] for p in rds.describe_db_parameters(+ DBParameterGroupName=out["ParamGroup"], Source="user")["Parameters"]}+ assert user == {"max_connections": "200"}+ value = json.loads(sm.get_secret_value(SecretId=out["SecretArn"])["SecretString"])+ assert set(value) == {"username", "password"}++ cfn.delete_stack(StackName=stack_name)+ assert _wait_stack(cfn, stack_name)["StackStatus"] == "DELETE_COMPLETE"+ with pytest.raises(ClientError):+ rds.describe_db_subnet_groups(DBSubnetGroupName=out["SubnetGroup"])+ with pytest.raises(ClientError):+ rds.describe_db_parameters(DBParameterGroupName=out["ParamGroup"])+ with pytest.raises(ClientError):+ rds.describe_db_cluster_parameters(DBClusterParameterGroupName=f"cpg-{uid}")+ finally:+ _delete_cfn_test_stack(cfn, stack_name)+++def test_cfn_rds_custom_named_parameter_group_cannot_be_replaced(cfn):+ """Family is Update requires: Replacement, so a custom-named group refuses it."""+ uid = _uuid_mod.uuid4().hex[:8]+ stack_name = f"cfn-rds-pg-repl-{uid}"++ def template(family):+ return json.dumps({"Resources": {"Params": {"Type": "AWS::RDS::DBParameterGroup", "Properties": {+ "DBParameterGroupName": f"pg-{uid}", "Description": "d", "Family": family}}}})++ cfn.create_stack(StackName=stack_name, TemplateBody=template("mysql8.0"))+ try:+ assert _wait_stack(cfn, stack_name)["StackStatus"] == "CREATE_COMPLETE"+ cfn.update_stack(StackName=stack_name, TemplateBody=template("mysql5.7"))+ stack = _wait_stack(cfn, stack_name)+ assert stack["StackStatus"] == "UPDATE_ROLLBACK_COMPLETE"+ finally:+ _delete_cfn_test_stack(cfn, stack_name)