Skip to content

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

feat(iot): add DescribeEventConfigurations and UpdateEventConfigurations (#1883)

iot-rocketb654e62b8e79
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 194a2499..f4a87458 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,10 +11,14 @@ Versioning follows [Semantic Versioning](https://semver.org/).
- **API Gateway v2 — `apiEndpoint` follows the gateway's TLS scheme** — with `USE_SSL=1` the gateway listener serves only HTTPS, but CreateApi and the `AWS::ApiGatewayV2::Api` CloudFormation resource always returned an `http://` `apiEndpoint`, which nothing answers. They now return `https://`, or `wss://` for a WebSocket API, as AWS does. Without `USE_SSL` the endpoint keeps `http://`.
+- **IoT — `DescribeEventConfigurations` and `UpdateEventConfigurations`** — both answered `Unsupported IoT path`; they now store the registry event switches per account and region, every type starting disabled, an update changing only the types it names, and `creationDate` / `lastModifiedDate` set from the first update on, as on AWS.
+
## [1.5.19] — 2026-09-30
### Added
+
+- **RDS — IAM database authentication for MySQL and Aurora MySQL** — users created `IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS'` log in with an SDK-generated token over `mysql_clear_password`, as on AWS. The instance or cluster must have `IAMDatabaseAuthenticationEnabled`; with `AUTH=true` the token and the `rds-db:connect` policy are verified too. `ModifyDBInstance` accepts `EnableIAMDatabaseAuthentication`. Contributed by @Areson.
- **Kinesis — `SubscribeToShard`** — enhanced fan-out: a registered consumer receives the shard's records as `SubscribeToShardEvent`s over an event stream (HTTP/1.1 or HTTP/2) for up to 5 minutes, from any `StartingPosition`, with `ContinuationSequenceNumber` for resuming and `ChildShards` when the shard is split or merged. A second call for the same consumer and shard within 5 seconds is a `ResourceInUseException`; a later one takes the subscription over.
- **CloudWatch Logs — resource policies** — `PutResourcePolicy`, `DescribeResourcePolicies` and `DeleteResourcePolicy`, account-scoped (up to 10) or scoped to one log group through `resourceArn`, with `expectedRevisionId` checks. `AWS::Logs::ResourcePolicy` stacks now create real policies. Contributed by @fabio-andre-rodrigues.
- **CloudFormation — `RollbackStack`** — rolls a stack left `CREATE_FAILED` or `UPDATE_FAILED` with rollback disabled back to its last stable state: a failed create ends `ROLLBACK_COMPLETE`, a failed update reverts its changes, deletes what it added and ends `UPDATE_ROLLBACK_COMPLETE`. `RetainExceptOnCreate` is honoured. Contributed by @fabio-andre-rodrigues.
diff --git a/ministack/services/iot.py b/ministack/services/iot.py
index ab95f2ad..447f9c2b 100644
--- a/ministack/services/iot.py
+++ b/ministack/services/iot.py
@@ -32,6 +32,8 @@ Implements the JSON/REST APIs under ``iot.{region}.amazonaws.com``:
- Fleet indexing: ``UpdateIndexingConfiguration`` /
``GetIndexingConfiguration`` / ``DescribeIndex`` / ``ListIndices``, and
``SearchIndex`` over the live registry, shadows and MQTT connectivity
+ - Registry events: ``DescribeEventConfigurations`` /
+ ``UpdateEventConfigurations``
- Jobs (control plane): ``CreateJob``, ``DescribeJob``, ``ListJobs``,
``GetJobDocument``, ``CancelJob``, ``DeleteJob``,
``ListJobExecutionsForThing``, ``DescribeJobExecution``,
@@ -110,6 +112,8 @@ _topic_rules: AccountRegionScopedDict = AccountRegionScopedDict()
_shadows: AccountRegionScopedDict = AccountRegionScopedDict()
# Fleet-indexing configuration, one entry per account+region.
_indexing_config: AccountRegionScopedDict = AccountRegionScopedDict()
+# Registry event configuration (UpdateEventConfigurations), one entry per account+region.
+_event_config: AccountRegionScopedDict = AccountRegionScopedDict()
# CA-certificate registry (RegisterCACertificate & friends): caCertificateId -> record
_ca_certificates: AccountRegionScopedDict = AccountRegionScopedDict()
# JITR registration code — a single "code" key per account/region
@@ -237,6 +241,7 @@ def get_state() -> dict:
"topic_rules": copy.deepcopy(_topic_rules),
"shadows": copy.deepcopy(_shadows),
"indexing_config": copy.deepcopy(_indexing_config),
+ "event_config": copy.deepcopy(_event_config),
"ca_certificates": copy.deepcopy(_ca_certificates),
"registration_codes": copy.deepcopy(_registration_codes),
"provisioning_templates": copy.deepcopy(_provisioning_templates),
@@ -272,6 +277,7 @@ def _restore_state(data: dict | None) -> None:
_topic_rules.update(data.get("topic_rules", {}))
_shadows.update(data.get("shadows", {}))
_indexing_config.update(data.get("indexing_config", {}))
+ _event_config.update(data.get("event_config", {}))
_ca_certificates.update(data.get("ca_certificates", {}))
_registration_codes.update(data.get("registration_codes", {}))
_provisioning_templates.update(data.get("provisioning_templates", {}))
@@ -312,6 +318,7 @@ def reset() -> None:
# gets no warning.
_warned_sql_funcs.clear()
_indexing_config.clear()
+ _event_config.clear()
_ca_certificates.clear()
_registration_codes.clear()
_provisioning_templates.clear()
@@ -581,6 +588,10 @@ async def handle_request(
return _list_indices()
if path.startswith("/indices/") and method == "GET":
return _describe_index(path)
+ if path == "/event-configurations" and method == "GET":
+ return _describe_event_configurations()
+ if path == "/event-configurations" and method == "PATCH":
+ return _update_event_configurations(_parse_body(body))
# Jobs (control plane) — CreateJob is PUT /jobs/{jobId} per the botocore
# `iot` service model; sub-resources (/cancel, /job-document) are
# dispatched inside _handle_job.
@@ -2791,6 +2802,66 @@ def _search_index(payload: dict) -> tuple:
return json_response(body)
+# ---------------------------------------------------------------------------
+# Registry event configuration
+# ---------------------------------------------------------------------------
+
+_EVENT_TYPES = (
+ "CA_CERTIFICATE", "CERTIFICATE", "JOB", "JOB_EXECUTION", "POLICY", "THING",
+ "THING_GROUP", "THING_GROUP_HIERARCHY", "THING_GROUP_MEMBERSHIP", "THING_TYPE",
+ "THING_TYPE_ASSOCIATION",
+)
+_EVENT_CONFIG_KEY = "events"
+
+
+def _event_configuration() -> dict:
+ """The account+region's event configuration; every type is off until the first update."""
+ stored = _event_config.get(_EVENT_CONFIG_KEY) or {}
+ return {
+ "eventConfigurations": {
+ t: {"Enabled": t in stored.get("enabled", ())} for t in _EVENT_TYPES
+ },
+ "creationDate": stored.get("creationDate"),
+ "lastModifiedDate": stored.get("lastModifiedDate"),
+ }
+
+
+def _describe_event_configurations() -> tuple:
+ """``GET /event-configurations``."""
+ return json_response(_event_configuration())
+
+
+def _update_event_configurations(payload: dict) -> tuple:
+ """``PATCH /event-configurations`` — types the request names change, the rest keep their state."""
+ configurations = payload.get("eventConfigurations")
+ if not isinstance(configurations, dict):
+ return error_response_json(
+ "InvalidRequestException", "Configuration cannot be null", 400
+ )
+ if set(configurations) - set(_EVENT_TYPES):
+ return error_response_json(
+ "InvalidRequestException",
+ "1 validation error detected: Value at 'eventConfigurations' failed to "
+ "satisfy constraint: Map keys must satisfy constraint: [Member must "
+ f"satisfy enum value set: [{', '.join(_EVENT_TYPES)}]]",
+ 400,
+ )
+ stored = _event_config.get(_EVENT_CONFIG_KEY) or {}
+ enabled = set(stored.get("enabled", ()))
+ for event_type, configuration in configurations.items():
+ if isinstance(configuration, dict) and configuration.get("Enabled") is True:
+ enabled.add(event_type)
+ else:
+ enabled.discard(event_type)
+ now = _now_epoch()
+ _event_config[_EVENT_CONFIG_KEY] = {
+ "enabled": sorted(enabled),
+ "creationDate": stored.get("creationDate", now),
+ "lastModifiedDate": now,
+ }
+ return json_response({})
+
+
# ---------------------------------------------------------------------------
# Topic rules
# ---------------------------------------------------------------------------
diff --git a/tests/test_iot.py b/tests/test_iot.py
index a26e54d6..929999f6 100644
--- a/tests/test_iot.py
+++ b/tests/test_iot.py
@@ -903,6 +903,62 @@ def test_iot_indexing_configuration_rejects_impossible_modes():
] == "OFF"
+_EVENT_TYPES = (
+ "THING", "THING_GROUP", "THING_TYPE", "THING_GROUP_MEMBERSHIP",
+ "THING_GROUP_HIERARCHY", "THING_TYPE_ASSOCIATION", "JOB", "JOB_EXECUTION",
+ "POLICY", "CERTIFICATE", "CA_CERTIFICATE",
+)
+
+
+def _enabled_event_types(client) -> set:
+ configs = client.describe_event_configurations()["eventConfigurations"]
+ assert set(configs) == set(_EVENT_TYPES)
+ return {t for t, c in configs.items() if c["Enabled"]}
+
+
+def test_iot_event_configurations_default_all_disabled():
+ client = _iot_client_for_fresh_account()
+ resp = client.describe_event_configurations()
+ assert resp["eventConfigurations"] == {t: {"Enabled": False} for t in _EVENT_TYPES}
+ assert "creationDate" not in resp and "lastModifiedDate" not in resp
+
+
+def test_iot_update_event_configurations_changes_only_named_types():
+ client = _iot_client_for_fresh_account()
+ client.update_event_configurations(eventConfigurations={"THING": {"Enabled": True}})
+ first = client.describe_event_configurations()
+ assert _enabled_event_types(client) == {"THING"}
+
+ client.update_event_configurations(
+ eventConfigurations={"THING_GROUP": {"Enabled": True}}
+ )
+ assert _enabled_event_types(client) == {"THING", "THING_GROUP"}
+ second = client.describe_event_configurations()
+ assert second["creationDate"] == first["creationDate"]
+ assert second["lastModifiedDate"] >= first["lastModifiedDate"]
+
+ # A type named without Enabled is turned off, as on AWS.
+ client.update_event_configurations(eventConfigurations={"THING": {}})
+ assert _enabled_event_types(client) == {"THING_GROUP"}
+
+
+def test_iot_update_event_configurations_rejects_bad_requests():
+ client = _iot_client_for_fresh_account()
+ with pytest.raises(ClientError) as ei:
+ client.update_event_configurations()
+ assert ei.value.response["Error"]["Code"] == "InvalidRequestException"
+ assert ei.value.response["Error"]["Message"] == "Configuration cannot be null"
+ with pytest.raises(ClientError) as ei:
+ client.update_event_configurations(
+ eventConfigurations={"THING": {"Enabled": True}, "BOGUS": {"Enabled": True}}
+ )
+ assert ei.value.response["Error"]["Code"] == "InvalidRequestException"
+ assert ei.value.response["ResponseMetadata"]["HTTPStatusCode"] == 400
+ # A refused update changes nothing.
+ assert _enabled_event_types(client) == set()
+ assert "creationDate" not in client.describe_event_configurations()
+
+
def test_iot_search_index_requires_indexing_enabled():
"""Searching an account that never enabled indexing is a 404 on AWS."""
client = _iot_client_for_fresh_account()