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(aws conformance): fix parity gaps (#1527)
Nahuel Nucera74a6f8f9fa6b
diff --git a/README.md b/README.mdindex 31c842d9..dd928f5b 100644--- a/README.md+++ b/README.md@@ -215,11 +215,11 @@ 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); API Gateway v1 (1.4.11); API Gateway v2 (1.4.12); AWS Config and Cloud Control API (1.4.14).+**Region-isolated services:** as of 1.5.1, every regional service is region-isolated except S3 and Aurora DSQL (the isolation migrations rolled out service by service from 1.4.0 to 1.4.12 — see the CHANGELOG for the per-release history; services introduced later, like AWS Config and the Cloud Control API in 1.4.14, were born region-scoped).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.-**Not yet region-isolated:** S3, IAM/STS, API Gateway v1/v2, CloudFront, Route 53, Organizations, and the remaining control-plane services — these share state across regions within an account (as all services did before 1.4.0); use unique resource names there if your tests exercise two regions. Region isolation for them lands in subsequent releases.+**Not yet region-isolated:** S3 and Aurora DSQL — these share state across regions within an account (as all services did before 1.4.0); use unique resource names there if your tests exercise two regions, until their isolation lands in a subsequent release. IAM/STS, CloudFront, Route 53, and Organizations are global services on AWS, so their account-scoped shared state is correct, not a gap.**Upgrading with `PERSIST_STATE=1`:** existing state files load and migrate automatically (on-disk format v2 with a version stamp — a newer-format file is refused instead of mis-parsed on downgrade). Each record's region is recovered from its stored ARNs; legacy records that carry no ARN migrate to the default region (`MINISTACK_REGION`).diff --git a/ministack/services/codebuild.py b/ministack/services/codebuild.pyindex 712b5044..c71b8b7b 100644--- a/ministack/services/codebuild.py+++ b/ministack/services/codebuild.py@@ -737,7 +737,11 @@ def _batch_delete_builds(data):del _builds[bid]deleted.append(bid)else:- not_deleted.append(bid)+ # BuildNotDeleted is a structure ({id, statusCode}), not a bare id —+ # SDK parsers crash on a plain string here. The AWS reference only+ # documents BUILD_IN_PROGRESS as an example statusCode; NOT_FOUND is+ # our value for an unknown id.+ not_deleted.append({"id": bid, "statusCode": "NOT_FOUND"})return json_response({"buildsDeleted": deleted, "buildsNotDeleted": not_deleted})diff --git a/ministack/services/ec2.py b/ministack/services/ec2.pyindex d32f42f9..a5a4bbf2 100644--- a/ministack/services/ec2.py+++ b/ministack/services/ec2.py@@ -5835,26 +5835,6 @@ def _describe_instance_credit_specifications(p):f"<instanceCreditSpecificationSet>{items}</instanceCreditSpecificationSet>")-def _describe_instance_maintenance_options(p):- instance_ids = _parse_member_list(p, "InstanceId")- items = "".join(- f"<item><instanceId>{iid}</instanceId><autoRecovery>default</autoRecovery></item>"- for iid in (instance_ids or list(_instances.keys()))- )- return _xml(200, "DescribeInstanceMaintenanceOptionsResponse",- f"<instanceMaintenanceOptionSet>{items}</instanceMaintenanceOptionSet>")---def _describe_instance_auto_recovery_attribute(p):- instance_ids = _parse_member_list(p, "InstanceId")- items = "".join(- f"<item><instanceId>{iid}</instanceId><autoRecovery><value>default</value></autoRecovery></item>"- for iid in (instance_ids or list(_instances.keys()))- )- return _xml(200, "DescribeInstanceAutoRecoveryAttributeResponse",- f"<instanceAutoRecoveryAttributeSet>{items}</instanceAutoRecoveryAttributeSet>")--def _modify_instance_maintenance_options(p):instance_id = _p(p, "InstanceId")return _xml(200, "ModifyInstanceMaintenanceOptionsResponse",@@ -6876,8 +6856,6 @@ _ACTION_MAP = {"DescribeInstanceStatus": _describe_instance_status,"DescribeInstanceAttribute": _describe_instance_attribute,"DescribeInstanceCreditSpecifications": _describe_instance_credit_specifications,- "DescribeInstanceMaintenanceOptions": _describe_instance_maintenance_options,- "DescribeInstanceAutoRecoveryAttribute": _describe_instance_auto_recovery_attribute,"ModifyInstanceMaintenanceOptions": _modify_instance_maintenance_options,"DescribeInstanceTopology": _describe_instance_topology,"DescribeSpotInstanceRequests": _describe_spot_instance_requests,diff --git a/ministack/services/lambda_svc.py b/ministack/services/lambda_svc.pyindex 8c52bad9..d0412a13 100644--- a/ministack/services/lambda_svc.py+++ b/ministack/services/lambda_svc.py@@ -2267,6 +2267,12 @@ async def _invoke_with_response_stream(name: str, event: dict, headers: dict,provide — so we cannot do any better without a custom RIE fork."""status, resp_headers, resp_body = await _invoke(name, event, headers, path_qualifier, query_params)+ # An HTTP-level failure (ResourceNotFoundException 404, throttles, ...)+ # never streams on AWS: the error is a plain JSON response, and wrapping+ # it in an eventstream envelope crashes SDK parsers. Only a 200 —+ # including a handler error, which rides InvokeComplete — is framed.+ if status != 200:+ return status, resp_headers, resp_body# Detect handler-level errors from the standard invoke path so we can flip# to the InvokeError event type in the stream.is_error = bool(resp_headers and resp_headers.get("X-Amz-Function-Error"))diff --git a/ministack/services/s3.py b/ministack/services/s3.pyindex cad7bf5f..08acb4a1 100644--- a/ministack/services/s3.py+++ b/ministack/services/s3.py@@ -208,8 +208,8 @@ def _resolve_storage_class(headers: dict, default: str = "STANDARD"):# Storage classes whose objects are unreadable until restored. GLACIER_IR is# deliberately absent: instant retrieval is an active tier, readable directly,-# and RestoreObject against it fails ObjectAlreadyInActiveTierError like any-# other active class.+# and RestoreObject against it fails InvalidObjectState ("Restore is not+# allowed for the object's current storage class.")._ARCHIVE_STORAGE_CLASSES = frozenset({"GLACIER", "DEEP_ARCHIVE"})# Simulated retrieval latency. Fixed on purpose: every caller passes throughdiff --git a/ministack/services/s3tables.py b/ministack/services/s3tables.pyindex 314f5dbd..298ddda7 100644--- a/ministack/services/s3tables.py+++ b/ministack/services/s3tables.py@@ -260,7 +260,7 @@ def _delete_table_bucket(arn):del _table_buckets[name]import ministack.services.s3 as _s3_s3._buckets.pop(name, None)- return json_response({})+ return 204, {}, b"" # AWS answers 204 No Content on the deletesdef _create_namespace(bucket_arn, data):@@ -312,7 +312,7 @@ def _delete_namespace(bucket_arn, namespace):if key not in _namespaces:return error_response_json("NotFoundException", f"Namespace {namespace} not found", 404)del _namespaces[key]- return json_response({})+ return 204, {}, b"" # AWS answers 204 No Content on the deletesdef _create_table(bucket_arn, namespace, data):@@ -400,7 +400,7 @@ def _delete_table(bucket_arn, namespace, table_name):if key not in _tables:return error_response_json("NotFoundException", f"Table {table_name} not found", 404)del _tables[key]- return json_response({})+ return 204, {}, b"" # AWS answers 204 No Content on the deletesdef _get_table_metadata_location(bucket_arn, namespace, table_name):diff --git a/tests/test_codebuild.py b/tests/test_codebuild.pyindex 1bafb34a..e4a2d3e5 100644--- a/tests/test_codebuild.py+++ b/tests/test_codebuild.py@@ -178,6 +178,16 @@ def test_codebuild_batch_delete_builds(codebuild):assert build_id in resp["buildsDeleted"]+def test_codebuild_batch_delete_builds_not_deleted_shape(codebuild):+ """An id that matches no build comes back as a BuildNotDeleted structure+ ({id, statusCode}), not a bare string — SDK parsers crash on the string."""+ resp = codebuild.batch_delete_builds(ids=["test-project:00000000-0000-0000-0000-000000000000"])+ assert resp["buildsDeleted"] == []+ entry = resp["buildsNotDeleted"][0]+ assert entry["id"] == "test-project:00000000-0000-0000-0000-000000000000"+ assert entry["statusCode"]++def test_codebuild_delete_project(codebuild):codebuild.delete_project(name="test-project")resp = codebuild.list_projects()diff --git a/tests/test_lambda.py b/tests/test_lambda.pyindex bb1b34ee..ea67c87b 100644--- a/tests/test_lambda.py+++ b/tests/test_lambda.py@@ -10679,3 +10679,12 @@ def handler(event, context):f"throttled={results.count('throttled')}, error={results.count('error')})")assert results.count("ok") > 0, "no invocation succeeded at all"+++def test_lambda_invoke_with_response_stream_missing_function_is_plain_error(lam):+ """An HTTP-level failure never streams: AWS answers a plain JSON+ ResourceNotFoundException, and an eventstream-framed error body would+ crash the SDK's stream parser with a decode error."""+ with pytest.raises(ClientError) as exc:+ lam.invoke_with_response_stream(FunctionName="stream-does-not-exist")+ assert exc.value.response["Error"]["Code"] == "ResourceNotFoundException"diff --git a/tests/test_s3tables.py b/tests/test_s3tables.pyindex beeec8c5..40abc837 100644--- a/tests/test_s3tables.py+++ b/tests/test_s3tables.py@@ -1008,3 +1008,17 @@ def test_s3tables_iceberg_add_sort_order_is_idempotent_by_order_id(s3tables):except Exception:passs3tables.delete_table_bucket(tableBucketARN=bucket_arn)+++def test_s3tables_deletes_answer_204(s3tables):+ """DeleteNamespace / DeleteTable / DeleteTableBucket answer 204 No Content."""+ arn = s3tables.create_table_bucket(name="del-status-bkt")["arn"]+ s3tables.create_namespace(tableBucketARN=arn, namespace=["ns204"])+ s3tables.create_table(tableBucketARN=arn, namespace="ns204", name="t204",+ format="ICEBERG")+ r = s3tables.delete_table(tableBucketARN=arn, namespace="ns204", name="t204")+ assert r["ResponseMetadata"]["HTTPStatusCode"] == 204+ r = s3tables.delete_namespace(tableBucketARN=arn, namespace="ns204")+ assert r["ResponseMetadata"]["HTTPStatusCode"] == 204+ r = s3tables.delete_table_bucket(tableBucketARN=arn)+ assert r["ResponseMetadata"]["HTTPStatusCode"] == 204