<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dmitry Frizner</title>
    <description>The latest articles on DEV Community by Dmitry Frizner (@frizner).</description>
    <link>https://dev.to/frizner</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1114106%2F31f322cf-84ca-4193-ae7a-b35a50edfa7d.jpg</url>
      <title>DEV Community: Dmitry Frizner</title>
      <link>https://dev.to/frizner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/frizner"/>
    <language>en</language>
    <item>
      <title>How to route IoT messages across multiple regions with AWS IoT Core and Amazon SNS</title>
      <dc:creator>Dmitry Frizner</dc:creator>
      <pubDate>Wed, 05 Jul 2023 22:45:53 +0000</pubDate>
      <link>https://dev.to/frizner/how-to-route-iot-messages-across-multiple-regions-with-aws-iot-core-and-amazon-sns-12e</link>
      <guid>https://dev.to/frizner/how-to-route-iot-messages-across-multiple-regions-with-aws-iot-core-and-amazon-sns-12e</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this blog, I explain how to route &lt;a href="https://aws.amazon.com/iot-core/" rel="noopener noreferrer"&gt;AWS IoT Core&lt;/a&gt; messages across multiple &lt;a href="https://aws.amazon.com/about-aws/global-infrastructure/regions_az/" rel="noopener noreferrer"&gt;AWS regions&lt;/a&gt; using &lt;a href="https://aws.amazon.com/sns/" rel="noopener noreferrer"&gt;Amazon Simple Notification Service&lt;/a&gt; (Amazon SNS). That is a common pattern when IoT telemetry should be ingested in different geographical regions and shipped to another region for further centralized processing of IoT messages. For instance, when an organization hosts a fleet of devices and collects telemetry in different regions providing lower latency however the collected data across regions should be proceed in one place due to operational or compliance requirements.&lt;/p&gt;

&lt;p&gt;You will learn how to configure &lt;a href="https://docs.aws.amazon.com/iot/latest/developerguide/iot-rules.html" rel="noopener noreferrer"&gt;Rules for AWS IoT&lt;/a&gt; and Amazon SNS for delivering of MQTT messages from one AWS region into &lt;a href="https://aws.amazon.com/sqs/" rel="noopener noreferrer"&gt;Amazon Simple Queue Service&lt;/a&gt; (Amazon SQS) in another region. A suggested approach can be used for cross-region routing of MQTT messages to other AWS services supported as a destination by Amazon SNS as well. A combination of Amazon SNS and Amazon SQS allows you to transfer messages from one AWS account to another also. &lt;/p&gt;

&lt;h2&gt;
  
  
  Solution Overview
&lt;/h2&gt;

&lt;p&gt;In this solution, you will first create an Amazon SNS topic in the data ingestion region and an Amazon SQS queue in the data processing region. Then you will grant permissions for the SNS topic to send messages to the SQS queue and subscribe the SQS queue to the SNS topic. Next, you will create an AWS IoT rule to route MQTT messages to the SNS topic. Lastly, you will test the solution by sending IoT messages to an AWS IoT Core topic and polling them from the SQS Queue in another region.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an Amazon SNS topic called &lt;code&gt;iot-transfer&lt;/code&gt; in the data ingestion region.&lt;/li&gt;
&lt;li&gt;In the data processing region:

&lt;ol&gt;
&lt;li&gt;Create an Amazon SQS queue called &lt;code&gt;iot-data&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Gant permissions for sending messages from the Amazon SNS topic &lt;code&gt;iot-transfer&lt;/code&gt; to the Amazon SQS queue &lt;code&gt;iot-data&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Subscribe the Amazon SQS queue &lt;code&gt;iot-data&lt;/code&gt; to the Amazon SNS topic &lt;code&gt;iot-transfer&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;In the data ingestion region:

&lt;ol&gt;
&lt;li&gt;Create an Identity and Access Management (IAM) Role called &lt;code&gt;iot-sns-allow&lt;/code&gt; with an inline policy that allows publishing to the Amazon SNS topic &lt;code&gt;iot-transfer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create an IoT rule with the IAM role &lt;code&gt;iot-sns-allow&lt;/code&gt; in the ingestion account to route messages from a MQTT topic called &lt;code&gt;dt/transferdata&lt;/code&gt; to the Amazon SNS topic &lt;code&gt;iot-transfer&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Publish messages to the MQTT topic &lt;code&gt;dt/transferdata&lt;/code&gt;.&lt;/li&gt;

&lt;li&gt;Verify a delivery of the messages by polling the messages from the Amazon SQS queue &lt;code&gt;iot-data&lt;/code&gt; in the data processing region.&lt;/li&gt;

&lt;/ol&gt;

&lt;h2&gt;
  
  
  Solution Diagram
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kpo8feyqbmmn1fwasks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kpo8feyqbmmn1fwasks.png" alt="Solution Diagram" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution Instructions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;One ore more AWS accounts.&lt;/li&gt;
&lt;li&gt;Administrator privileges in the accounts.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/cli/" rel="noopener noreferrer"&gt;AWS  Command Line Interface (AWS CLI)&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Command-line JSON processor &lt;a href="https://github.com/jqlang/jq" rel="noopener noreferrer"&gt;jq&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To deploy the solution, I recommend to use &lt;a href="https://aws.amazon.com/cloudshell/" rel="noopener noreferrer"&gt;AWS CloudShell&lt;/a&gt;. &lt;code&gt;AWS CloudShell&lt;/code&gt; has preinstalled &lt;code&gt;AWS CLI&lt;/code&gt; and &lt;code&gt;jq&lt;/code&gt;. Some AWS CLI commands have &lt;code&gt;--query&lt;/code&gt; parameter to filter the output of running command but I found out an usage of &lt;code&gt;jq&lt;/code&gt; utility is more convenient to parse the output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Define variables
&lt;/h3&gt;

&lt;p&gt;Define environment variables that will be used for the solution deployment. Change values of the variables if needed.&lt;/p&gt;

&lt;p&gt;Set up the data ingestion and data processing regions. I use &lt;code&gt;us-east-2&lt;/code&gt; as the data ingestion region and &lt;code&gt;us-west-2&lt;/code&gt; as the data processing region.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS_INGESTION_REGION=us-east-2
AWS_PROCESSING_REGION=us-west-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Define the &lt;code&gt;AWS_ACCOUNT_ID&lt;/code&gt; value with an account number of your AWS account. In case if you use different AWS accounts for the ingestion and processing data, set up the variable with the account number of the data ingestion account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS_ACCOUNT_ID=111111111111
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, define names for a SNS topic, SQS queue, IAM roles for Rules for AWS IoT.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS_SNS_NAME=iot-transfer
AWS_SQS_NAME=iot-data
AWS_SNS_ROLE_NAME=iot-sns-allow
AWS_REPUBLISH_ROLE_NAME=iot-republish-allow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a SNS topic
&lt;/h3&gt;

&lt;p&gt;With the configured AWS CLI create an SNS topic in the data ingestion region and retrieve the TopicArn from the output as a value of a variable. If you use AWS CloudShell, AWS CLI will be configured automatically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SNS_TOPIC_ARN=$(aws sns create-topic \
   --region $AWS_INGESTION_REGION \
   --name $AWS_SNS_NAME | jq -r .TopicArn)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a SQS queue
&lt;/h3&gt;

&lt;p&gt;In the data processing region create a SQS queue with a name defined in the &lt;code&gt;AWS_SQS_NAME&lt;/code&gt; variable and retrieve a &lt;code&gt;QueueUrl&lt;/code&gt; and &lt;code&gt;QueueArn&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SQS_URL=$(aws sqs create-queue \
   --region $AWS_PROCESSING_REGION \
   --queue-name $AWS_SQS_NAME \
   | jq -r .QueueUrl)

SQS_ARN=$(aws sqs get-queue-attributes \
    --region $AWS_PROCESSING_REGION \
    --queue-url $SQS_URL \
    --attribute-names QueueArn \
    | jq -r .Attributes.QueueArn)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Subscribe the SQS queue to the SNS topic and retrieve a &lt;code&gt;SubscriptionArn&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SUBSCRIPTION_ARN=$(aws sns subscribe \
   --region $AWS_INGESTION_REGION \
   --topic-arn $SNS_TOPIC_ARN \
   --protocol sqs \
   --notification-endpoint $SQS_ARN | jq -r .SubscriptionArn)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Grant permissions to the SNS topic sending messages to SQS
&lt;/h3&gt;

&lt;p&gt;In order the SNS topic can send messages into the SQS Queue created in the previous steps, I need to change a resource policy for the SQS queue and allow the &lt;code&gt;sqs:SendMessage&lt;/code&gt; action for the SNS &lt;code&gt;TopicArn&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create a file with the resource policy running the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;gt; policy.json &amp;lt;&amp;lt; EOF
{
  "Id": "SNStoSQSCrossRegion",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "sns.amazonaws.com"
      },
      "Action": "sqs:SendMessage",
      "Resource": "${SQS_ARN}",
      "Condition": {
        "ArnEquals": {
          "aws:SourceArn": "${SNS_TOPIC_ARN}"
        }
      }
    }
  ]
}
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file for SQS attributes and include the resource policy created on the previous step as a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;gt; sqs-attributes.json &amp;lt;&amp;lt; EOF
{
    "Policy": $(jq -Rs . policy.json)
}
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the resource policy of the SQS queue running the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws sqs set-queue-attributes \
    --region $AWS_PROCESSING_REGION \
    --queue-url $SQS_URL \
    --attributes file://sqs-attributes.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create the IAM role and policy for publishing to SNS
&lt;/h3&gt;

&lt;p&gt;To publish to the SNS topic from AWS IoT Core, create an IAM role with a policy allowing the publishing action.&lt;/p&gt;

&lt;p&gt;Create a file named &lt;code&gt;iot-role-trust-policy.json&lt;/code&gt; with a policy allowing to assume the role by &lt;code&gt;iot.amazonaws.com&lt;/code&gt; service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;gt; iot-role-trust-policy.json &amp;lt;&amp;lt;EOF
{
    "Version": "2012-10-17",
    "Statement": [
        {
          "Effect": "Allow",
          "Principal":
               {
                    "Service": "iot.amazonaws.com"
               },
          "Action": "sts:AssumeRole"
        }
     ]
}
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create an IAM role and retrieve a &lt;code&gt;RoleArn&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IOT_ROLE_ARN=$(aws iam create-role \
    --role-name $AWS_SNS_ROLE_NAME \
    --assume-role-policy-document file://iot-role-trust-policy.json \
     | jq -r .Role.Arn)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file with IAM policy allowing the &lt;code&gt;sns:Publish&lt;/code&gt; action to the SNS topic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "sns:Publish",
            "Resource": "${SNS_TOPIC_ARN}"
        }
    ]
}
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Attach the policy to the IAM role.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iam put-role-policy \
     --role-name $AWS_SNS_ROLE_NAME \
     --policy-name iot-sns-policy \
     --policy-document file://allow_send_sns.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create the IAM role and policy for publishing errors to IoT topic
&lt;/h3&gt;

&lt;p&gt;To republish error messages to another MQTT topic with an AWS IoT rule, you will create a role and attach a needed policy to the role.&lt;/p&gt;

&lt;p&gt;Create an AWS IAM role and retrieve a &lt;code&gt;RoleArn&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IOT_REPUBLISH_ROLE_ARN=$(aws iam create-role \
    --role-name $AWS_REPUBLISH_ROLE_NAME \
    --assume-role-policy-document file://iot-role-trust-policy.json \
     | jq -r .Role.Arn)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a policy allowing publishing to the &lt;code&gt;topic/errors&lt;/code&gt; topic and attach the policy to the role created in the previous step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;gt; allow_republish.json &amp;lt;&amp;lt;EOF
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "iot:Publish",
            "Resource": "arn:aws:iot:${AWS_INGESTION_REGION}:${AWS_ACCOUNT_ID}:topic/errors"
        }
    ]
}
EOF
aws iam put-role-policy \
     --role-name $AWS_REPUBLISH_ROLE_NAME \
     --policy-name iot-republish \
     --policy-document file://allow_republish.json

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create an IoT rule in the data ingestion region to evaluate messages and republish errors
&lt;/h3&gt;

&lt;p&gt;Next, create the IoT Rule that will route messages to the SNS topic and republish any messages that encounter an error to a topic named &lt;code&gt;topic/errors&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create a file with the rule definition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat &amp;gt; ing-rule.json &amp;lt;&amp;lt;EOF
{
    "sql": "SELECT * FROM 'dt/transferdata'" ,
    "description": "Publishing of IoT messages to SNS.",
    "awsIotSqlVersion": "2016-03-23",
    "ruleDisabled": false,
    "actions": [{
        "sns": {
            "roleArn": "${IOT_ROLE_ARN}",
            "targetArn": "${SNS_TOPIC_ARN}",
            "messageFormat": "JSON"
        }
    }], 
    "errorAction": {
            "republish": {
                "roleArn": "${IOT_REPUBLISH_ROLE_ARN}",
                "topic": "error/rules",
                "qos": 0
            }
    }
}
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the IoT rule&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iot create-topic-rule \
    --region $AWS_INGESTION_REGION \
    --rule-name "Publishing2SNS" \
    --topic-rule-payload file://ing-rule.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Publish messages in the data ingestion region and verify their delivery to the data processing region
&lt;/h3&gt;

&lt;p&gt;In the data ingestion region run the following command to publish a message into the SNS topic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iot-data publish \
    --region $AWS_INGESTION_REGION \
    --topic dt/transferdata \
    --cli-binary-format raw-in-base64-out \
    --payload '{"Default": "data"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use Default as a field name in a json document in order to follow the message format for Amazon SNS.&lt;/p&gt;

&lt;p&gt;Verify receiving messages in the data processing region.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws sqs receive-message \
    --region $AWS_PROCESSING_REGION \
    --queue-url $SQS_URL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If don’t receive the messages, in the data ingestion region, check the &lt;code&gt;topic/errors&lt;/code&gt; topic in AWS Console with the &lt;a href="https://docs.aws.amazon.com/iot/latest/developerguide/view-mqtt-messages.html" rel="noopener noreferrer"&gt;AWS IoT MQTT client&lt;/a&gt; for error messages related to delivery.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cleaning Up
&lt;/h2&gt;

&lt;p&gt;It is good practice to clean up any resources you no longer want to use. Cleaning up AWS resources prevents your account from incurring any further charges.&lt;/p&gt;

&lt;p&gt;Delete IoT Rule.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iot delete-topic-rule \
    --region $AWS_INGESTION_REGION \
    --rule-name "Publishing2SNS"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unsubscribe the SQS queue from the SNS topic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws sns unsubscribe \
    --region $AWS_INGESTION_REGION \
    --subscription-arn $SUBSCRIPTION_ARN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete the SNS topic and the SQS queue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws sns delete-topic \
    --region $AWS_INGESTION_REGION \
    --topic-arn $SNS_TOPIC_ARN
aws sqs delete-queue \
    --region $AWS_PROCESSING_REGION \
    --queue-url $SQS_URL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete the IAM roles and policies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws iam delete-role-policy \
    --role-name $AWS_SNS_ROLE_NAME \
    --policy-name iot-sns-policy
aws iam delete-role \
    --role-name $AWS_SNS_ROLE_NAME
aws iam delete-role-policy \
    --role-name $AWS_REPUBLISH_ROLE_NAME \
    --policy-name iot-republish
aws iam delete-role \
    --role-name $AWS_REPUBLISH_ROLE_NAME

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this blog I showed you how to route AWS IoT messages from one AWS Region to Amazon SQS in another region. The pattern allows use different AWS regions for ingestion and processing data. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>iot</category>
      <category>sns</category>
      <category>sqs</category>
    </item>
  </channel>
</rss>
