Skip to content

Update Thing Shadow #2133

@tuscaonline

Description

@tuscaonline

Describe the bug

I try use this code to update thing shadow.

import { IoTDataPlaneClient, UpdateThingShadowCommand, UpdateThingShadowCommandOutput, UpdateThingShadowRequest } from "@aws-sdk/client-iot-data-plane";
import { Shadow } from "../interface/shadow.interface";

export default async function updateThingShadow(shadow:Shadow, thingName: string){
    
    const ioTDataPlaneClient = new IoTDataPlaneClient({
        region: "eu-west-1"
    })
    console.log('Version : ' + ioTDataPlaneClient.config.apiVersion)
    const payload = {
        state: {
            reported: shadow
        }
    }
    const updateThingShadowRequest: UpdateThingShadowRequest = {
        thingName: thingName,
        payload: Buffer.from(JSON.stringify(payload))
    }
    try {
       const updateThingShadowCommandOutput = await ioTDataPlaneClient.send(new UpdateThingShadowCommand(updateThingShadowRequest));

    } catch (error) {
        throw new Error(`Une erreur à été trouver lors du traitement du shadow pour ${thingName}, Error : ${error}`);           
    }

}

Your environment

Lambda AWS

SDK version number

V3

Is the issue in the browser/Node.js/ReactNative?

Node.js

Details of the browser/Node.js/ReactNative version

v14.16.0

Steps to reproduce

In Lambda envirronement
There is no error when i use a thing who not exist.
There is no update when I try to update a shadow. (the lambda role has the updateThingShadow permission)
On computer envirronement
On my computer when the AWS token is expired, i get a timeout error.
no error when i use a thing who not exist.
I can Update the thing shadow.

Observed behavior

A clear and concise description of what happens.

Expected behavior

an Error when i use a bad thing.
A updated shadow.

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions