Files
floci/docs/services/iot.md
T
Mario Toffia 9220c057b7 feat(iot): domain configurations (#3008)
* feat(iot): add the domain configuration model and service

Stores AWS IoT Core domain configurations the way the API reports them:
a new configuration is ENABLED and CUSTOMER_MANAGED (ENDPOINT without a
domain name), carries one VALID server certificate, the default TLS
policy and an ARN with the short id AWS appends. Update changes the
status, authorizer, TLS, certificate and protocol settings; delete
refuses an ENABLED configuration, as AWS does; list filters by service
type and pages with marker and pageSize. Tags work on the ARN.

* feat(iot): serve the domain configuration API

Adds the REST-JSON routes CreateDomainConfiguration,
DescribeDomainConfiguration, UpdateDomainConfiguration,
DeleteDomainConfiguration and ListDomainConfigurations under
/domainConfigurations, registered with the IoT service so the
X-Amzn-Errortype header is set for unsigned callers too. Tags on a
configuration ARN go through IotTagHandler; the IoT /untag route now
uses the same handler as /tags instead of calling IotService directly.
DescribeEndpoint accepts iot:CredentialProvider, the endpoint type
that pairs with the CREDENTIAL_PROVIDER service type.

* feat(iot): provision AWS::IoT::DomainConfiguration

Adds IotDomainConfigurationCfnProvisioner over the domain configuration
service. Ref is the configuration name; Fn::GetAtt Arn, DomainType and
ServerCertificates resolve to what DescribeDomainConfiguration reports
(ServerCertificates as a JSON string, since attributes are strings).

Like the CloudFormation handler, a configuration is created ENABLED and
a DomainConfigurationStatus of DISABLED is applied with a follow-up
update; tags go through TagResource and are reconciled on update; a
delete disables the configuration first because the API refuses to
delete an ENABLED one. UpdateStack keeps the configuration when the
createOnly properties (DomainName, ServiceType, ValidationCertificateArn,
ServerCertificateArns) are unchanged and replaces it otherwise, with a
fresh generated name when the template names none.

Inventory TSV, fixture wiring and the generated resource-type table
updated.

* docs(iot): describe domain configurations and add the stack integration test

IotDomainConfigurationCfnIntegrationTest provisions the type through a
stack and asserts Ref and every Fn::GetAtt attribute against
DescribeDomainConfiguration, the in-place status update, and that
DeleteStack removes the configuration.

* test(iot): cover domain configurations in the Java and Go SDK suites

Both cases create, describe, list, update and delete a configuration
through the real SDK clients and check the AWS error types on the
duplicate create, the refused delete of an ENABLED configuration and
the describe after deletion.

* fix(iot): remove a renamed domain configuration and keep the status when the template omits it

A template that changes DomainConfigurationName creates the new
configuration and now removes the previous one, as the generated-name
replacement already did; before, the old configuration outlived the
stack. An update without DomainConfigurationStatus no longer forces
ENABLED: the field is omitted and the current status stays, as the AWS
handler does.

The service rejects a structured JSON value where a string, boolean,
list or object is expected instead of turning it into an empty string
or silently clearing the authorizer, and validates the whole update
before touching the stored record.

* fix(iot): let stack rollback remove a domain configuration and make same-name creates atomic

A configuration created by a stack is recorded, with the owned marker,
before the follow-up status update, so a failure there still lets the
create rollback delete it. A replacement that fails after the new
configuration exists removes it again, re-enables the previous one if
it had been disabled on the way out, and marks the resource restored,
as the other provisioners do.

CreateDomainConfiguration checks and stores the name in one step, so
two overlapping creates of the same name cannot both succeed. A tags
value that is not a list is rejected. The Java SDK compatibility case
looks for a leftover configuration instead of swallowing every cleanup
exception.

* fix(iot): point the resource back at the prior domain configuration after a failed replacement

After the unwind removes the replacement and re-enables the previous
configuration, the resource now carries the previous name and
attributes again, without the owned marker, so it describes the
configuration that is still there rather than the one just removed.

* feat(iot): serve the AWS-managed domain configurations

Every AWS account has iot:Data-ATS, iot:Data, iot:CredentialProvider
and iot:Jobs without creating them. They now exist in every region on
first use: AWS_MANAGED, ENABLED, no server certificate, and the address
DescribeEndpoint returns as their domain name. They can be updated and
tagged like any other configuration, but not deleted, as on AWS. A
client that starts by describing iot:Data-ATS gets an answer instead of
a 404.

* fix(iot): report a failed replacement cleanup as a rollback failure

When the unwind of a failed replacement cannot remove the new domain
configuration, the resource now carries the rollback-failure marker
with the reason, so the stack ends in UPDATE_ROLLBACK_FAILED instead of
reporting a clean rollback while the configuration is still there. The
marker moves next to the restored one in CfnRollback so extracted
provisioners can set it; the legacy provisioner keeps its alias.

* fix(iot): serialise every read-modify-write on a domain configuration

Update, delete, tag and untag read a record, change it and write it
back. Two overlapping writers lost each other's changes: sixteen tag
writers on one configuration left seven keys. All of them now run under
the lock the create already used, and a test pins the invariant. A JSON
round trip with the mapper setup persistent storage uses pins that the
model reloads intact.

* fix(iot): keep the prior status the unwind compares against and never delete a same-name replacement

The store hands out its live record, so disabling the prior on the way
to deleting it changed the very object the unwind later compared
against, and a prior whose delete failed half way was left DISABLED
while the stack reported a clean rollback. The status seen at the start
is now kept and used. The test reproduces the aliasing instead of
handing the provisioner a fresh copy per call.

A replacement under the same explicit name normally fails on the
create; if it goes through because the prior vanished in between, the
prior is no longer deleted, which would have removed the configuration
just created.

* fix(iot): tolerate a domain configuration that vanishes while a stack delete disables it

The disable that precedes the delete now treats ResourceNotFoundException
as already deleted, the way the delete itself does. The SDK cases also
enable an already ENABLED configuration, the call a client makes when
it only wants to be sure the configuration is on.
2026-09-04 01:05:21 -05:00

12 KiB

AWS IoT Core

Floci's IoT service emulates the AWS IoT Core control plane, IoT Data shadow APIs, and MQTT data-plane behavior used by local device and SDK tests.

MVP 1 Coverage

Status: complete for the local emulator slice.

Supported MVP 1 behavior:

  • Thing CRUD with idempotent identical CreateThing, duplicate-conflict semantics, UpdateThing.expectedVersion, and list pagination.
  • Certificate basics: CreateKeysAndCertificate, CreateCertificateFromCsr, DescribeCertificate, ListCertificates, UpdateCertificate, and DeleteCertificate with active/attached delete constraints.
  • Policy basics: CreatePolicy, GetPolicy, ListPolicies, DeletePolicy, policy version lifecycle, AttachPolicy, DetachPolicy, ListAttachedPolicies, and ListTargetsForPolicy.
  • Thing principal basics: AttachThingPrincipal, DetachThingPrincipal, ListThingPrincipals, and ListPrincipalThings.
  • Tags for things, certificates, policies, and topic rules.
  • IoT Data retained messages: retained Publish, GetRetainedMessage, and paginated ListRetainedMessages.
  • Shadow null-delete and version-conflict behavior for HTTP and shared service paths.
  • Topic rule duplicate/delete/replace semantics, plus republish, sqs, sns, s3, dynamoDBv2, kinesis, and lambda action dispatch.

Current MVP 1 limitations:

  • Certificate CSR handling creates emulator-local certificates; it does not perform real CA signing.
  • MQTT auth remains permissive; certificate and policy resources are modeled for provisioning compatibility, not enforced as broker authorization yet.
  • Rules support basic topic filter extraction and action dispatch only; SQL projection, WHERE evaluation, substitutions, and error actions remain follow-up scope.

MVP 2 Coverage

Status: implemented for the current SDK compatibility slice.

Supported MVP 2 behavior:

  • Thing types: CreateThingType, DescribeThingType, ListThingTypes, UpdateThingType, DeprecateThingType, and DeleteThingType with typed CreateThing association and in-use delete protection.
  • Static thing groups: CreateThingGroup, DescribeThingGroup, ListThingGroups, UpdateThingGroup, DeleteThingGroup, AddThingToThingGroup, RemoveThingFromThingGroup, ListThingsInThingGroup, and ListThingGroupsForThing.
  • Jobs control plane: CreateJob, DescribeJob, and ListJobs, including thing ARN targets and static thing group targets.
  • Jobs data plane: pending-job listing, StartNextPendingJobExecution, DescribeJobExecution, and UpdateJobExecution with version conflicts and terminal-state checks.
  • Endpoint discovery accepts iot:Jobs and iot:CredentialProvider in addition to IoT Data endpoint types.
  • MQTT clients can use QoS 1 subscribe/publish paths with broker PUBACK and delivery behavior.
  • IoT Data connection APIs for live MQTT sessions: GetConnection, DeleteConnection, ListSubscriptions, and SendDirectMessage.
  • DeleteConnection closes active MQTT client sessions through the embedded broker and optionally purges broker session state for cleanSession=true.
  • IoT rules can dispatch matching payloads to SQS, SNS, S3, DynamoDB v2, Kinesis, Lambda, and MQTT republish targets.

Current MVP 2 limitations:

  • DeleteConnection.preventWillMessage is accepted for SDK request compatibility, but the embedded broker does not expose selective Last Will suppression.
  • HTTP IoT Data Publish still treats QoS and MQTT5 metadata as compatibility inputs only; those properties are not fully forwarded or persisted yet.
  • SendDirectMessage publishes to the requested MQTT topic through the embedded broker. Unlike AWS IoT Core, it does not yet bypass subscription matching to deliver to a client that is not subscribed to that topic.
  • GetConnection and ListSubscriptions report live in-memory broker state only; offline persistent session subscription reporting is not modeled yet.
  • Jobs reserved MQTT topics remain follow-up scope; Jobs Data HTTP APIs are implemented first.
  • Dynamic thing groups, fleet indexing, job rollouts, cancellations, documents from S3, and advanced job scheduling are not yet modeled.

Domain Configurations

Status: control plane only.

CreateDomainConfiguration, DescribeDomainConfiguration, UpdateDomainConfiguration, DeleteDomainConfiguration and ListDomainConfigurations are served on the REST-JSON paths the AWS SDKs use, with the AWS shapes and error codes:

  • A new configuration is ENABLED and CUSTOMER_MANAGED, its server certificate is reported VALID, and its ARN carries the short id AWS appends (domainconfiguration/<name>/<id>). A configuration created without a domain name has the ENDPOINT domain type.
  • UpdateDomainConfiguration changes the status, the authorizer (or removes it with removeAuthorizerConfig), the TLS, server certificate and client certificate settings, the authentication type and the application protocol.
  • DeleteDomainConfiguration refuses an ENABLED configuration with InvalidRequestException; disable it first, as on AWS.
  • ListDomainConfigurations filters by serviceType and pages with marker and pageSize.
  • Tags work through TagResource, UntagResource and ListTagsForResource on the configuration ARN.
  • CloudFormation provisions AWS::IoT::DomainConfiguration through the same operations; see the CloudFormation service page for the attribute list.
  • The four AWS-managed configurations every account has (iot:Data-ATS, iot:Data, iot:CredentialProvider, iot:Jobs) exist in every region without being created: AWS_MANAGED, ENABLED, no server certificate, and the address DescribeEndpoint returns as their domain name. They can be updated and tagged but not deleted, as on AWS.

Current limitations:

  • A custom domain does not change where the broker listens. DescribeEndpoint keeps returning Floci's own address, and pointing DNS at the emulator is outside its scope.
  • Server certificate ARNs are stored as given and reported VALID; they are not checked against ACM.

MQTT Broker

Status: complete.

Floci uses Vert.x MQTT as the embedded MQTT protocol server. IotMqttBrokerService owns the broker lifecycle, live session registry, subscription registry, MQTT fan-out, and the bridge into IoT service behavior.

Broker scope:

  • Target real AWS IoT/device SDK style MQTT clients, not only handcrafted packet tests.
  • Support MQTT v3 and MQTT 5 CONNECT handling used by local compatibility tests.
  • Support QoS 0 and QoS 1 publish/subscribe behavior for the local AWS IoT slice.
  • Keep MQTT plaintext-only for this phase; TLS and mTLS are out of scope.
  • Keep MQTT authorization permissive for now, but leave room for a later pluggable IoT certificate and policy authorizer.
  • Keep MQTT broker logging minimal.
  • Validate the relevant IoT compatibility tests against the native binary before considering the phase complete.

Reserved Topics

AWS IoT reserved topics such as $aws/things/{thingName}/shadow/update are service control topics, not ordinary application topics. Floci should handle these publishes by invoking IoT shadow behavior and then publishing the AWS-compatible response topics through the broker.

Required phase 7 reserved-topic behavior:

  • Classic unnamed shadows: $aws/things/{thingName}/shadow/update, get, and delete.
  • Named shadows: $aws/things/{thingName}/shadow/name/{shadowName}/update, get, and delete.
  • Shadow response topics: accepted, rejected, documents, and delta where applicable.
  • Basic Ingest and Jobs topic families are desired follow-up scope, but should not block restoring the broker unless explicitly pulled into the implementation phase.

Reserved request topics are handled by Floci before normal MQTT fan-out. The original $aws/... request publish is not routed as an application message; generated accepted, rejected, documents, and delta responses are published back through IotMqttBrokerService.publish(...) so matching MQTT subscribers receive broker-native messages.

Implementation notes:

  • Vert.x MQTT handles the wire protocol and connection lifecycle.
  • Floci-owned session, subscription, and retained-message state drives local AWS IoT compatibility behavior.
  • Normal client publishes call IotService.publish(...) so retained-message storage, event recording, and rule evaluation remain service-owned.
  • Internal broker publishes fan out only to MQTT subscribers and do not recursively evaluate IoT topic rules.

Current accepted limitation:

  • Certificate and policy authorization are not enforced at the broker layer yet.
  • Persistent offline sessions are not modeled yet.
  • QoS 2 and advanced MQTT 5 property semantics remain follow-up scope.

Implementation Shape

The MQTT integration should keep service behavior separated from broker mechanics:

  • IotMqttBrokerService owns Vert.x MQTT lifecycle and broker-native publish helpers.
  • The broker publish handler detects AWS IoT reserved topics.
  • IoT reserved-topic handling lives in IoT service code or a focused reserved-topic handler, not in packet parsing code.
  • AWS-generated shadow responses are published back through IotMqttBrokerService.publish(...) so regular MQTT subscribers receive broker-native messages.

Phase 7 Completion Criteria

Phase 7 completion criteria:

  • Vert.x MQTT is the active MQTT broker implementation.
  • Reserved shadow topics are handled from the broker publish handler.
  • AWS-generated shadow responses are published through the broker service, not by manually writing MQTT packets.
  • MQTT 5 CONNECT and publish/subscribe behavior are covered by automated tests.
  • Classic unnamed shadow MQTT topics are covered by automated tests.
  • Named shadow MQTT topics are covered by automated tests.
  • Relevant IoT compatibility tests pass against the native binary.

Rules Engine

Status: complete for the MVP 2 action slice.

Phase 8 adds stored IoT topic rules and dispatches matching IoT publishes to rule actions.

Supported rule behavior:

  • CreateTopicRule, GetTopicRule, ListTopicRules, EnableTopicRule, DisableTopicRule, and DeleteTopicRule through AWS SDK-compatible IoT control-plane paths.
  • SQL topic filter extraction for rules shaped like SELECT * FROM 'topic/filter'.
  • MQTT-style topic filter matching for exact topics, +, and terminal #.
  • IoT Data Publish and MQTT publishes use the same rule dispatch path.
  • Rule matching is region-scoped: an IoT Data Publish evaluates the rules of the region named by its SigV4 credential, and a rule's actions target the rule's own region.
  • Publishes that carry no region — MQTT, or an IoT Data Publish whose Authorization header is absent or not SigV4 — are evaluated against every region's rules.
  • republish action republishes the original payload to another MQTT topic through IotMqttBrokerService.
  • sqs action sends the original payload to an SQS queue through Floci's SQS service boundary.
  • sns action publishes the original payload to an SNS topic through Floci's SNS service boundary.
  • s3 action writes the original payload to the configured bucket/key through Floci's S3 service boundary.
  • dynamoDBv2 action writes JSON object payload fields as DynamoDB attribute values through Floci's DynamoDB service boundary.
  • kinesis action puts the original payload into a Kinesis stream through Floci's Kinesis service boundary.
  • lambda action invokes the configured function ARN through Floci's Lambda service boundary.

Current limitations:

  • SQL projection, WHERE clauses, functions, substitutions, error actions, and less common AWS IoT rule action types are follow-up scope.

Open follow-up scope for phase 7 unless explicitly deferred:

  • Basic Ingest topics under $aws/rules/....
  • AWS IoT Jobs reserved topics and required job lifecycle behavior.