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
release v1.4.11 (#1268)
Nahuel Nuceradfc101193bf2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dc32e151..d7cb5c64 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,10 +5,16 @@ All notable changes to MiniStack will be documented here.Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).Versioning follows [Semantic Versioning](https://semver.org/).-## [Unreleased]+## [1.4.11] — 2026-08-04### Added- **Lambda — Function URL data plane** — `CreateFunctionUrlConfig` returned a `{urlId}.lambda-url.{region}.on.aws` URL that nothing served: a request addressed to it matched no route, fell through to S3 virtual-host addressing, and came back as `NoSuchBucket`. Function URLs are now invocable. A request reaching the gateway on a `{urlId}.lambda-url.{region}.*` host — or on the path-based `/_aws/lambda-url/{urlId}/...` form, for clients that can't set `Host` and browsers that won't resolve `*.localhost` — resolves the URL id to its function and invokes it with a payload-format-2.0 event carrying `$default` for `routeKey` and `stage`, `rawPath`/`rawQueryString` percent-encoded as AWS sends them, and `body`/`queryStringParameters` omitted rather than null. `AuthType` is enforced (`AWS_IAM` returns `403 Forbidden` to an unsigned request, header-signed and presigned both pass; `NONE` is open), the `Cors` config drives preflight and response headers with a non-allowed origin getting none, and `InvokeMode: RESPONSE_STREAM` responses are unwrapped from the `HttpResponseStream` framing so the prelude supplies the status and headers instead of leaking into the body. Cookies returned via the format-2.0 `cookies` array become `Set-Cookie` headers. Contributed by @liammizrahi.+- **API Gateway v1 — state is now account- and region-scoped** — REST APIs, resources, methods, integrations, deployments, stages, models, API keys, and usage plans were stored globally and leaked across account and region boundaries. They now scope by account and region; execute-api dispatch resolves a REST API's owning region by id (the mock execute-api host carries no region segment) and runs the invocation in that scope, and a caller-supplied `ms-custom-id` stays unique across the account's regions. Persisted state carries the on-disk format v3 an older binary refuses rather than misreads; legacy snapshots restore into each API's region and v1 tags remain account-scoped. Contributed by @Areson.+- **CloudWatch Logs — Insights queries are now account- and region-scoped** — Logs Insights query ids were account-scoped, so a `StartQuery` in one region could be read or stopped from another, contrary to the regional Logs Insights API. They now scope by account and region; persisted state carries the on-disk format v3 an older binary refuses, and legacy queries restore into their referenced log group's region. Contributed by @Areson.++### Fixed+- **Step Functions — `aws-sdk:ec2` tasks now return the SDK output shape** — the EC2 Query-XML adapter passed a near-wire structure through without reshaping or typing, so `describeVolumes` returned `VolumeSet.Item.Status` where AWS returns `Volumes[0].State`, scalars were strings, empty collections were `""` instead of `[]`, and a `requestId` the SDK never returns was included — an ASL `Choice` written against AWS silently took the wrong branch locally. The normalizer now follows the SDK output shape: PascalCase member names, `*Set` wrappers pluralized and unwrapped, and list/int/bool leaves coerced, with overrides for names that cannot be inferred (e.g. `keySet` -> `KeyPairs`). Contributed by @bandle.+- **CloudWatch — `DescribeAlarms` and metric reads over CBOR still broke the Terraform AWS provider ≥ 6.50** — after 1.4.10 fixed the alarm timestamp encoding, absent optional fields (`ExtendedStatistic`, `Unit`) were still serialized as CBOR Nil, which the provider's typed smithy-rpc-v2-cbor decoder rejected with `unexpected value type *cbor.Nil`; separately, `GetMetricStatistics` and `GetMetricData` returned their `Timestamp` / `Timestamps` members as strings rather than CBOR tag 1. Absent optional fields are now omitted from every CloudWatch CBOR response (real AWS never sends null), and metric-data timestamps are tag-1 encoded. Reported by @sdreger.## [1.4.10] — 2026-08-03diff --git a/README.md b/README.mdindex ebeae9cc..c3461487 100644--- a/README.md+++ b/README.md@@ -215,7 +215,7 @@ use1.list_tables()["TableNames"] # → ["users"]euw1.list_tables()["TableNames"] # → [] — eu-west-1 is independent```-**Region-isolated services:** AppConfig, Bedrock (all four services), CloudWatch, CloudWatch Logs, DynamoDB (tables, metadata, Streams), Lambda (functions, event source mappings, durable executions), MSK, RDS, S3 Tables, Secrets Manager, SQS, SSM Parameter Store, and Step Functions (1.4.0); EventBridge Pipes (1.4.1); SNS, Kinesis, KMS, and ElastiCache (1.4.2); EventBridge, ECS, and Firehose (1.4.3); EventBridge Scheduler, CodeBuild, and Resource Groups (1.4.4); Batch and SES (1.4.5); Athena, Auto Scaling, Cloud Map, EFS, EMR, Inspector2, Amazon MQ, AppSync, and S3 Files (1.4.6); Amazon Bedrock AgentCore, Amazon MWAA, Amazon EKS, and AWS Transfer Family (1.4.7); AWS IoT and AppSync Events (1.4.8); EC2, CloudTrail, ECR, Glue, OpenSearch, WAFv2, Backup, ACM, Elastic Load Balancing (ALB/NLB), MediaConnect, and RDS Data (1.4.9); Cognito and CloudFormation (1.4.10).+**Region-isolated services:** AppConfig, Bedrock (all four services), CloudWatch, CloudWatch Logs, DynamoDB (tables, metadata, Streams), Lambda (functions, event source mappings, durable executions), MSK, RDS, S3 Tables, Secrets Manager, SQS, SSM Parameter Store, and Step Functions (1.4.0); EventBridge Pipes (1.4.1); SNS, Kinesis, KMS, and ElastiCache (1.4.2); EventBridge, ECS, and Firehose (1.4.3); EventBridge Scheduler, CodeBuild, and Resource Groups (1.4.4); Batch and SES (1.4.5); Athena, Auto Scaling, Cloud Map, EFS, EMR, Inspector2, Amazon MQ, AppSync, and S3 Files (1.4.6); Amazon Bedrock AgentCore, Amazon MWAA, Amazon EKS, and AWS Transfer Family (1.4.7); AWS IoT and AppSync Events (1.4.8); EC2, CloudTrail, ECR, Glue, OpenSearch, WAFv2, Backup, ACM, Elastic Load Balancing (ALB/NLB), MediaConnect, and RDS Data (1.4.9); Cognito and CloudFormation (1.4.10); API Gateway v1 (1.4.11).Cross-resource references resolve in the referenced ARN's own account and region (SNS→SQS fanout, EventBridge targets, event source mappings), and cross-region references that real AWS rejects return the same errors AWS returns — e.g. invoking a `eu-west-1` Lambda from a `us-east-1` Step Functions task fails with `Functions from 'eu-west-1' are not reachable in this region`, exactly as on AWS.diff --git a/ministack/services/cloudfront.py b/ministack/services/cloudfront.pyindex 0281bb03..f2f5164d 100644--- a/ministack/services/cloudfront.py+++ b/ministack/services/cloudfront.py@@ -15,6 +15,14 @@ Supports:ListFunctions, PublishFunction, UpdateFunctionKeyValueStore: CreateKeyValueStore, DescribeKeyValueStore, ListKeyValueStores,UpdateKeyValueStore, DeleteKeyValueStore+ Cache policies: CreateCachePolicy, GetCachePolicy, GetCachePolicyConfig,+ UpdateCachePolicy, DeleteCachePolicy, ListDistributionsByCachePolicyId+ Origin request policies: CreateOriginRequestPolicy, GetOriginRequestPolicy,+ GetOriginRequestPolicyConfig, UpdateOriginRequestPolicy,+ DeleteOriginRequestPolicy, ListDistributionsByOriginRequestPolicyId+ Response headers policies: CreateResponseHeadersPolicy, GetResponseHeadersPolicy,+ GetResponseHeadersPolicyConfig, UpdateResponseHeadersPolicy,+ DeleteResponseHeadersPolicy, ListDistributionsByResponseHeadersPolicyIdTags: TagResource, UntagResource, ListTagsForResource"""diff --git a/ministack/services/cloudwatch.py b/ministack/services/cloudwatch.pyindex 852c4f5c..42398ee6 100644--- a/ministack/services/cloudwatch.py+++ b/ministack/services/cloudwatch.py@@ -672,7 +672,7 @@ def _get_metric_statistics(params, cbor_data, is_cbor, is_json=False):datapoints.append(dp)if is_cbor:- return _cbor_ok({"Datapoints": datapoints, "Label": metric_name})+ return _cbor_ok({"Datapoints": [_cbor_datapoint(dp) for dp in datapoints], "Label": metric_name})if is_json:return _json_ok({"Datapoints": datapoints, "Label": metric_name})@@ -810,7 +810,7 @@ def _get_metric_data(params, cbor_data, is_cbor, is_json=False):)if is_cbor:- return _cbor_ok({"MetricDataResults": results})+ return _cbor_ok({"MetricDataResults": [_cbor_metric_data_result(r) for r in results]})if is_json:return _json_ok({"MetricDataResults": results})@@ -1586,11 +1586,53 @@ def _cbor_history_item(item):return out+def _cbor_datapoint(dp):+ """Return a CBOR-safe copy of a GetMetricStatistics datapoint.++ ``Datapoint.Timestamp`` is a smithy ``timestamp`` member, so over+ rpc-v2-cbor it must be tag 1 (not the ISO string used by the XML path),+ same class as the alarm timestamps in issue #1261.+ """+ out = dict(dp)+ if out.get("Timestamp") is not None:+ out["Timestamp"] = _cbor_timestamp(out["Timestamp"])+ return out+++def _cbor_metric_data_result(result):+ """Return a CBOR-safe copy of a GetMetricData result.++ ``MetricDataResult.Timestamps`` is a list of smithy ``timestamp`` members,+ so each element must be tag-1 encoded over rpc-v2-cbor.+ """+ out = dict(result)+ if result.get("Timestamps"):+ out["Timestamps"] = [_cbor_timestamp(t) for t in result["Timestamps"]]+ return out+++def _cbor_strip_none(value):+ """Recursively drop dict entries whose value is None.++ smithy-rpc-v2-cbor decoders (Terraform AWS provider >= 6.50) reject a CBOR+ Nil for a typed member with ``unexpected value type *cbor.Nil`` (issue+ #1261): real AWS omits absent optional fields from the response rather than+ encoding them as null, so a None must never reach cbor2.dumps(). Non-None+ values — CBORTag timestamps, ints, empty strings, and empty lists — are+ preserved unchanged.+ """+ if isinstance(value, dict):+ return {k: _cbor_strip_none(v) for k, v in value.items() if v is not None}+ if isinstance(value, list):+ return [_cbor_strip_none(v) for v in value]+ return value++def _cbor_ok(data: dict):try:import cbor2- body = cbor2.dumps(data)+ body = cbor2.dumps(_cbor_strip_none(data))except Exception:body = json.dumps(data).encode()return (diff --git a/ministack/services/eks.py b/ministack/services/eks.pyindex 02307fa6..f8728256 100644--- a/ministack/services/eks.py+++ b/ministack/services/eks.py@@ -8,6 +8,8 @@ API server. DeleteCluster stops and removes it.Supports:Clusters: CreateCluster, DescribeCluster, ListClusters, DeleteClusterNodegroups: CreateNodegroup, DescribeNodegroup, ListNodegroups, DeleteNodegroup+ IdP configs: AssociateIdentityProviderConfig, DescribeIdentityProviderConfig,+ DisassociateIdentityProviderConfig, ListIdentityProviderConfigsTags: TagResource, UntagResource, ListTagsForResource"""diff --git a/pyproject.toml b/pyproject.tomlindex 40807172..5c45f72a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"[project]name = "ministack"-version = "1.4.10"+version = "1.4.11"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.pyindex ef4ece4c..0c464757 100644--- a/tests/test_cloudwatch.py+++ b/tests/test_cloudwatch.py@@ -624,3 +624,145 @@ def test_cloudwatch_describe_alarms_cbor_timestamps_are_tag1():_cw._alarms.pop_scoped("000000000000", "us-east-1", name, None)_resp._request_region.reset(region_tok)_resp._request_account_id.reset(acct_tok)+++def _cbor_has_nil(value):+ if value is None:+ return True+ if isinstance(value, dict):+ return any(_cbor_has_nil(v) for v in value.values())+ if isinstance(value, list):+ return any(_cbor_has_nil(v) for v in value)+ return False+++def test_cloudwatch_describe_alarms_cbor_omits_absent_optional_fields():+ """DescribeAlarms over smithy-rpc-v2-cbor must OMIT absent optional fields+ (ExtendedStatistic, Unit) rather than serialize them as CBOR Nil, or the+ Terraform AWS provider >= 6.50 fails the read-back with+ `unexpected value type *cbor.Nil` (issue #1261). Real AWS omits absent+ optional members entirely.+ """+ import cbor2++ from ministack.core import responses as _resp+ from ministack.services import cloudwatch as _cw++ acct_tok = _resp._request_account_id.set("000000000000")+ region_tok = _resp._request_region.set("us-east-1")+ name = f"cbor-nil-{_uuid_mod.uuid4().hex[:8]}"+ try:+ # No ExtendedStatistic / Unit -> stored as None on the alarm record.+ _cw._put_metric_alarm({}, {+ "AlarmName": name,+ "ComparisonOperator": "GreaterThanThreshold",+ "EvaluationPeriods": 1,+ "MetricName": "Errors",+ "Namespace": "AWS/Lambda",+ "Period": 300,+ "Statistic": "Sum",+ "Threshold": 1,+ }, is_cbor=True)++ status, _headers, body = _cw._describe_alarms({}, {"AlarmNames": [name]}, is_cbor=True)+ assert status == 200+ decoded = cbor2.loads(body)+ alarm = next(a for a in decoded["MetricAlarms"] if a["AlarmName"] == name)++ assert "ExtendedStatistic" not in alarm+ assert "Unit" not in alarm+ assert not _cbor_has_nil(decoded)+ finally:+ _cw._alarms.pop_scoped("000000000000", "us-east-1", name, None)+ _resp._request_region.reset(region_tok)+ _resp._request_account_id.reset(acct_tok)+++def test_cloudwatch_get_metric_statistics_cbor_timestamps_are_tag1():+ """GetMetricStatistics over smithy-rpc-v2-cbor must encode+ Datapoint.Timestamp as CBOR tag 1, not an ISO string, so the provider's+ typed decoder accepts it (same class as issue #1261)."""+ import datetime as _dt+ import time as _time++ import cbor2++ from ministack.core import responses as _resp+ from ministack.services import cloudwatch as _cw++ acct_tok = _resp._request_account_id.set("000000000000")+ region_tok = _resp._request_region.set("us-east-1")+ namespace = f"MSTest/{_uuid_mod.uuid4().hex[:8]}"+ now = int(_time.time())+ try:+ _cw._put_metric_data({}, {+ "Namespace": namespace,+ "MetricData": [{"MetricName": "M", "Value": 1.0, "Timestamp": now}],+ }, is_cbor=True)++ status, _headers, body = _cw._get_metric_statistics({}, {+ "Namespace": namespace,+ "MetricName": "M",+ "Period": 60,+ "StartTime": now - 3600,+ "EndTime": now + 3600,+ "Statistics": ["Sum"],+ }, is_cbor=True)+ assert status == 200+ datapoints = cbor2.loads(body)["Datapoints"]+ assert datapoints, "expected at least one datapoint"+ assert isinstance(datapoints[0]["Timestamp"], _dt.datetime)+ finally:+ for key in list(_cw._metrics.keys()):+ if key[0] == namespace:+ _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_get_metric_data_cbor_timestamps_are_tag1():+ """GetMetricData over smithy-rpc-v2-cbor must encode+ MetricDataResult.Timestamps as CBOR tag 1 values, not ISO strings (same+ class as issue #1261)."""+ import datetime as _dt+ import time as _time++ import cbor2++ from ministack.core import responses as _resp+ from ministack.services import cloudwatch as _cw++ acct_tok = _resp._request_account_id.set("000000000000")+ region_tok = _resp._request_region.set("us-east-1")+ namespace = f"MSTest/{_uuid_mod.uuid4().hex[:8]}"+ now = int(_time.time())+ try:+ _cw._put_metric_data({}, {+ "Namespace": namespace,+ "MetricData": [{"MetricName": "M", "Value": 2.0, "Timestamp": now}],+ }, is_cbor=True)++ status, _headers, body = _cw._get_metric_data({}, {+ "StartTime": now - 3600,+ "EndTime": now + 3600,+ "MetricDataQueries": [{+ "Id": "m1",+ "ReturnData": True,+ "MetricStat": {+ "Metric": {"Namespace": namespace, "MetricName": "M"},+ "Period": 60,+ "Stat": "Sum",+ },+ }],+ }, is_cbor=True)+ assert status == 200+ results = cbor2.loads(body)["MetricDataResults"]+ timestamps = results[0]["Timestamps"]+ assert timestamps, "expected at least one timestamp"+ assert all(isinstance(t, _dt.datetime) for t in timestamps)+ finally:+ for key in list(_cw._metrics.keys()):+ if key[0] == namespace:+ _cw._metrics.pop_scoped("000000000000", "us-east-1", key, None)+ _resp._request_region.reset(region_tok)+ _resp._request_account_id.reset(acct_tok)