Skip to content

Commit 83b6e9d

Browse files
graebmbretambrose
andauthored
All V2 SDK samples can share policies. (#63)
* All V2 SDK samples can share policies. * Update against new split READMEs Co-authored-by: Bret Ambrose <[email protected]>
1 parent c13e5ed commit 83b6e9d

File tree

5 files changed

+20
-23
lines changed

5 files changed

+20
-23
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ This SDK is built on the AWS Common Runtime, a collection of libraries
1212
cross-platform, high-performance, secure, and reliable. The libraries are bound
1313
to JS by the [awscrt](https://github.com/awslabs/aws-crt-nodejs) package.
1414

15-
1615
*__Jump To:__*
1716
* [Installation](#Installation)
1817
* [Samples](samples)
@@ -48,7 +47,6 @@ npm install
4847
[Samples README](samples)
4948

5049

51-
5250
## Getting Help
5351

5452
Use the following sources for information :
@@ -84,7 +82,6 @@ and [Jobs](https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html)
8482
is provided by code that been generated from a model of the service.
8583

8684

87-
8885
# License
8986

9087
This library is licensed under the Apache 2.0 License.

samples/README.md

Lines changed: 3 additions & 3 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
]

samples/node/basic_discovery/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ yargs.command('*', false, (yargs: any) => {
3838
alias: 't',
3939
description: 'STRING: Targeted topic',
4040
type: 'string',
41-
default: 'sdk/test/NodeJSv2'
41+
default: 'test/topic'
4242
})
4343
.option('mode', {
4444
alias: 'm',
@@ -184,16 +184,16 @@ async function main(argv: Args) {
184184
const level : io.LogLevel = parseInt(io.LogLevel[argv.verbose.toUpperCase()]);
185185
io.enable_logging(level);
186186
}
187-
187+
188188
const client_bootstrap = new io.ClientBootstrap();
189189
const socket_options = new io.SocketOptions(io.SocketType.STREAM, io.SocketDomain.IPV4, 3000);
190-
const tls_options = new io.TlsContextOptions();
190+
const tls_options = new io.TlsContextOptions();
191191
tls_options.override_default_trust_store_from_path(undefined, argv.ca_file);
192192
tls_options.certificate_filepath = argv.cert;
193193
tls_options.private_key_filepath = argv.key;
194194
if (io.is_alpn_available()) {
195195
tls_options.alpn_list.push('x-amzn-http-ca');
196-
}
196+
}
197197
const tls_ctx = new io.ClientTlsContext(tls_options);
198198
const discovery = new greengrass.DiscoveryClient(client_bootstrap, socket_options, tls_ctx, argv.region);
199199

@@ -218,7 +218,7 @@ async function main(argv: Args) {
218218
.catch((reason) => {
219219
console.log(`DISCOVERY SAMPLE FAILED: ${reason}`);
220220
});
221-
221+
222222
// Allow node to die if the promise above resolved
223223
clearTimeout(timer);
224224
}

samples/node/fleet_provisioning/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ yargs.command('*', false, (yargs: any) => {
4646
alias: 'C',
4747
description: 'Client ID for MQTT connection.',
4848
type: 'string',
49-
default: 'samples-client-id'
49+
required: false
5050
})
5151
.option('template_name', {
5252
alias: 't',
@@ -305,7 +305,7 @@ async function main(argv: Args) {
305305
}
306306

307307
config_builder.with_clean_session(false);
308-
config_builder.with_client_id(argv.client_id);
308+
config_builder.with_client_id(argv.client_id || "test-" + Math.floor(Math.random() * 100000000));
309309
config_builder.with_endpoint(argv.endpoint);
310310

311311
// force node to wait 60 seconds before killing itself, promises do not keep node alive

samples/node/pub_sub/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ yargs.command('*', false, (yargs: any) => {
1616
description: "Your AWS IoT custom endpoint, not including a port. " +
1717
"Ex: \"abcd123456wxyz-ats.iot.us-east-1.amazonaws.com\"",
1818
type: 'string',
19-
required: true
19+
required: true
2020
})
2121
.option('ca_file', {
2222
alias: 'r',
@@ -40,13 +40,13 @@ yargs.command('*', false, (yargs: any) => {
4040
alias: 'C',
4141
description: 'Client ID for MQTT connection.',
4242
type: 'string',
43-
default: 'samples-client-id'
43+
required: false
4444
})
4545
.option('topic', {
4646
alias: 't',
4747
description: 'STRING: Targeted topic',
4848
type: 'string',
49-
default: 'samples/test'
49+
default: 'test/topic'
5050
})
5151
.option('count', {
5252
alias: 'n',
@@ -143,12 +143,12 @@ async function main(argv: Args) {
143143
const level : io.LogLevel = parseInt(io.LogLevel[argv.verbosity.toUpperCase()]);
144144
io.enable_logging(level);
145145
}
146-
146+
147147
const client_bootstrap = new io.ClientBootstrap();
148148

149149
let config_builder = null;
150-
if(argv.use_websocket) {
151-
let proxy_options = undefined;
150+
if(argv.use_websocket) {
151+
let proxy_options = undefined;
152152
if (argv.proxy_host) {
153153
proxy_options = new http.HttpProxyOptions(argv.proxy_host, argv.proxy_port);
154154
}
@@ -159,15 +159,15 @@ async function main(argv: Args) {
159159
proxy_options: proxy_options
160160
});
161161
} else {
162-
config_builder = iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path(argv.cert, argv.key);
162+
config_builder = iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path(argv.cert, argv.key);
163163
}
164164

165165
if (argv.ca_file != null) {
166166
config_builder.with_certificate_authority_from_path(undefined, argv.ca_file);
167167
}
168-
168+
169169
config_builder.with_clean_session(false);
170-
config_builder.with_client_id(argv.client_id);
170+
config_builder.with_client_id(argv.client_id || "test-" + Math.floor(Math.random() * 100000000));
171171
config_builder.with_endpoint(argv.endpoint);
172172

173173
// force node to wait 60 seconds before killing itself, promises do not keep node alive
@@ -179,7 +179,7 @@ async function main(argv: Args) {
179179

180180
await connection.connect()
181181
await execute_session(connection, argv)
182-
182+
183183
// Allow node to die if the promise above resolved
184184
clearTimeout(timer);
185185
}

0 commit comments

Comments
 (0)