Leaving AWS IoT Core is rarely about the broker alone. A typical account has things and X.509 certificates, IoT policies with ${iot:Connection.Thing.ThingName} variables, a handful of topic rules feeding DynamoDB or Lambda, Device Shadows, and maybe Jobs for OTA updates. The MQTT part is the easy bit. An AWS IoT Core migration is hard because every one of those services needs a replacement owner. Every device also needs a firmware or configuration change before it can talk to another broker.
aws-iot-core-migration-skills turns that work into two AI agent skills with tested scripts. Load them into Claude Code (or any agent that reads SKILL.md skills). The agent can then inventory your AWS IoT setup, convert IoT policies to ConnectMQ access control rules, plan the firmware rollout, run a relay between both brokers and move thing groups one wave at a time. This post walks through what each skill does and why the migration is ordered the way it is.
Why an AWS IoT Core Migration Needs a Plan
On a self-hosted broker you change a hostname and a password. AWS IoT Core differs in several ways:
- Identity is a certificate. Devices authenticate with X.509 client certificates, and most firmware trusts only Amazon Root CA 1. ConnectMQ uses username and password over TLS with a public CA, so every device needs a new root CA and somewhere to store a credential.
- Topics include reserved
$aws/paths. Shadows, Jobs, Basic Ingest and lifecycle events live under$aws/. These have to become ordinary topics, and the new design should be agreed once, because changing it later means another OTA. - The rules engine is a hidden consumer. Every topic rule silently reads data. Turn off AWS before the rule has a replacement and data stops arriving without an error.
- There is no native bridge. AWS IoT Core cannot forward to another broker, so the parallel run needs a client that connects to both sides.
If you are still comparing options, AWS IoT Core alternative covers the trade-offs. The skills assume you have decided to move.
The Planner Skill: Inventory, Sizing and Design
The aws-iot-core-migration-planner skill starts with read-only AWS CLI commands. It records the ATS endpoint, the things and thing groups, every IoT policy (aws iot get-policy) and what each one is attached to, every topic rule and its SQL and actions, a sample of classic and named shadows, and whether Jobs are in use. Then it pulls 30 days of CloudWatch metrics such as Connect.Success, PublishIn.Success and PublishOut.Success to size the workload.
The fit check compares that workload with ConnectMQ plan limits: concurrent connections, session minutes, messages per second per client, the retained-message count you need for shadows, and session expiry. AWS lets a persistent session live up to seven days, while ConnectMQ caps session expiry per plan. Devices that sleep for days should read retained desired state on wake-up instead of waiting for queued messages. AWS caps payloads at 128 KB, so existing payloads already fit ConnectMQ's message size.
Converting IoT Policies to ACL Rules
The policy converter reads raw policy documents or get-policy output and turns each statement into ConnectMQ rules:
python scripts/aws_policy_to_connectmq.py migration/aws/policies/*.json \
--client-map migration/client-map.csv --out migration/
iot:Publishontopic/...becomes a publish rule andiot:Subscribeontopicfilter/...becomes a subscribe rule.- Explicit
Denystatements go first, because in AWS a deny always wins and ConnectMQ evaluates rules in order. ${iot:ClientId}and${iot:Connection.Thing.ThingName}become one rule per thing when you pass the client map, so your topics keep the thing names. Without the map they become${clientid}, with a warning that the value is now the full ConnectMQ client ID.- Policy wildcards (
*,?) are translated to#and+where possible, with a warning when the result is broader. Conditionblocks,iot:Receive, thing-attribute variables and$aws/service topics are listed as notes for review instead of being silently dropped.
The output is a numbered rule table to enter in the ConnectMQ console. For rule design background, see MQTT ACL.
Redesigning Shadows and Reserved Topics
The planner writes a topic map before any firmware is touched. The default replaces Device Shadow with two retained topics per thing. The device publishes things/<thing>/shadow/reported and subscribes to things/<thing>/shadow/desired, which the backend publishes retained. Basic Ingest topics lose their $aws/rules/<rule>/ prefix, Jobs move to your own things/<thing>/jobs/... topics, and presence comes from a Last Will on a status topic. The pattern is explained in digital twin state with retained MQTT messages and MQTT retained messages.
Each topic rule gets a replacement: usually a backend service with a shared subscription that applies the rule's SQL filter in code and still writes to DynamoDB, Timestream or S3 if the data stays in AWS.
Planning the Firmware in Two Steps
Because devices must trust a new CA and store a credential, the planner splits the rollout. Step one ships while devices still run on AWS: add the ConnectMQ root CA and credential storage. Step two switches endpoint, credentials, client ID (<ISSUED_ID>_<thing>) and topics, one thing group at a time. If step one fails on a device, nothing has changed for that device yet.
The Executor Skill: Relay, State and Waves
The aws-iot-core-migration-executor skill follows the plan and asks before each production change. It logs every step to migration/log.md.
A Least-Privilege Relay Thing
The executor creates a dedicated connectmq-relay thing with its own certificate and a policy that only allows what the relay needs: connect as itself, subscribe to and receive the forward topics, and publish the reverse topics. Then it runs relay.py:
python scripts/relay.py \
--source mqtts://<prefix>-ats.iot.eu-west-1.amazonaws.com:8883 --source-client-id connectmq-relay \
--source-cafile AmazonRootCA1.pem --source-cert relay.cert.pem --source-key relay.private.key \
--target mqtts://BROKER_HOST:8883 --forward 'dt/#' --reverse 'cmd/#'
Telemetry from devices still on AWS reaches ConnectMQ, and commands from backends already on ConnectMQ reach those devices. Forward and reverse filters are checked for overlap so messages cannot loop. Sites that already run Mosquitto can use a two-bridge Mosquitto hub instead, and the reference includes that configuration.
Moving Shadow State
aws_shadows_to_retained.py reads classic and named shadows, from saved files or live through the AWS CLI with --fetch. It writes them as retained messages under things/<thing>/shadow/reported and .../desired, and copy_retained.py publishes the file to ConnectMQ, warning if the count exceeds your plan's retained limit. While devices are split between brokers, the copy can run on a schedule so ConnectMQ consumers always see current state.
Waves with a Real Rollback Lever
Backends move first and run in shadow mode next to the AWS rules for at least a day. Then thing groups switch, triggered by your OTA system or an AWS IoT Job that points each device at its own credential (never a password in a job document). Device certificates stay active until a wave has soaked. A device that cannot reach ConnectMQ can fall back to its previous configuration, and the relay keeps data flowing either way. Throughout, the executor watches for reason codes such as 0x85 (client ID without the issued prefix), 0x86 (bad credentials) and TLS failures from firmware that still trusts only Amazon's CA.
Decommissioning is deliberately slow. Rules are disabled before they are deleted, certificates are deactivated per thing group while CloudWatch confirms connections have stopped, and nothing is deleted before the rollback window ends.
Installing the Skills
/plugin marketplace add connectmq/aws-iot-core-migration-skills
/plugin install aws-iot-core-migration-skills@connectmq-aws-iot-core-migration
You can also copy the skills/ folders into ~/.claude/skills/, or zip a skill folder and upload it to Claude.ai. The converters use only the Python standard library; the MQTT scripts need paho-mqtt 2.x. Nothing calls AWS unless you run the inventory commands or --fetch with your own credentials.
Try prompts like "Plan a move of our 600 AWS IoT devices to ConnectMQ" or "Convert these IoT policies to ConnectMQ rules".
The collection also covers HiveMQ, Mosquitto, EMQX, VerneMQ and Azure IoT Hub. For what you get on the other side, read managed MQTT broker.
Frequently Asked Questions
Can ConnectMQ use my existing AWS IoT device certificates?
No. ConnectMQ authenticates devices with username and password over TLS, and the server certificate chains to a public CA instead of Amazon Root CA. That is why the planner schedules a first firmware step that adds the new root CA and credential storage while devices are still on AWS. If you want to understand what you give up, see MQTT mTLS.
What replaces AWS IoT Device Shadow?
Retained MQTT messages. Each thing gets a retained reported topic written by the device and a retained desired topic written by the backend, and the device works out the difference itself. Existing shadow documents are copied once with aws_shadows_to_retained.py, and on a schedule while devices are split between brokers.
What happens to my AWS IoT rules?
Each rule gets a replacement owner in the plan, usually a small backend service that subscribes with a shared subscription and writes to the same targets. Rules stay enabled until the replacement has run in parallel and produced the same output, and they are disabled before they are deleted.
Do I have to move all devices at once?
No. The relay keeps AWS IoT Core and ConnectMQ connected, so thing groups move in waves while the rest stay on AWS. Device certificates stay active until each wave has soaked, which keeps rollback a configuration change rather than a recovery project.
Is the code open source?
Yes. The skills and scripts are MIT licensed on GitHub. Issues and pull requests with policy constructs or AWS features the converter does not handle yet are welcome.



