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/update botocore (#1923)
Nahuel Nucera9ce5bf153965
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 72668469..7131340e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,15 @@ Versioning follows [Semantic Versioning](https://semver.org/).## [Unreleased]+### Changed++- **botocore 1.43.106** — the service models MiniStack reads move from 1.43.63 to 1.43.106; the images keep `awscli` 1.45.63, installed on the same botocore instead of its pinned one.++### Fixed++- **SES v2 — `ListEmailIdentities` and `ListConfigurationSets` answer the routes newer SDKs use** — botocore 1.43.106 sends them as `POST /v2/email/list-identities` and `POST /v2/email/list-configuration-sets` with `NextToken`, `PageSize` and `Filter` in the body; those paths answered `NotFoundException`. Both forms page, and the `Filter` keys are applied.+- **Kinesis — `ApproximateArrivalTimestamp` keeps milliseconds** — it was truncated to whole seconds, so an `AT_TIMESTAMP` iterator from an SDK that sends fractional seconds skipped records written earlier in the same second.+- **CloudFormation — an empty `Capabilities` list is accepted** — botocore sends it as a bare `Capabilities=`, which was read as one empty value and refused, so `aws cloudformation deploy` without `--capabilities` and `Capabilities=[]` from an SDK failed with a `ValidationError` since 1.5.11.### Added- **IoT — registry events** — with a type enabled through `UpdateEventConfigurations`, the thing, thing type, thing type association, thing group, thing group hierarchy and thing group membership operations publish the AWS payload to `$aws/events/...`, where MQTT subscribers and topic rules receive it. Contributed by @iot-rocket.diff --git a/Dockerfile b/Dockerfileindex 6838888e..0b464e89 100644--- a/Dockerfile+++ b/Dockerfile@@ -6,6 +6,8 @@ ARG PLUGIN_DONOR_IMAGE=ghcr.io/ministackorg/ministack:fullFROM python:3.13-alpine AS builder+# awscli 1.45.x pins botocore exactly and 1.46 bundles its own copy (~120 MB),+# so the CLI is installed without deps and runs on the botocore pinned here.RUN pip install --no-cache-dir --no-compile \hypercorn==0.18.0 \"cbor2>=5.4.0" \@@ -18,7 +20,11 @@ RUN pip install --no-cache-dir --no-compile \"boto3>=1.34" \"jsonata-python>=0.7.0" \"graphql-core==3.2.12" \- "awscli==1.45.63"+ "botocore==1.43.106" \+ "docutils>=0.18.1,<=0.19" \+ "colorama>=0.2.5,<0.4.7" \+ "rsa>=3.1.2,<4.8" \+ && pip install --no-cache-dir --no-compile --no-deps awscli==1.45.63# Strip awscli help examples (~25 MB) and Python cache files (~15 MB).RUN rm -rf /usr/local/lib/python3.13/site-packages/awscli/examples \diff --git a/Dockerfile.full b/Dockerfile.fullindex a4dc0d05..7d5e3f4e 100644--- a/Dockerfile.full+++ b/Dockerfile.full@@ -4,6 +4,8 @@ FROM python:3.13-slim AS builder# published manylinux wheels instead of building from source against musl.# See issue #411: DuckDB has no musllinux wheels and runs ~30% slower# on musl per upstream docs; psycopg2-binary likewise has no musl wheels.+# awscli 1.45.x pins botocore exactly and 1.46 bundles its own copy (~120 MB),+# so the CLI is installed without deps and runs on the botocore pinned here.RUN pip install --no-cache-dir --no-compile \hypercorn==0.18.0 \"cbor2>=5.4.0" \@@ -19,7 +21,11 @@ RUN pip install --no-cache-dir --no-compile \"boto3>=1.34" \"jsonata-python>=0.7.0" \"graphql-core==3.2.12" \- "awscli==1.45.63"+ "botocore==1.43.106" \+ "docutils>=0.18.1,<=0.19" \+ "colorama>=0.2.5,<0.4.7" \+ "rsa>=3.1.2,<4.8" \+ && pip install --no-cache-dir --no-compile --no-deps awscli==1.45.63# Strip awscli help examples (~25 MB), Python cache files (~15 MB),# pip metadata, and DuckDB stub / ADBC artefacts that aren't used at runtime.diff --git a/ministack/services/cloudformation/helpers.py b/ministack/services/cloudformation/helpers.pyindex 3708c6e0..174b9a00 100644--- a/ministack/services/cloudformation/helpers.py+++ b/ministack/services/cloudformation/helpers.py@@ -288,7 +288,8 @@ def _extract_string_members(params, prefix):protocol sends it as a list under the bare key."""direct = params.get(prefix)if isinstance(direct, list):- return [str(v) for v in direct]+ # A Query-protocol empty list arrives as a bare ``Name=``.+ return [str(v) for v in direct if v != ""]result = []i = 1while True:diff --git a/ministack/services/kinesis.py b/ministack/services/kinesis.pyindex 0b079095..f2b3d440 100644--- a/ministack/services/kinesis.py+++ b/ministack/services/kinesis.py@@ -333,7 +333,7 @@ def put_record_internal(stream_arn: str, partition_key: str, data: bytes) -> booshard_id = _route_to_shard(hash_int, stream)stream["shards"][shard_id]["records"].append({"SequenceNumber": _next_sequence_number(),- "ApproximateArrivalTimestamp": int(time.time()),+ "ApproximateArrivalTimestamp": round(time.time(), 3),"Data": base64.b64encode(data).decode("ascii"),"PartitionKey": partition_key,})@@ -631,7 +631,7 @@ def _put_record(data):stream["shards"][shard_id]["records"].append({"SequenceNumber": seq,- "ApproximateArrivalTimestamp": int(time.time()),+ "ApproximateArrivalTimestamp": round(time.time(), 3),"Data": record_data,"PartitionKey": partition_key,})@@ -700,7 +700,7 @@ def _put_records(data):seq = _next_sequence_number()stream["shards"][sid]["records"].append({"SequenceNumber": seq,- "ApproximateArrivalTimestamp": int(time.time()),+ "ApproximateArrivalTimestamp": round(time.time(), 3),"Data": rd,"PartitionKey": pk,})diff --git a/ministack/services/ses_v2.py b/ministack/services/ses_v2.pyindex 6f234782..576816da 100644--- a/ministack/services/ses_v2.py+++ b/ministack/services/ses_v2.py@@ -186,8 +186,13 @@ def _page_size(query_params, default, maximum=100):return size, None-def _paginate(items, query_params, default_size):- size, err = _page_size(query_params, default_size)+def _body_paging(data):+ """NextToken / PageSize sent in a JSON body, in the query-parameter form."""+ return {k: str(data[k]) for k in ("NextToken", "PageSize") if data.get(k) is not None}+++def _paginate(items, query_params, default_size, maximum=100):+ size, err = _page_size(query_params, default_size, maximum)if err:return [], None, errstart, err = _decode_page_token(_first_query_value(query_params, "NextToken"))@@ -486,14 +491,27 @@ async def handle_request(method, path, headers, body, query_params):"DkimAttributes": dkim_attributes,})- # GET /v2/email/identities (ListEmailIdentities)- if sub == "/identities" and method == "GET":- return json_response({- "EmailIdentities": [- {"IdentityType": v["IdentityType"], "IdentityName": k, "SendingEnabled": True}- for k, v in _identities.items()- ],- })+ # ListEmailIdentities: GET /v2/email/identities, or POST /v2/email/list-identities+ # with paging and Filter in the body (newer SDKs)+ if (sub == "/identities" and method == "GET") or (sub == "/list-identities" and method == "POST"):+ params = query_params if method == "GET" else _body_paging(data)+ wanted = (data.get("Filter") or {}) if method == "POST" else {}+ items = [+ {"IdentityType": v["IdentityType"], "IdentityName": k, "SendingEnabled": True,+ "VerificationStatus": "SUCCESS"}+ for k, v in _identities.items()+ ]+ items = [i for i in items+ if wanted.get("IDENTITY_NAME_CONTAINS", "") in i["IdentityName"]+ and wanted.get("IDENTITY_TYPE", i["IdentityType"]) == i["IdentityType"]+ and wanted.get("VERIFICATION_STATUS", "SUCCESS") == "SUCCESS"]+ page, next_token, err = _paginate(items, params, 1000, maximum=1000)+ if err:+ return err+ out = {"EmailIdentities": page}+ if next_token:+ out["NextToken"] = next_token+ return json_response(out)# GET /v2/email/identities/{identity}m = re.match(r"^/identities/(.+)$", sub)@@ -517,9 +535,21 @@ async def handle_request(method, path, headers, body, query_params):_ses_tags[_resource_arn("configuration-set", name)] = list(data.get("Tags", []))return json_response({})- # GET /v2/email/configuration-sets (ListConfigurationSets)- if sub == "/configuration-sets" and method == "GET":- return json_response({"ConfigurationSets": list(_config_sets.keys())})+ # ListConfigurationSets: GET /v2/email/configuration-sets, or+ # POST /v2/email/list-configuration-sets with paging and Filter in the body+ if ((sub == "/configuration-sets" and method == "GET")+ or (sub == "/list-configuration-sets" and method == "POST")):+ params = query_params if method == "GET" else _body_paging(data)+ contains = ((data.get("Filter") or {}).get("CONFIGURATION_SET_NAME_CONTAINS", "")+ if method == "POST" else "")+ page, next_token, err = _paginate(+ [n for n in _config_sets if contains in n], params, 1000, maximum=1000)+ if err:+ return err+ out = {"ConfigurationSets": page}+ if next_token:+ out["NextToken"] = next_token+ return json_response(out)# GET/DELETE /v2/email/configuration-sets/{name}m = re.match(r"^/configuration-sets/([^/]+)$", sub)diff --git a/pyproject.toml b/pyproject.tomlindex 08bf60ae..49c92d49 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -30,8 +30,8 @@ dependencies = [# models to map a wire request to its IAM action. Without it that lookup# finds nothing and AUTH=true would allow what it cannot classify, so this# is a runtime dependency rather than a dev one. Pinned to the version the- # images already carry: awscli==1.45.63 requires botocore==1.43.63.- "botocore==1.43.63",+ # images carry.+ "botocore==1.43.106",# Step Functions JSONata expressions (QueryLanguage: JSONata) are evaluated# by this pure-Python port of the reference jsonata-js engine, which AWS# documents Step Functions as implementing per the JSONata 2.0.6 spec. Purediff --git a/requirements.txt b/requirements.txtindex 48fed913..ad16618c 100644--- a/requirements.txt+++ b/requirements.txt@@ -1,6 +1,6 @@hypercorn==0.18.0docker>=7.0.0cbor2>=5.4.0-# Pinned to the version the images carry (awscli==1.45.63 requires it), so a-# pip install and a Docker run classify requests against identical service models.-botocore==1.43.63+# Pinned to the version the images carry, so a pip install and a Docker run+# classify requests against identical service models.+botocore==1.43.106diff --git a/tests/test_cfn.py b/tests/test_cfn.pyindex 3e75a428..01e36ec2 100644--- a/tests/test_cfn.py+++ b/tests/test_cfn.py@@ -2476,6 +2476,23 @@ def test_cfn_stack_and_change_set_report_their_capabilities(cfn):_delete_cfn_test_stack(cfn, stack_name)+def test_cfn_empty_capabilities_list_is_accepted(cfn):+ """botocore sends an empty Capabilities list as a bare ``Capabilities=``,+ which is what ``aws cloudformation deploy`` does without --capabilities."""+ uid = _uuid_mod.uuid4().hex[:8]+ template = json.dumps({"Resources": {"Q": {"Type": "AWS::SQS::Queue"}}})+ stack_name, cs_stack = f"cfn-caps-empty-{uid}", f"cfn-caps-empty-cs-{uid}"+ try:+ cfn.create_stack(StackName=stack_name, TemplateBody=template, Capabilities=[])+ assert _wait_stack(cfn, stack_name)["StackStatus"] == "CREATE_COMPLETE"+ cfn.create_change_set(StackName=cs_stack, ChangeSetName="cs", ChangeSetType="CREATE",+ TemplateBody=template, Capabilities=[])+ assert _wait_change_set(cfn, cs_stack, "cs")["Status"] == "CREATE_COMPLETE"+ finally:+ _delete_cfn_test_stack(cfn, stack_name)+ _delete_cfn_test_stack(cfn, cs_stack)++def test_cfn_unknown_capability_is_refused(cfn):"""Capabilities is an enum of three values, so a fourth is a parametervalidation error rather than something the stack silently keeps, ondiff --git a/tests/test_ses.py b/tests/test_ses.pyindex f307f4a6..9c9501db 100644--- a/tests/test_ses.py+++ b/tests/test_ses.py@@ -236,6 +236,41 @@ def test_ses_v2_configuration_set_crud(sesv2):lst2 = sesv2.list_configuration_sets()assert "my-cfg-set" not in lst2["ConfigurationSets"]+def test_ses_v2_list_routes_old_and_new(sesv2):+ """SDKs since botocore 1.43.106 list with POST /v2/email/list-identities and+ /list-configuration-sets (paging and Filter in the body); older ones GET."""+ import urllib.request++ from conftest import ENDPOINT+ uid = _uuid_mod.uuid4().hex[:8]+ names = [f"list-{uid}-{i}.example.com" for i in range(3)] + [f"user-{uid}@example.com"]+ for name in names:+ sesv2.create_email_identity(EmailIdentity=name)+ sesv2.create_configuration_set(ConfigurationSetName=f"cfg-{uid}")+ try:+ domains = sesv2.list_email_identities(+ Filter={"IDENTITY_NAME_CONTAINS": uid, "IDENTITY_TYPE": "DOMAIN"}, PageSize=2)+ first = [e["IdentityName"] for e in domains["EmailIdentities"]]+ rest = sesv2.list_email_identities(+ Filter={"IDENTITY_NAME_CONTAINS": uid, "IDENTITY_TYPE": "DOMAIN"},+ PageSize=2, NextToken=domains["NextToken"])+ assert sorted(first + [e["IdentityName"] for e in rest["EmailIdentities"]]) == names[:3]+ assert "NextToken" not in rest+ assert sesv2.list_configuration_sets(+ Filter={"CONFIGURATION_SET_NAME_CONTAINS": uid})["ConfigurationSets"] == [f"cfg-{uid}"]++ auth = {"Authorization": "AWS4-HMAC-SHA256 Credential=test/20261001/us-east-1/ses/aws4_request"}+ for path, key, expected in (("/v2/email/identities", "EmailIdentities", names[0]),+ ("/v2/email/configuration-sets", "ConfigurationSets", f"cfg-{uid}")):+ with urllib.request.urlopen(urllib.request.Request(ENDPOINT + path, headers=auth)) as r:+ listed = json.loads(r.read())[key]+ assert expected in [i["IdentityName"] if isinstance(i, dict) else i for i in listed]+ finally:+ for name in names:+ sesv2.delete_email_identity(EmailIdentity=name)+ sesv2.delete_configuration_set(ConfigurationSetName=f"cfg-{uid}")++def test_ses_v2_get_account(sesv2):resp = sesv2.get_account()assert resp["SendingEnabled"] is True