Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

release v1.4.20 (#1448)

Nahuel Nucera46d21750796a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c9e3b7a8..0155cb7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ Versioning follows [Semantic Versioning](https://semver.org/).
## [Unreleased]
+## [1.4.20] — 2026-08-19
+
### Added
- **RDS — `FailoverDBCluster`** — forcing an Aurora cluster failover was `InvalidAction`. The operation now promotes a reader member to writer: an explicit `TargetDBInstanceIdentifier` must be an available reader belonging to the cluster (a non-member is `InvalidDBInstanceState`, an unknown instance `DBInstanceNotFound`); without a target the available reader with the lowest `PromotionTier` is chosen, as on AWS. The response reports the transitional `failing-over` status while a follow-up `DescribeDBClusters` sees `available` with the flipped `IsClusterWriter` flags, mirroring `FailoverGlobalCluster`. A missing cluster is `DBClusterNotFoundFault`, a non-available cluster or one with no promotable reader `InvalidDBClusterStateFault`. Metadata-only for now: cluster members share one container, so there is no reader data plane to re-point until per-instance replication (#1325) lands. Contributed by @kiran01bm.
- **RDS — opt-in Aurora PostgreSQL reader instances backed by real streaming replication** — with `MINISTACK_RDS_PG_CLUSTER_REPLICATION=1`, the second and later members of an Aurora PostgreSQL cluster launch their own PostgreSQL containers, cloned from the writer with `pg_basebackup` and running as hot standbys that stream WAL from it. A reader is genuinely read-only (`pg_is_in_recovery()` is true, writes fail with `25006`), sees data written to the writer, and the cluster `ReaderEndpoint` resolves to an available reader instead of the writer — so read/write connection routing, replica-lag handling, and reader-endpoint pooling can be rehearsed locally. Off by default: without the flag (and for Aurora MySQL) members keep aliasing the writer's single shared container. Requires the shared Docker network (`DOCKER_NETWORK`); deleting a reader removes only its own container. Not yet modeled (follow-up slices of #1325): stopping a cluster with replicating readers is rejected with `InvalidDBClusterStateFault`, and a persisted reader demotes to a shared-container alias on warm boot. Contributed by @kiran01bm.
@@ -14,6 +16,9 @@ Versioning follows [Semantic Versioning](https://semver.org/).
- **CloudFormation — API Gateway (v1) API keys and usage plans** — `AWS::ApiGateway::ApiKey`, `AWS::ApiGateway::UsagePlan`, and `AWS::ApiGateway::UsagePlanKey` failed stack creation with `Unsupported resource type`, even though the runtime `CreateApiKey` / `CreateUsagePlan` APIs were already served. The three resource types now provision through those same stores: an `ApiKey` supports a pinned `Value`, `Enabled`, and `StageKeys`, updates `Name` / `Description` / `Enabled` in place, and exposes both `Ref` and `Fn::GetAtt APIKeyId` as the key id; a `UsagePlan` maps `Throttle` / `Quota` / `ApiStages` and returns its id via `Ref` and `Fn::GetAtt Id`; a `UsagePlanKey` associates a key with a plan and is torn down from the plan on delete. This unblocks CDK `RestApi` / `ApiKey` constructs and Terraform `aws_api_gateway_api_key` deployed through CloudFormation. Contributed by @ryan-bennett.
- **AWS IoT Jobs — control plane and device data plane** — `CreateJob` fell through to `Unsupported IoT path` and the `iot-jobs-data` endpoint did not exist, so device OTA loops could not be rehearsed locally. The `iot` service now serves the nine job operations and a new `iot-jobs-data` service the four device ones (incl. the `$next` sentinel), sharing one store and the AWS execution state machine. A `documentSource` job gets a placeholder, not the S3 object. Contributed by @iot-rocket.
### Fixed
+- **S3 — server-side encryption is stated, validated, and enforced instead of silently dropped** — SSE-S3, SSE-KMS and SSE-C headers all returned 200 and were then forgotten: nothing was echoed on the PUT reply or on later reads, an object written under a customer key read back without one, and incoherent requests (a wrong key MD5, key material without the algorithm, SSE-C combined with KMS) were accepted. MiniStack still does not encrypt at rest — like the ACL plane, SSE is now contract state: validated on write, persisted with the object so HEAD/GET echo it, and enforced on reads for SSE-C (a keyless or plain-object read is a 400 `InvalidRequest`, a wrong-key read a 403 `AccessDenied`, as AWS answers). Only the key's MD5 is stored, and the state follows versions, copies and multipart completes; a bucket's default encryption now applies to the object rather than only stamping the PUT reply, and copies take the destination's SSE from the request or the destination bucket, never the source. Contributed by @gaul.
+- **DynamoDB — key attribute types are enforced on `PutItem`, `Query`, and `UpdateTable`** — a key declared `S` accepted an `N` value on `PutItem` (stored as `N`) and on a `Query` key condition (returned the row), and `UpdateTable` carrying only `AttributeDefinitions` silently changed a key's type in place — while `GetItem` / `UpdateItem` / `BatchWriteItem` / `TransactWriteItems` already rejected the mismatch. `PutItem` now returns `ValidationException` "Type mismatch for key <name> expected: S actual: N", a `Query` key-condition type mismatch returns "Condition parameter type does not match schema type", and an attribute-definitions-only `UpdateTable` is rejected ("At least one of ... is required"), so no API changes a key's type. Reported by @iot-rocket.
+- **CloudWatch — extended-statistic percentiles are computed instead of aliased to `Average`** — `GetMetricData` and alarm evaluation returned `Average` for any `pNN` extended statistic regardless of the percentile requested (`_stat_value` had a stub, and alarm evaluation read only `Statistic`, never `ExtendedStatistic`). Percentiles are now computed by linear interpolation over the period's samples on both paths, and a percentile alarm's `StateReason` reports the actual statistic (e.g. `p95`) instead of `Average`. Contributed by @MGSousa.
- **S3 — presigned SigV4 URLs verify for virtual-hosted addressing and temporary credentials** — two bugs made valid presigned `GET`/`PUT` URLs fail `403 SignatureDoesNotMatch`: a virtual-hosted (`{bucket}.host`) URL was rewritten to path-style before the signature was recomputed, so it no longer matched the bucket-less URI the client signed; and a URL signed with STS temporary credentials was always verified against the static server secret, never the unique secret STS issued. Verification now runs against the original signed URI, and STS records each issued secret so the verifier resolves the one a credential actually signed with (long-term keys still fall back to `AWS_SECRET_ACCESS_KEY`). Tampered and wrong-secret URLs are still rejected. Reported by @mayankgupta57.
- **Step Functions — `arn:aws:states:::events:putEvents` actually publishes the event** — the optimized EventBridge integration fell through to the task passthrough, so the state reported `SUCCEEDED` while nothing reached any rule target. It now calls EventBridge `PutEvents` and returns its response (`Entries` / `FailedEntryCount`). Reported by @iwasakar.
- **Aurora DSQL — `SELECT ... FOR UPDATE` is no longer refused for its predicate** — strict mode enforced a rule Aurora DSQL does not (any more): a locking read had to be a single table with an equality on every primary key column, or it was rejected with `0A000` "locking clause such as FOR UPDATE can be applied only on tables with equality predicates on the key". The check compared the WHERE clause's column against the key name as raw SQL text, so `WHERE "id" = $1` did not match key column `id` — and every mainstream ORM (Drizzle, Prisma, TypeORM, SQLAlchemy) quotes its identifiers, so in practice every locking read from an ORM failed, with a message that blamed the user's schema. Measured against a live cluster (eu-central-1, 2026-08-18, `server_version` 16.15), DSQL restricts the lock *strength*, not the predicate: `FOR UPDATE` locks whatever the query selects — no `WHERE` clause, a non-key column, an inequality, `IN`/`OR`, a join, or a table with no primary key all succeed, as do `NOWAIT`, `SKIP LOCKED` and `OF` — while `FOR NO KEY UPDATE`, `FOR SHARE` and `FOR KEY SHARE` are refused with `0A000` "locking clauses other than FOR UPDATE/FOR KEY SHARE are not supported", inside a CTE or subquery included. The predicate rule is gone and the lock-strength rule takes its place, so the emulator stops failing correct code and starts failing the code DSQL actually fails. The new rule is token-based (`FOR SHARE` inside a string literal is text, not a clause) and needs no catalog probe, so a locking read no longer costs a round-trip before it is forwarded.
diff --git a/ministack/services/cloudwatch.py b/ministack/services/cloudwatch.py
index 1b5be623..146eeab5 100644
--- a/ministack/services/cloudwatch.py
+++ b/ministack/services/cloudwatch.py
@@ -299,7 +299,7 @@ def _evaluate_alarm(alarm):
old_state = alarm["StateValue"]
new_state = "ALARM" if breaching else "OK"
if old_state != new_state:
- reason = f"Threshold Crossed: {alarm.get('Statistic','Average')} {val} {op} {threshold}"
+ reason = f"Threshold Crossed: {stat_name} {val} {op} {threshold}"
alarm["StateValue"] = new_state
alarm["StateReason"] = reason
alarm["StateUpdatedTimestamp"] = int(time.time())
diff --git a/pyproject.toml b/pyproject.toml
index 94c66341..d53e33eb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "ministack"
-version = "1.4.19"
+version = "1.4.20"
description = "Free, open-source local AWS emulator — drop-in LocalStack replacement"
readme = "README.md"
license = { file = "LICENSE" }
diff --git a/tests/test_cloudwatch.py b/tests/test_cloudwatch.py
index 5c82a330..86e3bf08 100644
--- a/tests/test_cloudwatch.py
+++ b/tests/test_cloudwatch.py
@@ -838,3 +838,32 @@ def test_cloudwatch_get_metric_data_cbor_timestamps_are_tag1():
_cw._metrics.pop_scoped("000000000000", "us-east-1", key, None)
_resp._request_region.reset(region_tok)
_resp._request_account_id.reset(acct_tok)
+
+
+def test_cloudwatch_percentile_alarm_reason_reports_statistic(cw):
+ """A percentile alarm's StateReason must name the actual extended statistic
+ (e.g. p90), not fall back to Average. Regression for the label that stayed
+ 'Average' after the percentile value itself was fixed."""
+ ns = "Test/PctAlarmReason"
+ now = time.time()
+ for i, v in enumerate([1, 2, 3, 4, 90, 95, 98, 99]):
+ cw.put_metric_data(Namespace=ns, MetricData=[{
+ "MetricName": "Latency",
+ "Timestamp": now - i,
+ "Value": float(v),
+ }])
+ # p90 of the set is 98.3; threshold 50 -> breaches -> ALARM.
+ cw.put_metric_alarm(
+ AlarmName="pct-reason",
+ MetricName="Latency",
+ Namespace=ns,
+ ExtendedStatistic="p90",
+ Period=3600,
+ EvaluationPeriods=1,
+ Threshold=50.0,
+ ComparisonOperator="GreaterThanThreshold",
+ )
+ alarm = cw.describe_alarms(AlarmNames=["pct-reason"])["MetricAlarms"][0]
+ assert alarm["StateValue"] == "ALARM"
+ assert "p90" in alarm["StateReason"]
+ assert "Average" not in alarm["StateReason"]