UNPKG

@softchef/cdk-iot-device-management

Version:

IoT device management is composed of things, thing types, thing groups, jobs, files API services. The constructs can be used independently, that are based on full-managed service to create an API Gateway & Lambda function.

35 lines (33 loc) 922 B
import { IoTClient, ListThingsCommand, ListThingsCommandInput, } from '@aws-sdk/client-iot'; import { Request, Response, } from '@softchef/lambda-events'; export async function handler(event: { [key: string]: any }) { const request = new Request(event); const response = new Response(); try { const parameters: ListThingsCommandInput = {}; if (request.has('attributeName')) { parameters.attributeName = request.get('attributeName'); parameters.attributeValue = request.get('attributeValue'); } if (request.has('nextToken')) { parameters.nextToken = request.get('nextToken'); } const iotClient = new IoTClient({}); const { things, nextToken } = await iotClient.send( new ListThingsCommand(parameters), ); return response.json({ things: things, nextToken: nextToken, }); } catch (error) { return response.error(error); } }