Skip to content

Commit

Permalink
All V2 SDK samples can share policies. (#63)
Browse files Browse the repository at this point in the history
* All V2 SDK samples can share policies.
* Update against new split READMEs

Co-authored-by: Bret Ambrose <[email protected]>
  • Loading branch information
graebm and bretambrose authored Jul 13, 2020
1 parent c13e5ed commit 83b6e9d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ This SDK is built on the AWS Common Runtime, a collection of libraries
cross-platform, high-performance, secure, and reliable. The libraries are bound
to JS by the [awscrt](https://github.com/awslabs/aws-crt-nodejs) package.


*__Jump To:__*
* [Installation](#Installation)
* [Samples](samples)
Expand Down Expand Up @@ -48,7 +47,6 @@ npm install
[Samples README](samples)



## Getting Help

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



# License

This library is licensed under the Apache 2.0 License.
6 changes: 3 additions & 3 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ and receive.
"iot:Receive"
],
"Resource": [
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/samples/test"
"arn:aws:iot:<b>region</b>:<b>account</b>:topic/test/topic"
]
},
{
Expand All @@ -44,7 +44,7 @@ and receive.
"iot:Subscribe"
],
"Resource": [
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/samples/test"
"arn:aws:iot:<b>region</b>:<b>account</b>:topicfilter/test/topic"
]
},
{
Expand All @@ -53,7 +53,7 @@ and receive.
"iot:Connect"
],
"Resource": [
"arn:aws:iot:<b>region</b>:<b>account</b>:client/samples-client-id"
"arn:aws:iot:<b>region</b>:<b>account</b>:client/test-*"
]
}
]
Expand Down
10 changes: 5 additions & 5 deletions samples/node/basic_discovery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ yargs.command('*', false, (yargs: any) => {
alias: 't',
description: 'STRING: Targeted topic',
type: 'string',
default: 'sdk/test/NodeJSv2'
default: 'test/topic'
})
.option('mode', {
alias: 'm',
Expand Down Expand Up @@ -184,16 +184,16 @@ async function main(argv: Args) {
const level : io.LogLevel = parseInt(io.LogLevel[argv.verbose.toUpperCase()]);
io.enable_logging(level);
}

const client_bootstrap = new io.ClientBootstrap();
const socket_options = new io.SocketOptions(io.SocketType.STREAM, io.SocketDomain.IPV4, 3000);
const tls_options = new io.TlsContextOptions();
const tls_options = new io.TlsContextOptions();
tls_options.override_default_trust_store_from_path(undefined, argv.ca_file);
tls_options.certificate_filepath = argv.cert;
tls_options.private_key_filepath = argv.key;
if (io.is_alpn_available()) {
tls_options.alpn_list.push('x-amzn-http-ca');
}
}
const tls_ctx = new io.ClientTlsContext(tls_options);
const discovery = new greengrass.DiscoveryClient(client_bootstrap, socket_options, tls_ctx, argv.region);

Expand All @@ -218,7 +218,7 @@ async function main(argv: Args) {
.catch((reason) => {
console.log(`DISCOVERY SAMPLE FAILED: ${reason}`);
});

// Allow node to die if the promise above resolved
clearTimeout(timer);
}
4 changes: 2 additions & 2 deletions samples/node/fleet_provisioning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ yargs.command('*', false, (yargs: any) => {
alias: 'C',
description: 'Client ID for MQTT connection.',
type: 'string',
default: 'samples-client-id'
required: false
})
.option('template_name', {
alias: 't',
Expand Down Expand Up @@ -305,7 +305,7 @@ async function main(argv: Args) {
}

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

// force node to wait 60 seconds before killing itself, promises do not keep node alive
Expand Down
20 changes: 10 additions & 10 deletions samples/node/pub_sub/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ yargs.command('*', false, (yargs: any) => {
description: "Your AWS IoT custom endpoint, not including a port. " +
"Ex: \"abcd123456wxyz-ats.iot.us-east-1.amazonaws.com\"",
type: 'string',
required: true
required: true
})
.option('ca_file', {
alias: 'r',
Expand All @@ -40,13 +40,13 @@ yargs.command('*', false, (yargs: any) => {
alias: 'C',
description: 'Client ID for MQTT connection.',
type: 'string',
default: 'samples-client-id'
required: false
})
.option('topic', {
alias: 't',
description: 'STRING: Targeted topic',
type: 'string',
default: 'samples/test'
default: 'test/topic'
})
.option('count', {
alias: 'n',
Expand Down Expand Up @@ -143,12 +143,12 @@ async function main(argv: Args) {
const level : io.LogLevel = parseInt(io.LogLevel[argv.verbosity.toUpperCase()]);
io.enable_logging(level);
}

const client_bootstrap = new io.ClientBootstrap();

let config_builder = null;
if(argv.use_websocket) {
let proxy_options = undefined;
if(argv.use_websocket) {
let proxy_options = undefined;
if (argv.proxy_host) {
proxy_options = new http.HttpProxyOptions(argv.proxy_host, argv.proxy_port);
}
Expand All @@ -159,15 +159,15 @@ async function main(argv: Args) {
proxy_options: proxy_options
});
} else {
config_builder = iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path(argv.cert, argv.key);
config_builder = iot.AwsIotMqttConnectionConfigBuilder.new_mtls_builder_from_path(argv.cert, argv.key);
}

if (argv.ca_file != null) {
config_builder.with_certificate_authority_from_path(undefined, argv.ca_file);
}

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

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

await connection.connect()
await execute_session(connection, argv)

// Allow node to die if the promise above resolved
clearTimeout(timer);
}

0 comments on commit 83b6e9d

Please sign in to comment.