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.
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
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,
});
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. |
- Type: constructs.Construct
- Type: string
- Type: ThingWithCertProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
public toString(): string
Returns a string representation of this construct.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { ThingWithCert } from 'cdk-iot-core-certificates'
ThingWithCert.isConstruct(x: any)
Checks if x
is a construct.
- Type: any
Any object.
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. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly certId: string;
- Type: string
public readonly certPem: string;
- Type: string
public readonly privKey: string;
- Type: string
public readonly thingArn: string;
- Type: string
import { ThingWithCertProps } from 'cdk-iot-core-certificates'
const thingWithCertProps: ThingWithCertProps = { ... }
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. |
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.
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
.
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.
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.
public readonly thingName: string;
- Type: string
public readonly paramPrefix: string;
- Type: string
public readonly saveToParamStore: boolean;
- Type: boolean