Skip to content

IoT Data Plane

CloudMock emulates the AWS IoT Data Plane, supporting device shadow operations and MQTT message publishing. Device shadows are JSON documents with state (desired/reported), metadata, and version fields. Versions increment on each update, and delta computation between desired and reported state is supported.

OperationStatusNotes
GetThingShadowSupportedReturns shadow document with state, metadata, version, timestamp
UpdateThingShadowSupportedMerges state, increments version, computes delta
DeleteThingShadowSupportedDeletes a shadow document
ListNamedShadowsForThingSupportedLists named shadows (excludes classic shadow)
PublishSupportedStores message to topic (no actual MQTT delivery)
{
"state": {
"desired": { "temp": 72, "mode": "auto" },
"reported": { "temp": 70 },
"delta": { "temp": 72 }
},
"metadata": {},
"version": 3,
"timestamp": 1234567890
}
import { IoTDataPlaneClient, UpdateThingShadowCommand, GetThingShadowCommand } from '@aws-sdk/client-iot-data-plane';
const client = new IoTDataPlaneClient({
endpoint: 'http://localhost:4566',
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
// Update shadow (desired and reported)
await client.send(new UpdateThingShadowCommand({
thingName: 'my-sensor',
payload: JSON.stringify({
state: {
desired: { temp: 72, mode: 'auto' },
reported: { temp: 70 },
}
}),
}));
// Get shadow (includes delta when desired != reported)
const shadow = await client.send(new GetThingShadowCommand({
thingName: 'my-sensor',
}));
const doc = JSON.parse(new TextDecoder().decode(shadow.payload));
console.log('delta:', doc.state.delta); // { temp: 72 }
import boto3
import json
client = boto3.client('iot-data',
endpoint_url='http://localhost:4566',
region_name='us-east-1',
aws_access_key_id='test',
aws_secret_access_key='test')
# Update named shadow
client.update_thing_shadow(
thingName='my-sensor',
shadowName='config',
payload=json.dumps({'state': {'desired': {'interval': 30}}}))
# List named shadows
response = client.list_named_shadows_for_thing(thingName='my-sensor')
print(response['results']) # ['config']
# Publish to topic
client.publish(topic='sensors/temp', payload=b'{"value": 72}', qos=0)
cloudmock.yml
services:
iotdata:
enabled: true
  • Publish does not deliver messages to MQTT subscribers
  • Shadow versioning does not reject stale versions (no version conflict detection)
  • Shadow metadata timestamps are set to creation time, not per-field timestamps