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): validate aurora-postgresql engine versions at create time (#1299)
kiran01bm742f21133ab1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 91f034b5..9f0987e0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).## [Unreleased]### Fixed+- **RDS — Aurora PostgreSQL engine versions are validated at create time** — `CreateDBCluster` / `CreateDBInstance` accepted any `EngineVersion` string for `aurora-postgresql`: because the Docker image is derived from the major alone, a bogus minor like `16.99` silently ran PostgreSQL 16 while claiming to be `16.99`, and only an unknown major produced a visible image-pull failure. An unknown version — anything `DescribeDBEngineVersions` doesn't advertise and that isn't a dot-boundary prefix of an advertised version (bare majors like `16` stay accepted, since real AWS resolves them server-side) — now fails immediately with `InvalidParameterCombination` / `Cannot find version {version} for aurora-postgresql`, matching real AWS and the existing aurora-mysql behavior; `DescribeOrderableDBInstanceOptions` rejects unknown versions the same way instead of echoing a fabricated option. The advertised catalog is refreshed to the full creatable set real AWS returns (41 versions, 11.9 through 18.4, including `-limitless` variants, as of 2026-08-06) and is a single shared constant used by both the catalog and the validator; the default `aurora-postgresql` version is now `17.7` (AWS's current default) and the CloudFormation `AWS::RDS::DBCluster` provisioner uses that shared default instead of a hard-coded `15.4`. Contributed by @kiran01bm.- **RDS — duplicate DB instance wire code matches AWS** — a duplicate `CreateDBInstance`, `CreateDBInstanceReadReplica`, or `RestoreDBInstanceFromDBSnapshot` target returned wire code `DBInstanceAlreadyExistsFault`, but real AWS omits the `Fault` suffix for instance-level error codes (cluster-level codes such as `DBClusterAlreadyExistsFault` keep it). SDKs match the exact string to produce their typed error — aws-sdk-go-v2, for example, deserialized the response as a generic API error instead of the typed `DBInstanceAlreadyExistsFault`. The wire code is now `DBInstanceAlreadyExists`. This deliberately reverts the v1.1.18 change, which mistook the SDK exception *shape name* for the *wire code* — the model's `error.code` field (`DBInstanceAlreadyExists`) is what SDKs match, and exact-string tests now pin the correct direction. Contributed by @kiran01bm.### Added- **CodeBuild - builds can really run (`MINISTACK_CODEBUILD_EXECUTE=1`)** - `StartBuild` returned a build that was already `SUCCEEDED`, so a pipeline rehearsed against MiniStack reported a pass without a single phase having run, and a buildspec that fails on AWS still looked green locally. With the flag set, `StartBuild` returns `IN_PROGRESS` and the project's inline buildspec is handed to the official AWS CodeBuild local agent (`public.ecr.aws/codebuild/local-builds`), which runs the phases in the project's `environment.image` the way CodeBuild does - the phase semantics come from AWS's own agent instead of a reimplemented executor. `BatchGetBuilds` reflects progress while the build runs: the agent's `Phase complete: <PHASE> State: <STATUS>` lines become `phases` entries, and the container's exit status maps to `SUCCEEDED` / `FAILED`, with `FAULT` when Docker is unreachable. `environment.environmentVariables`, `privilegedMode`, and the `CODEBUILD_BUILD_ID` / `_ARN` / `_NUMBER` / `_INITIATOR` variables reach the build. The build reaches back into MiniStack: `AWS_ENDPOINT_URL` (plus placeholder credentials) is injected unless the project declares its own, so `aws s3 cp` inside a build hits this emulator rather than real AWS. `timeoutInMinutes` is enforced (the build is stopped and its phase reported `TIMED_OUT`), and a restored build that was in flight when MiniStack stopped is reported `FAULT` rather than polling as running forever. `StopBuild` is honoured deterministically: it records the intent before removing the container, so the worker reports the requested `STOPPED` instead of racing it to `FAULT`. Build output also reaches CloudWatch Logs: the record already advertised `logs.groupName` / `logs.streamName`, and an executed build now writes the agent output there, so `aws logs get-log-events` and `aws logs tail` read back a real build log instead of an empty stream. Default behaviour is unchanged - without the flag builds stay metadata-only. Requires the Docker socket; the agent image and workspace path are fixed internals, not configurable.diff --git a/ministack/services/cloudformation/provisioners.py b/ministack/services/cloudformation/provisioners.pyindex 553a9660..7fb79bda 100644--- a/ministack/services/cloudformation/provisioners.py+++ b/ministack/services/cloudformation/provisioners.py@@ -4779,7 +4779,7 @@ def _cf_kvs_delete(physical_id, props):def _rds_db_cluster_create(logical_id, props, stack_name):cluster_id = props.get("DBClusterIdentifier") or _physical_name(stack_name, logical_id, lowercase=True, max_len=63)engine = props.get("Engine", "aurora-postgresql")- engine_version = props.get("EngineVersion", "15.4")+ engine_version = props.get("EngineVersion") or _rds._default_engine_version(engine)master_user = props.get("MasterUsername", "admin")arn = f"arn:aws:rds:{get_region()}:{get_account_id()}:cluster:{cluster_id}"suffix = new_uuid()[:8]diff --git a/ministack/services/rds.py b/ministack/services/rds.pyindex 56bcf35f..8476040e 100644--- a/ministack/services/rds.py+++ b/ministack/services/rds.py@@ -142,6 +142,63 @@ AURORA_MYSQL_ENGINE_VERSIONS = []AURORA_MYSQL_ENGINE_VERSION_SET = {version for version, _ in AURORA_MYSQL_ENGINE_VERSIONS}+# Aurora PostgreSQL versions are the creatable set returned by AWS RDS as of+# 2026-08-06 (single source of truth for both the catalog and create-time+# validation). Refresh with:+# aws rds describe-db-engine-versions --engine aurora-postgresql \+# --query 'DBEngineVersions[].[EngineVersion,DBParameterGroupFamily]' \+# --output text | sort -V+# The Docker image is derived from the major alone (16.14 -> postgres:16-alpine),+# so new minors need no image work — but keep _default_engine_version aligned:+# AWS's default (describe-db-engine-versions --default-only) can trail the+# latest advertised version, so update it deliberately when refreshing.+AURORA_POSTGRESQL_ENGINE_VERSIONS = [+ ("11.9", "aurora-postgresql11"),+ ("11.21", "aurora-postgresql11"),+ ("12.9", "aurora-postgresql12"),+ ("12.22", "aurora-postgresql12"),+ ("13.9", "aurora-postgresql13"),+ ("13.23", "aurora-postgresql13"),+ ("14.6", "aurora-postgresql14"),+ ("14.17", "aurora-postgresql14"),+ ("14.18", "aurora-postgresql14"),+ ("14.19", "aurora-postgresql14"),+ ("14.20", "aurora-postgresql14"),+ ("14.22", "aurora-postgresql14"),+ ("14.23", "aurora-postgresql14"),+ ("15.10", "aurora-postgresql15"),+ ("15.12", "aurora-postgresql15"),+ ("15.13", "aurora-postgresql15"),+ ("15.14", "aurora-postgresql15"),+ ("15.15", "aurora-postgresql15"),+ ("15.17", "aurora-postgresql15"),+ ("15.18", "aurora-postgresql15"),+ ("16.4-limitless", "aurora-postgresql16"),+ ("16.6-limitless", "aurora-postgresql16"),+ ("16.8", "aurora-postgresql16"),+ ("16.8-limitless", "aurora-postgresql16"),+ ("16.9", "aurora-postgresql16"),+ ("16.9-limitless", "aurora-postgresql16"),+ ("16.10", "aurora-postgresql16"),+ ("16.10-limitless", "aurora-postgresql16"),+ ("16.11", "aurora-postgresql16"),+ ("16.11-limitless", "aurora-postgresql16"),+ ("16.13", "aurora-postgresql16"),+ ("16.13-limitless", "aurora-postgresql16"),+ ("16.14", "aurora-postgresql16"),+ ("17.4", "aurora-postgresql17"),+ ("17.5", "aurora-postgresql17"),+ ("17.6", "aurora-postgresql17"),+ ("17.7", "aurora-postgresql17"),+ ("17.9", "aurora-postgresql17"),+ ("17.10", "aurora-postgresql17"),+ ("18.3", "aurora-postgresql18"),+ ("18.4", "aurora-postgresql18"),+]+AURORA_POSTGRESQL_ENGINE_VERSION_SET = {+ version for version, _ in AURORA_POSTGRESQL_ENGINE_VERSIONS+}+AURORA_MYSQL_IMAGE_MAP = {"5.6": "mysql:5.6","5.7": "mysql:5.7",@@ -2380,7 +2437,7 @@ def _create_db_instance(p):engine = _p(p, "Engine") or "postgres"explicit_engine_version = _p(p, "EngineVersion")- engine_version_error = _unsupported_aurora_mysql_engine_version_error(engine, explicit_engine_version)+ engine_version_error = _unsupported_aurora_engine_version_error(engine, explicit_engine_version)if engine_version_error:return engine_version_errorengine_version = explicit_engine_version or _default_engine_version(engine)@@ -3225,7 +3282,8 @@ def _restore_from_snapshot(p):"DBInstanceIdentifier": db_id,"DBInstanceClass": _p(p, "DBInstanceClass") or snap.get("DBInstanceClass", "db.t3.micro"),"Engine": snap.get("Engine", "postgres"),- "EngineVersion": snap.get("EngineVersion", "15.3"),+ "EngineVersion": snap.get("EngineVersion")+ or _default_engine_version(snap.get("Engine", "postgres")),"DBInstanceStatus": "available","MasterUsername": snap.get("MasterUsername", "admin"),"DBName": snap.get("DBName", ""),@@ -3322,7 +3380,7 @@ def _create_db_cluster(p):)engine = expected_engine or engineexplicit_engine_version = _p(p, "EngineVersion")- engine_version_error = _unsupported_aurora_mysql_engine_version_error(engine, explicit_engine_version)+ engine_version_error = _unsupported_aurora_engine_version_error(engine, explicit_engine_version)if engine_version_error:return engine_version_errorengine_version = explicit_engine_version or _default_engine_version(engine)@@ -4938,11 +4996,7 @@ def _describe_engine_versions(p):"mariadb": [("10.6.14", "10.6"), ("10.5.21", "10.5"),],- "aurora-postgresql": [- ("18.3", "aurora-postgresql18"), ("17.5", "aurora-postgresql17"),- ("16.4", "aurora-postgresql16"),- ("15.3", "aurora-postgresql15"), ("14.8", "aurora-postgresql14"),- ],+ "aurora-postgresql": AURORA_POSTGRESQL_ENGINE_VERSIONS,"aurora-mysql": AURORA_MYSQL_ENGINE_VERSIONS,}versions = versions_map.get(engine, [("15.3", "15")])@@ -4976,7 +5030,7 @@ def _describe_orderable_options(p):engine = _p(p, "Engine") or "postgres"engine_version = _p(p, "EngineVersion")db_class = _p(p, "DBInstanceClass")- engine_version_error = _unsupported_aurora_mysql_engine_version_error(engine, engine_version)+ engine_version_error = _unsupported_aurora_engine_version_error(engine, engine_version)if engine_version_error:return engine_version_error@@ -5548,23 +5602,30 @@ def _format_time(ts):def _default_engine_version(engine):defaults = {"postgres": "15.3", "mysql": "8.0.33", "mariadb": "10.6.14",- "aurora-postgresql": "15.3", "aurora-mysql": "8.0.mysql_aurora.3.10.3",+ "aurora-postgresql": "17.7", "aurora-mysql": "8.0.mysql_aurora.3.10.3",}return defaults.get(engine, "15.3")-def _unsupported_aurora_mysql_engine_version_error(engine, engine_version):- if (- engine == "aurora-mysql"- and engine_version- and engine_version not in AURORA_MYSQL_ENGINE_VERSION_SET- ):- return _error(- "InvalidParameterCombination",- f"Cannot find version {engine_version} for aurora-mysql",- 400,- )- return None+def _unsupported_aurora_engine_version_error(engine, engine_version):+ supported = {+ "aurora-mysql": AURORA_MYSQL_ENGINE_VERSION_SET,+ "aurora-postgresql": AURORA_POSTGRESQL_ENGINE_VERSION_SET,+ }.get(engine)+ if supported is None or not engine_version or engine_version in supported:+ return None+ # Real AWS also accepts a dot-boundary prefix of a creatable version and+ # resolves it to a concrete minor server-side: aurora-postgresql "16" and+ # aurora-mysql "8.0" (or "8.0.mysql_aurora.3.04") are all valid inputs.+ # Ministack stores the prefix as given; the Docker image is derived from+ # the major, so the running database matches what the prefix requested.+ if any(version.startswith(engine_version + ".") for version in supported):+ return None+ return _error(+ "InvalidParameterCombination",+ f"Cannot find version {engine_version} for {engine}",+ 400,+ )def _mysql_community_major_minor(engine_version):diff --git a/tests/test_rds.py b/tests/test_rds.pyindex 4c99300d..da5b0c0b 100644--- a/tests/test_rds.py+++ b/tests/test_rds.py@@ -19,6 +19,51 @@ from conftest import ENDPOINTDEFAULT_AURORA_MYSQL_ENGINE_VERSION = "8.0.mysql_aurora.3.10.3"UNSUPPORTED_AURORA_MYSQL_ENGINE_VERSION = "9.0.mysql_aurora.9.0.1"+DEFAULT_AURORA_POSTGRESQL_ENGINE_VERSION = "17.7"+UNSUPPORTED_AURORA_POSTGRESQL_ENGINE_VERSION = "16.99"+EXPECTED_AURORA_POSTGRESQL_ENGINE_VERSIONS = {+ "11.9": "aurora-postgresql11",+ "11.21": "aurora-postgresql11",+ "12.9": "aurora-postgresql12",+ "12.22": "aurora-postgresql12",+ "13.9": "aurora-postgresql13",+ "13.23": "aurora-postgresql13",+ "14.6": "aurora-postgresql14",+ "14.17": "aurora-postgresql14",+ "14.18": "aurora-postgresql14",+ "14.19": "aurora-postgresql14",+ "14.20": "aurora-postgresql14",+ "14.22": "aurora-postgresql14",+ "14.23": "aurora-postgresql14",+ "15.10": "aurora-postgresql15",+ "15.12": "aurora-postgresql15",+ "15.13": "aurora-postgresql15",+ "15.14": "aurora-postgresql15",+ "15.15": "aurora-postgresql15",+ "15.17": "aurora-postgresql15",+ "15.18": "aurora-postgresql15",+ "16.4-limitless": "aurora-postgresql16",+ "16.6-limitless": "aurora-postgresql16",+ "16.8": "aurora-postgresql16",+ "16.8-limitless": "aurora-postgresql16",+ "16.9": "aurora-postgresql16",+ "16.9-limitless": "aurora-postgresql16",+ "16.10": "aurora-postgresql16",+ "16.10-limitless": "aurora-postgresql16",+ "16.11": "aurora-postgresql16",+ "16.11-limitless": "aurora-postgresql16",+ "16.13": "aurora-postgresql16",+ "16.13-limitless": "aurora-postgresql16",+ "16.14": "aurora-postgresql16",+ "17.4": "aurora-postgresql17",+ "17.5": "aurora-postgresql17",+ "17.6": "aurora-postgresql17",+ "17.7": "aurora-postgresql17",+ "17.9": "aurora-postgresql17",+ "17.10": "aurora-postgresql17",+ "18.3": "aurora-postgresql18",+ "18.4": "aurora-postgresql18",+}EXPECTED_AURORA_MYSQL_ENGINE_VERSIONS = {"5.7.mysql_aurora.2.11.1": "aurora-mysql5.7","5.7.mysql_aurora.2.11.2": "aurora-mysql5.7",@@ -1079,6 +1124,22 @@ def test_rds_describe_aurora_mysql_engine_versions_by_family(rds):assert filtered == []+def test_rds_describe_aurora_postgresql_engine_versions_by_family(rds):+ resp = rds.describe_db_engine_versions(Engine="aurora-postgresql")+ families = {+ v["EngineVersion"]: v["DBParameterGroupFamily"]+ for v in resp["DBEngineVersions"]+ }+ assert families == EXPECTED_AURORA_POSTGRESQL_ENGINE_VERSIONS+ assert DEFAULT_AURORA_POSTGRESQL_ENGINE_VERSION in families++ filtered = rds.describe_db_engine_versions(+ Engine="aurora-postgresql",+ EngineVersion=UNSUPPORTED_AURORA_POSTGRESQL_ENGINE_VERSION,+ )["DBEngineVersions"]+ assert filtered == []++def test_rds_aurora_mysql_create_rejects_unsupported_explicit_engine_version(rds):with pytest.raises(ClientError) as cluster_exc:rds.create_db_cluster(@@ -1131,6 +1192,93 @@ def test_rds_aurora_mysql_create_accepts_cataloged_84_engine_version(rds):)+def test_rds_aurora_postgresql_create_rejects_unsupported_explicit_engine_version(rds):+ with pytest.raises(ClientError) as cluster_exc:+ rds.create_db_cluster(+ DBClusterIdentifier="unsupported-apg-version-cluster",+ Engine="aurora-postgresql",+ EngineVersion=UNSUPPORTED_AURORA_POSTGRESQL_ENGINE_VERSION,+ MasterUsername="admin",+ MasterUserPassword="password123",+ )+ assert cluster_exc.value.response["Error"]["Code"] == "InvalidParameterCombination"+ assert (+ cluster_exc.value.response["Error"]["Message"]+ == f"Cannot find version {UNSUPPORTED_AURORA_POSTGRESQL_ENGINE_VERSION} for aurora-postgresql"+ )++ with pytest.raises(ClientError) as instance_exc:+ rds.create_db_instance(+ DBInstanceIdentifier="unsupported-apg-version-instance",+ DBInstanceClass="db.t3.micro",+ Engine="aurora-postgresql",+ EngineVersion=UNSUPPORTED_AURORA_POSTGRESQL_ENGINE_VERSION,+ MasterUsername="admin",+ MasterUserPassword="password123",+ AllocatedStorage=20,+ )+ assert instance_exc.value.response["Error"]["Code"] == "InvalidParameterCombination"+ assert (+ instance_exc.value.response["Error"]["Message"]+ == f"Cannot find version {UNSUPPORTED_AURORA_POSTGRESQL_ENGINE_VERSION} for aurora-postgresql"+ )+++def test_rds_aurora_postgresql_orderable_options_reject_unsupported_engine_version(rds):+ with pytest.raises(ClientError) as exc:+ rds.describe_orderable_db_instance_options(+ Engine="aurora-postgresql",+ EngineVersion=UNSUPPORTED_AURORA_POSTGRESQL_ENGINE_VERSION,+ )+ assert exc.value.response["Error"]["Code"] == "InvalidParameterCombination"+ assert (+ exc.value.response["Error"]["Message"]+ == f"Cannot find version {UNSUPPORTED_AURORA_POSTGRESQL_ENGINE_VERSION} for aurora-postgresql"+ )+++def test_rds_aurora_postgresql_create_accepts_cataloged_engine_version(rds):+ rds.create_db_cluster(+ DBClusterIdentifier="supported-apg-168-cluster",+ Engine="aurora-postgresql",+ EngineVersion="16.8",+ MasterUsername="admin",+ MasterUserPassword="password123",+ )+ try:+ cluster = rds.describe_db_clusters(+ DBClusterIdentifier="supported-apg-168-cluster"+ )["DBClusters"][0]+ assert cluster["EngineVersion"] == "16.8"+ finally:+ rds.delete_db_cluster(+ DBClusterIdentifier="supported-apg-168-cluster",+ SkipFinalSnapshot=True,+ )+++def test_rds_aurora_postgresql_create_accepts_bare_major_engine_version(rds):+ """Real AWS accepts a bare major (e.g. "16") and resolves it server-side;+ ministack accepts any dot-boundary prefix of a cataloged version."""+ rds.create_db_cluster(+ DBClusterIdentifier="supported-apg-major-cluster",+ Engine="aurora-postgresql",+ EngineVersion="16",+ MasterUsername="admin",+ MasterUserPassword="password123",+ )+ try:+ cluster = rds.describe_db_clusters(+ DBClusterIdentifier="supported-apg-major-cluster"+ )["DBClusters"][0]+ assert cluster["EngineVersion"] == "16"+ finally:+ rds.delete_db_cluster(+ DBClusterIdentifier="supported-apg-major-cluster",+ SkipFinalSnapshot=True,+ )++def test_rds_aurora_mysql_parameter_defaults_are_family_aware(rds):rds.create_db_parameter_group(DBParameterGroupName="test-mysql80-defaults",@@ -5258,7 +5406,7 @@ def test_create_db_cluster_validates_global_cluster_identifier_and_engine():east.create_db_cluster(DBClusterIdentifier=f"{cluster_id}-version",Engine="aurora-postgresql",- EngineVersion="14.8",+ EngineVersion="14.20",GlobalClusterIdentifier=global_id,MasterUsername="admin",MasterUserPassword="password123",