/cdk-iot-core-certificates

AWS CDK L3 construct for managing certificates for AWS IoT Core

Primary LanguageTypeScriptMIT LicenseMIT

CDK IoT Core Certificates

Source Release GitHub Docs

npm package

Downloads npm downloads

AWS CDK L3 construct for managing certificates for AWS IoT Core

CloudFormation doesn't directly support creation of certificates for AWS IoT Core. This construct provides an easy interface for creating certificates through a custom CloudFormation resource. The private key is stored in AWS Parameter Store.

Installation

This package has peer dependencies, which need to be installed along in the expected version.

For TypeScript/NodeJS, add these to your dependencies in package.json:

  • cdk-iot-core-certificates

Usage

import { ThingWithCert } from 'cdk-iot-core-certificates';

// Creates new AWS IoT Thing called thingName
// Saves certs to /devices/thingName/certPem and /devices/thingName/privKey
// thingName and paramPrefix cannot start with '/'
const { thingArn, certId, certPem, privKey } = new ThingWithCert(this, 'ThingWithCert', {
    thingName: 'integrationTest',
    saveToParamStore: true,
    paramPrefix: 'devices',
});

new CfnOutput(this, 'Output-ThingArn', {
    value: thingArn,
});

new CfnOutput(this, 'Output-CertId', {
    value: certId,
});

new CfnOutput(this, 'Output-CertPem', {
    value: certPem,
});

new CfnOutput(this, 'Output-PrivKey', {
    value: privKey,
});