Skip to content

Commit 51d4838

Browse files
author
Microchip Technology
committed
MCU8MASS-256:Added a modified JSON policy file and updated the tutorial to reflect the provitioning tool changes.;MCU8MASS-256:Improved instructions for updating policy document.;MCU8MASS-256:Minor text update.;MCU8MASS-256:Replaced hardcoded resource ID with placeholder.;
1 parent 9f91751 commit 51d4838

File tree

1 file changed

+45
-0
lines changed
  • your-first-application-sending-and-receiving-data

1 file changed

+45
-0
lines changed

your-first-application-sending-and-receiving-data/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Links to software and other useful tools and guides are provided in the [Resourc
2626
- [Table of Contents](#table-of-contents)
2727
- [A Brief Introduction to the Firmware of the IoT Boards](#a-brief-introduction-to-the-firmware-of-the-iot-boards)
2828
- [Implementing the Example Application](#implementing-the-example-application)
29+
- [Step 0: Update the AWS IoT Core Policy](#step-0-update-the-aws-iot-core-policy)
2930
- [Step 1: Start With an Unmodified Version of the Github Project](#step-1-start-with-an-unmodified-version-of-the-github-project)
3031
- [Step 2: Sending MQTT Messages to the Cloud](#step-2-sending-mqtt-messages-to-the-cloud)
3132
- [Procedures for AVR-IoT Boards](#procedures-for-avr-iot-boards)
@@ -62,6 +63,50 @@ In this example, we will demonstrate how devices can be configured to send and r
6263

6364
![Flowchart showing how information flows in the first example](figures/embedded_and_cloud_connectivity_flowchart.svg)
6465

66+
### Step 0: Update the AWS IoT Core Policy
67+
In the [previous tutorial](../connect-the-board-to-your-aws-account), we provisioned the IoT boards using the [IoT Provisioning Tool](http://www.microchip.com/mymicrochip/filehandler.aspx?ddocname=en1001525). This generated an AWS IoT Core Policy that determines which permissions the boards have when they interact with AWS resources. By default, this policy is configured to only grant an IoT board the right to publish and subscribe to MQTT topics containing the board's thing name.
68+
69+
In this tutorial, we will send and receive MQTT messages over the `buttonPresses` topic. We must, therefore, expand the permissions to also include this topic:
70+
71+
1. Open the [IoT Core](https://us-east-2.console.aws.amazon.com/iot/home) module in AWS and select **Secure -> Policies** in the menu on the left-hand side.
72+
2. Open **zt_policy** and scroll down to the **Policy document** section.
73+
3. Click **Edit policy document** and perform the changes described below.
74+
1. Update the `iot:Publish` and `iot:Receive` permissions to include the `buttonPresses` topic, as shown below. Note that `############` in the code below is a placeholder for your unique AWS resource identifier. Remember to replace this with the identifier found in your original policy document.
75+
76+
```json
77+
{
78+
"Effect": "Allow",
79+
"Action": [
80+
"iot:Publish",
81+
"iot:Receive"
82+
],
83+
"Resource": [
84+
"arn:aws:iot:us-east-2:############:topic/${iot:Connection.Thing.ThingName}/*",
85+
"arn:aws:iot:us-east-2:############:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/*",
86+
"arn:aws:iot:us-east-2:############:topic/buttonPresses"
87+
]
88+
},
89+
```
90+
91+
2. Update the `iot:Subscribe` permissions to include the `buttonPresses` topic, as shown below. Replace `############` with the identifier found in your original policy document.
92+
93+
```json
94+
{
95+
"Effect": "Allow",
96+
"Action": [
97+
"iot:Subscribe"
98+
],
99+
"Resource": [
100+
"arn:aws:iot:us-east-2:############:topicfilter/${iot:Connection.Thing.ThingName}/*",
101+
"arn:aws:iot:us-east-2:############:topicfilter/$aws/things/${iot:Connection.Thing.ThingName}/shadow/*",
102+
"arn:aws:iot:us-east-2:############:topicfilter/buttonPresses"
103+
]
104+
},
105+
```
106+
4. Click **Save as new version**.
107+
108+
The permissions have now been updated, and the board should be able to send and receive data over the `buttonPresses` MQTT topic.
109+
65110
### Step 1: Start With an Unmodified Version of the Github Project
66111

67112
The starting point for this example is an unmodified copy of the GitHub project compatible with your device's microcontroller family:

0 commit comments

Comments
 (0)