By using AWS re:Post, you agree to the Terms of Use
/AWS IoT Device Management/

Questions tagged with AWS IoT Device Management

Sort by most recent
  • 1
  • 90 / page

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Aws Iot Device Client Setup not working

Hello, i have been trying to setup a rpi using the tutorials [here](https://docs.aws.amazon.com/iot/latest/developerguide/iot-dc-install-configure.html) and when i run the command `./aws-iot-device-client --config-file ~/dc-configs/dc-testconn-config.json ` i am getting errors on the terminal saying that the aws crt sdk is not found with a fatal error like this ``` 2022-04-11T07:38:13.850Z [WARN] {Config.cpp}: Key {template-name} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.850Z [WARN] {Config.cpp}: Key {csr-file} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.850Z [WARN] {Config.cpp}: Key {device-key} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.850Z [WARN] {Config.cpp}: Key {file} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.850Z [WARN] {Config.cpp}: Key {publish-file} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.851Z [WARN] {Config.cpp}: Key {subscribe-file} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.851Z [WARN] {Config.cpp}: Shadow Name {shadow-name} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.851Z [WARN] {Config.cpp}: Input file {shadow-input-file} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.851Z [WARN] {Config.cpp}: Output file {shadow-output-file} was provided in the JSON configuration file with an empty value 2022-04-11T07:38:13.851Z [INFO] {Config.cpp}: Successfully fetched JSON config file: { "endpoint": "a32vqcn021ykiy-ats.iot.ap-south-1.amazonaws.com", "cert": "~/certs/testconn/device.pem.crt", "key": "~/certs/testconn/private.pem.key", "root-ca": "~/certs/AmazonRootCA1.pem", "thing-name": "Triton_Dp_Office", "logging": { "enable-sdk-logging": true, "level": "DEBUG", "type": "STDOUT", "file": "" }, "jobs": { "enabled": false, "handler-directory": "" }, "tunneling": { "enabled": false }, "device-defender": { "enabled": false, "interval": 300 }, "fleet-provisioning": { "enabled": false, "template-name": "", "template-parameters": "", "csr-file": "", "device-key": "" }, "samples": { "pub-sub": { "enabled": true, "publish-topic": "test/dc/pubtopic", "publish-file": "", "subscribe-topic": "test/dc/subtopic", "subscribe-file": "" } }, "config-shadow": { "enabled": false }, "sample-shadow": { "enabled": false, "shadow-name": "", "shadow-input-file": "", "shadow-output-file": "" } } 2022-04-11T07:38:13.851Z [DEBUG] {Config.cpp}: Did not find a runtime configuration file, assuming Fleet Provisioning has not run for this device 2022-04-11T07:38:13.852Z [DEBUG] {EnvUtils.cpp}: Updated PATH environment variable to: /home/pi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/snap/bin:/home/pi/.aws-iot-device-client:/home/pi/.aws-iot-device-client/jobs:/home/pi/aws-iot-device-client/build:/home/pi/aws-iot-device-client/build/jobs 2022-04-11T07:38:13.852Z [INFO] {Main.cpp}: Now running AWS IoT Device Client version v1.5.19-868465b 2022-04-11T07:38:13.860Z [ERROR] {FileUtils.cpp}: Failed to create empty file: /var/log/aws-iot-device-client/sdk.log errno: 17 msg: File exists 2022-04-11T07:38:13.860Z [ERROR] {Main.cpp}: *** AWS IOT DEVICE CLIENT FATAL ERROR: Failed to initialize AWS CRT SDK. AWS IoT Device Client must abort execution, reason: Failed to initialize AWS CRT SDK Please check the AWS IoT Device Client logs for more information Aborted ``` I need this setup asap to work on deploying a fleet and test out AWS IOT Jobs. Any help is appreciated.
1
answers
0
votes
15
views
asked a month ago

Javascript IoT client SDK AttachPolicy call inside AWS lambda blocks and causes the lambda to timeout without any error/exception/log whatsoever

Hello, **Issue in short: ** When I make [AttachPolicy](https://docs.aws.amazon.com/iot/latest/apireference/API_AttachPolicy.html) call using the [Javascript v3 AWS SDK IoT Client](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-iot/index.html) inside AWS lambda, the call blocks and causes the lambda to timeout without any error/exception/log whatsoever. I am having trouble identifying why the call does not succeed and blocks, hence my question here. --- **Details:** I have a lambda function from which I want to use the [Javascript v3 AWS SDK IoT Client](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-iot/index.html). The request that I want to make to IoT core is [AttachPolicy](https://docs.aws.amazon.com/iot/latest/apireference/API_AttachPolicy.html), in order to attach a policy to a Thing's certificate (certificate is identified by ARN). **Basically what I have in my code (excerpts) is this:** **1) Creation of an IoT client: ** ``` new IoTClient({ region: process.env.REGION }); ``` I have not provided any credentials, because I read that they are retrieved from the lambda's execution role: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/loading-node-credentials-lambda.html ---- **2) Creation of AttachPolicyCommand** - https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-iot/classes/attachpolicycommand.html: ``` const attachPolicyCommand = new AttachPolicyCommand({ policyName: <NAME_OF_POLICY>, target: <CERTIFICATE_ARN> }); console.log(`Sending attach policy request to attach '${policyName}' to '${targetArn}'.`) ``` From the log above I double check and make absolutely sure that the policy name and the certificate ARN are the correct ones. **3) AttachPolicy request - this is where the problem arises** ``` const attachPolicyResponse = await this.iotClient.send(attachPolicyCommand); ... // unreachable code after the call above ... // after the configured lambda's timeout, the function execution ceases without executing any other line of code ``` I have also tried to wrap the above call inside try/catch/finally block, but it didn't make any difference. --- One thing that I noticed and thought was causing the issue was that the lambda's execution role didn't have the permission to access the [AttachPolicy](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions) action. But once I fixed that and added the needed policy, the issue persists. This is the json of the policy which I added to the lambda execution role in order to allow AttachPolicy: ``` { "Version": "2012-10-17", "Statement": [ { "Action": "iot:AttachPolicy", "Resource": "*", "Effect": "Allow" } ] } ``` Another thing is that the lambda's timeout configuration seems to make no difference - I tried making it both 5 seconds and 2 minutes - and the blocking is, respectively, for 5 seconds and 2 minutes. I'll be grateful if you provide some insights on what the problem might be :)).
1
answers
1
votes
33
views
asked 5 months ago
  • 1
  • 90 / page