Rules engine API fails to trigger S3 action for incoming MQTT messages despite valid SQL configuration

Our IoT Rules Engine is not triggering the S3 action when MQTT messages arrive on our data ingestion topic. We’ve configured a rule with SQL statement to filter and route messages, but the S3 bucket remains empty even though devices are publishing successfully.

Rule SQL statement:

SELECT * FROM 'factory/sensors/+/telemetry'
WHERE temperature > 75

The CloudWatch metrics show messages are arriving on the topic, but the S3 action never executes. We suspect either the MQTT payload format is invalid or our SQL statement has syntax issues. This is creating significant data ingestion gaps in our analytics pipeline.

Check your rule’s error action configuration in CloudWatch. When a rule fails to execute, AWS IoT publishes error details to a special topic. Subscribe to $aws/rules/YOUR_RULE_NAME/error to see what’s actually failing. Often it’s an IAM permissions issue where the rule doesn’t have rights to write to your S3 bucket.

Yes, field names in the SQL WHERE clause must exactly match the JSON keys in your MQTT payload. Change your SQL to WHERE temp > 75 to match your actual device data structure. Also, since you’re selecting all fields with SELECT *, make sure your S3 action is configured to handle the complete JSON structure including the timestamp field.

Beyond the field name mismatch, you should also implement proper error handling in your device firmware. If a device publishes invalid JSON, the rule will silently fail for that message. Consider adding a validation step in your device code before publishing, or use a separate rule with no WHERE clause to capture all messages for debugging purposes.