Skip to content

Commit b6615b4

Browse files
graebmbretambrose
andauthored
All V2 SDK samples can share policies. (#84)
* All V2 SDK samples can share policies. * client id permissions policy updates within sample README Co-authored-by: Bret Ambrose <[email protected]>
1 parent e6ac456 commit b6615b4

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ sudo apt-get install libssl-dev
5656

5757
[Samples README](samples)
5858

59-
60-
6159
## Getting Help
6260

6361
Use the following sources for information :
@@ -67,8 +65,6 @@ Use the following sources for information :
6765

6866
If you still can’t find a solution to your problem open an [issue](https://github.com/aws/aws-iot-device-sdk-python-v2/issues)
6967

70-
71-
7268
## Giving Feedback and Contributions
7369

7470
We need your help in making this SDK great. Please participate in the community and contribute to this effort by submitting issues, participating in discussion forums and submitting pull requests through the following channels.
@@ -92,7 +88,6 @@ and [Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html)
9288
is provided by code that been generated from a model of the service.
9389

9490

95-
9691
# License
9792

9893
This library is licensed under the Apache 2.0 License.

samples/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ and receive.
3535
"iot:Receive"
3636
],
3737
"Resource": [
38-
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/samples/test"
38+
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/test/topic"
3939
]
4040
},
4141
{
@@ -44,7 +44,7 @@ and receive.
4444
"iot:Subscribe"
4545
],
4646
"Resource": [
47-
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/samples/test"
47+
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/test/topic"
4848
]
4949
},
5050
{
@@ -53,7 +53,7 @@ and receive.
5353
"iot:Connect"
5454
],
5555
"Resource": [
56-
"arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id"
56+
"arn:aws:iot:<b>region</b>:<b>account</b>:client/test-*"
5757
]
5858
}
5959
]
@@ -138,7 +138,7 @@ and receive.
138138
{
139139
"Effect": "Allow",
140140
"Action": "iot:Connect",
141-
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id"
141+
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/test-*"
142142
}
143143
]
144144
}
@@ -223,7 +223,7 @@ and receive.
223223
{
224224
"Effect": "Allow",
225225
"Action": "iot:Connect",
226-
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id"
226+
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/test-*"
227227
}
228228
]
229229
}
@@ -291,7 +291,7 @@ and receive.
291291
{
292292
"Effect": "Allow",
293293
"Action": "iot:Connect",
294-
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id"
294+
"Resource": "arn:aws:iot:<b>region</b>:<b>account</b>:client/test-*"
295295
}
296296
]
297297
}

samples/basic_discovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
parser.add_argument('-c', '--cert', action='store', required=True, dest='certificate_path', help='Certificate file path')
2020
parser.add_argument('-k', '--key', action='store', required=True, dest='private_key_path', help='Private key file path')
2121
parser.add_argument('-n', '--thing-name', action='store', required=True, dest='thing_name', help='Targeted thing name')
22-
parser.add_argument('-t', '--topic', action='store', dest='topic', default='sdk/test/Python', help='Targeted topic')
22+
parser.add_argument('-t', '--topic', action='store', dest='topic', default='test/topic', help='Targeted topic')
2323
parser.add_argument('-m', '--mode', action='store', dest='mode', default='both',
2424
help='Operation modes: %s'%str(allowed_actions))
2525
parser.add_argument('-M', '--message', action='store', dest='message', default='Hello World!',

samples/fleetprovisioning.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import threading
1313
import time
1414
import traceback
15+
from uuid import uuid4
1516
import json
1617

1718
# - Overview -
@@ -35,7 +36,7 @@
3536
parser.add_argument('--root-ca', help="File path to root certificate authority, in PEM format. " +
3637
"Necessary if MQTT server uses a certificate that's not already in " +
3738
"your trust store")
38-
parser.add_argument('--client-id', default='samples-client-id', help="Client ID for MQTT connection.")
39+
parser.add_argument('--client-id', default="test-" + str(uuid4()), help="Client ID for MQTT connection.")
3940
parser.add_argument('--use-websocket', default=False, action='store_true',
4041
help="To use a websocket instead of raw mqtt. If you " +
4142
"specify this option you must specify a region for signing, you can also enable proxy mode.")

samples/jobs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import threading
1313
import time
1414
import traceback
15+
from uuid import uuid4
1516

1617
# - Overview -
1718
# This sample uses the AWS IoT Jobs Service to receive and execute operations
@@ -42,7 +43,7 @@
4243
parser.add_argument('--root-ca', help="File path to root certificate authority, in PEM format. " +
4344
"Necessary if MQTT server uses a certificate that's not already in " +
4445
"your trust store")
45-
parser.add_argument('--client-id', default='samples-client-id', help="Client ID for MQTT connection.")
46+
parser.add_argument('--client-id', default="test-" + str(uuid4()), help="Client ID for MQTT connection.")
4647
parser.add_argument('--thing-name', required=True, help="The name assigned to your IoT Thing")
4748
parser.add_argument('--job-time', default=5, type=float, help="Emulate working on job by sleeping this many seconds.")
4849
parser.add_argument('--use-websocket', default=False, action='store_true',

samples/pubsub.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import sys
1010
import threading
1111
import time
12+
from uuid import uuid4
1213

1314
# This sample uses the Message Broker for AWS IoT to send and receive messages
1415
# through an MQTT connection. On startup, the device connects to the server,
@@ -24,8 +25,8 @@
2425
parser.add_argument('--root-ca', help="File path to root certificate authority, in PEM format. " +
2526
"Necessary if MQTT server uses a certificate that's not already in " +
2627
"your trust store.")
27-
parser.add_argument('--client-id', default='samples-client-id', help="Client ID for MQTT connection.")
28-
parser.add_argument('--topic', default="samples/test", help="Topic to subscribe to, and publish messages to.")
28+
parser.add_argument('--client-id', default="test-" + str(uuid4()), help="Client ID for MQTT connection.")
29+
parser.add_argument('--topic', default="test/topic", help="Topic to subscribe to, and publish messages to.")
2930
parser.add_argument('--message', default="Hello World!", help="Message to publish. " +
3031
"Specify empty string to publish nothing.")
3132
parser.add_argument('--count', default=10, type=int, help="Number of messages to publish/receive before exiting. " +

samples/shadow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import sys
1212
import threading
1313
import traceback
14+
from uuid import uuid4
1415

1516
# - Overview -
1617
# This sample uses the AWS IoT Device Shadow Service to keep a property in
@@ -39,7 +40,7 @@
3940
parser.add_argument('--root-ca', help="File path to root certificate authority, in PEM format. " +
4041
"Necessary if MQTT server uses a certificate that's not already in " +
4142
"your trust store")
42-
parser.add_argument('--client-id', default='samples-client-id', help="Client ID for MQTT connection.")
43+
parser.add_argument('--client-id', default="test-" + str(uuid4()), help="Client ID for MQTT connection.")
4344
parser.add_argument('--thing-name', required=True, help="The name assigned to your IoT Thing")
4445
parser.add_argument('--shadow-property', default="color", help="Name of property in shadow to keep in sync")
4546
parser.add_argument('--use-websocket', default=False, action='store_true',

0 commit comments

Comments
 (0)