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.

34 lines (32 loc) 891 B
import { DescribeThingGroupCommand, DescribeThingGroupCommandInput, IoTClient, } from '@aws-sdk/client-iot'; import { Request, Response, } from '@softchef/lambda-events'; import { AwsError } from '../../constracts'; export async function handler(event: { [key: string]: any }) { const request = new Request(event); const response = new Response(); try { const parameters: DescribeThingGroupCommandInput = { thingGroupName: request.parameter('thingGroupName'), }; const iotClient = new IoTClient({}); const thingGroup = await iotClient.send( new DescribeThingGroupCommand(parameters), ); return response.json({ thingGroup: thingGroup, }); } catch (error) { if ((error as AwsError).Code === 'ResourceNotFoundException') { return response.error(error, 404); } else { return response.error(error); } } }