@uhuru/awsiot-thing-creator
Advanced tools
Comparing version
@@ -12,3 +12,3 @@ interface ConfigObject { | ||
export declare class AWSIoTThingCreator { | ||
private readonly enebularInstallId; | ||
private readonly installToken; | ||
private awsAccessKeyId; | ||
@@ -26,3 +26,3 @@ private awsIotRegion; | ||
private _iotClient; | ||
constructor({ awsAccessKeyId, awsIotRegion, awsSecretAccessKey, configSavePath, thingAttributePayload, thingName, thingTypeName, enebularInstallId, enebularBaseUrl }: { | ||
constructor({ awsAccessKeyId, awsIotRegion, awsSecretAccessKey, configSavePath, thingAttributePayload, thingName, thingTypeName, installToken, enebularBaseUrl }: { | ||
awsAccessKeyId?: string; | ||
@@ -35,3 +35,3 @@ awsIotRegion?: string; | ||
thingTypeName?: string; | ||
enebularInstallId?: string; | ||
installToken?: string; | ||
enebularBaseUrl?: string; | ||
@@ -38,0 +38,0 @@ }); |
@@ -21,4 +21,4 @@ "use strict"; | ||
class AWSIoTThingCreator { | ||
constructor({ awsAccessKeyId, awsIotRegion, awsSecretAccessKey, configSavePath, thingAttributePayload, thingName, thingTypeName, enebularInstallId, enebularBaseUrl }) { | ||
if (!enebularInstallId && | ||
constructor({ awsAccessKeyId, awsIotRegion, awsSecretAccessKey, configSavePath, thingAttributePayload, thingName, thingTypeName, installToken, enebularBaseUrl }) { | ||
if (!installToken && | ||
!awsIotRegion && | ||
@@ -30,3 +30,3 @@ !awsSecretAccessKey && | ||
} | ||
this.enebularInstallId = enebularInstallId; | ||
this.installToken = installToken; | ||
this.awsAccessKeyId = awsAccessKeyId; | ||
@@ -376,6 +376,6 @@ this.awsIotRegion = awsIotRegion; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.enebularInstallId) { | ||
throw new Error('enebularInstallId must be specified'); | ||
if (!this.installToken) { | ||
throw new Error('installToken must be specified'); | ||
} | ||
const getAgentThingUrl = this.enebularApiUrl + `/get-thing-install-info/${this.enebularInstallId}`; | ||
const getAgentThingUrl = this.enebularApiUrl + `/get-thing-install-info/${this.installToken}`; | ||
const { thingName, clientPem, privateKey, config, rootPem, enebularConfig } = yield axios_1.default | ||
@@ -382,0 +382,0 @@ .get(getAgentThingUrl) |
{ | ||
"name": "@uhuru/awsiot-thing-creator", | ||
"version": "1.0.1-beta.28", | ||
"version": "1.0.1-beta.29", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,44 +8,2 @@ # @uhuru/awsiot-thing-creator | ||
## Environment Variables | ||
Supported environment variables: | ||
```sh | ||
ENV DESCRIPTION | ||
AWS_ACCESS_KEY_ID AWS access key ID | ||
AWS_SECRET_ACCESS_KEY AWS secret access key | ||
AWS_IOT_REGION AWS IoT region | ||
AWS_IOT_THING_NAME The name of the AWS IoT thing to be created | ||
``` | ||
## npm start | ||
This library can be called by npm-start command. | ||
```shell | ||
$ npm start -- --aws-access-key-id=hoge --aws-secret-access-key=foo --aws-iot-region=bar --aws-iot-thing-name=buzz --thing-attribute-payload={\"attributes\":{\"string1\":\"string2\"}} --thing-type-name=Device | ||
``` | ||
Note that you need to build this package before running npm start. | ||
```shell | ||
$ npm run build | ||
``` | ||
### The arguments | ||
| Argument | Required | Description | Example | | ||
|----------|----------|-------------|---------| | ||
| `--aws-access-key-id` | Yes | AWS access key ID | `AKIAJWWCHDEPQJD456PQ` | | ||
| `--aws-secret-access-key` | Yes| AWS secret access key | `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`| | ||
| `--aws-iot-region` | Yes | AWS IoT region | `us-west-2` | | ||
| `--aws-iot-thing-name` | Yes | The name of the AWS IoT thing to be created | `enebular-agent-test` | | ||
| `--thing-attribute-payload` | No | The attribute payload | `{\"attributes\":{\"string1\":\"string2\"}` | | ||
| `--thing-type-name` | No | The name of the thing type | `Device` | | ||
For more details about above arguments, please refer to AWS document | ||
[IoT Client - AWS SDK for JavaScript v3](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-iot/index.html#description) | ||
## ECMAScript Modules | ||
@@ -52,0 +10,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
50566
-3.24%60
-41.18%