Republish - Amazon IoT Core
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.


The republish (republish) action republishes an MQTT message to another MQTT topic.


This rule action has the following requirements:

  • An IAM role that Amazon IoT can assume to perform the iot:Publish operation. For more information, see Granting Amazon IoT the required access.

    In the Amazon IoT console, you can choose or create a role to allow Amazon IoT to perform this rule action.


When you create an Amazon IoT rule with this action, you must specify the following information:


The MQTT topic to which to republish the message.

To republish to a reserved topic, which begins with $, use $$ instead. For example, to republish to the device shadow topic $aws/things/MyThing/shadow/update, specify the topic as $$aws/things/MyThing/shadow/update.


Republishing to reserved job topics is not supported.

Supports substitution templates: Yes


(Optional) The Quality of Service (QoS) level to use when republishing messages. Valid values: 0, 1. The default value is 0. For more information about MQTT QoS, see MQTT.

Supports substitution templates: No


The IAM role that allows Amazon IoT to publish to the MQTT topic. For more information, see Requirements.

Supports substitution templates: No


The following JSON example defines a republish action in an Amazon IoT rule.

{ "topicRulePayload": { "sql": "SELECT * FROM 'some/topic'", "ruleDisabled": false, "awsIotSqlVersion": "2016-03-23", "actions": [ { "republish": { "topic": "another/topic", "qos": 1, "roleArn": "arn:aws:iam::123456789012:role/aws_iot_republish" } } ] } }

The following JSON example defines a republish action with substitution templates in an Amazon IoT rule.

{ "topicRulePayload": { "sql": "SELECT * FROM 'some/topic'", "ruleDisabled": false, "awsIotSqlVersion": "2016-03-23", "actions": [ { "republish": { "topic": "${topic()}/republish", "roleArn": "arn:aws:iam::123456789012:role/aws_iot_republish" } } ] } }