Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Latest commit

 

History

History
333 lines (211 loc) · 11.2 KB

API.md

File metadata and controls

333 lines (211 loc) · 11.2 KB

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,
});

API Reference

Constructs

ThingWithCert

Initializers

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

new ThingWithCert(scope: Construct, id: string, props: ThingWithCertProps)
Name Type Description
scope constructs.Construct No description.
id string No description.
props ThingWithCertProps No description.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsRequired

Methods

Name Description
toString Returns a string representation of this construct.

toString
public toString(): string

Returns a string representation of this construct.

Static Functions

Name Description
isConstruct Checks if x is a construct.

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

ThingWithCert.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


Properties

Name Type Description
node constructs.Node The tree node.
certId string No description.
certPem string No description.
privKey string No description.
thingArn string No description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


certIdRequired
public readonly certId: string;
  • Type: string

certPemRequired
public readonly certPem: string;
  • Type: string

privKeyRequired
public readonly privKey: string;
  • Type: string

thingArnRequired
public readonly thingArn: string;
  • Type: string

Structs

ThingWithCertProps

Initializer

import { ThingWithCertProps } from 'cdk-iot-core-certificates'

const thingWithCertProps: ThingWithCertProps = { ... }

Properties

Name Type Description
account string The AWS account ID this resource belongs to.
environmentFromArn string ARN to deduce region and account from.
physicalName string The value passed in by users to the physical name prop of the resource.
region string The AWS region this resource belongs to.
thingName string No description.
paramPrefix string No description.
saveToParamStore boolean No description.

accountOptional
public readonly account: string;
  • Type: string
  • Default: the resource is in the same account as the stack it belongs to

The AWS account ID this resource belongs to.


environmentFromArnOptional
public readonly environmentFromArn: string;
  • Type: string
  • Default: take environment from account, region parameters, or use Stack environment.

ARN to deduce region and account from.

The ARN is parsed and the account and region are taken from the ARN. This should be used for imported resources.

Cannot be supplied together with either account or region.


physicalNameOptional
public readonly physicalName: string;
  • Type: string
  • Default: The physical name will be allocated by CloudFormation at deployment time

The value passed in by users to the physical name prop of the resource.

undefined implies that a physical name will be allocated by CloudFormation during deployment.

  • a concrete value implies a specific physical name
  • PhysicalName.GENERATE_IF_NEEDED is a marker that indicates that a physical will only be generated by the CDK if it is needed for cross-environment references. Otherwise, it will be allocated by CloudFormation.

regionOptional
public readonly region: string;
  • Type: string
  • Default: the resource is in the same region as the stack it belongs to

The AWS region this resource belongs to.


thingNameRequired
public readonly thingName: string;
  • Type: string

paramPrefixOptional
public readonly paramPrefix: string;
  • Type: string

saveToParamStoreOptional
public readonly saveToParamStore: boolean;
  • Type: boolean