Skip to main content

AWS IoT Core Thing with Certificate v3 construct

This is a CDK construct that creates an AWS IoT Core Thing with a certificate and policy using aws-sdk-js-v3.

elements

Cloudformation does not support creating a certificate for an IoT Thing, so this construct uses the AWS SDK to create a certificate and attach it to the Thing.

This construct is a modified version of this excellent construct (cdk-iot-core-certificate) to work with aws-sdk-js-v3.

View on Construct Hub Open in Visual Studio Code npm version Build Status Release Status License Downloads npm downloads

Installation

npm i cdk-iot-core-certificates-v3

Usage

import * as s3 from 'aws-cdk-lib/aws-s3';
import { ThingWithCert } from 'cdk-iot-core-certificates-v3';

declare const saveFileBucket: s3.IBucket;

const { thingArn, certId, certPem, privKey } = new ThingWithCert(this, 'MyThing', {
  // The name of the thing
  thingName: 'MyThing',
  // Whether to save the certificate and private key to the SSM Parameter Store
  saveToParamStore: true,
  // The prefix to use for the SSM Parameter Store parameters
  paramPrefix: 'test',
  // The bucket to save the certificate and private key to
  // Both files are saved at `{thingName}/{thingName}.private.key` and `{thingName}/{thingName}.cert.pem`
  // If not provided, the certificate and private key will not be saved
  saveFileBucket,
});

If you want to create multiple things and save certificates and private keys to the same bucket, you should not use saveFileBucket prop and save them at once by BucketDeployment construct.

This is because the each saveFileBucket prop will share a custom resource for each thing, which will cause the deployment to fail.

import * as s3 from 'aws-cdk-lib/aws-s3';
import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
import { ThingWithCert } from 'cdk-iot-core-certificates-v3';

const thingNames = ['Thing1', 'Thing2', 'Thing3'];
const certBucket = new s3.Bucket(this, "CertBucket");
const sources: s3deploy.ISource[] = [];

thingNames.forEach((thingName, index) => {
  const { certPem, privKey } = new ThingWithCert(this, `Thing${index}`, {
    thingName,
    saveToParamStore: true,
  });
  sources.push(
    s3deploy.Source.data(`${thingName}/${thingName}.cert.pem`, certPem),
    s3deploy.Source.data(`${thingName}/${thingName}.private.key`, privKey)
  );
});

// Deploy the certificate and private key to the S3 bucket at once
new s3deploy.BucketDeployment(this, "DeployCerts", {
  sources,
  destinationBucket: certBucket,
});

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk_iot_core_certificates_v3-0.1.5.tar.gz (34.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdk_iot_core_certificates_v3-0.1.5-py3-none-any.whl (34.3 MB view details)

Uploaded Python 3

File details

Details for the file cdk_iot_core_certificates_v3-0.1.5.tar.gz.

File metadata

File hashes

Hashes for cdk_iot_core_certificates_v3-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f0c104bca44b0d5379cda483ca35df56c3355fbd967a339839e74925fe4f87dc
MD5 ab3e4cd3602119d495a5fe105a395d15
BLAKE2b-256 2265faa4054916a49da766ce5ccbffd39ea52d66a0860d84ebd4e6467d3b050d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdk_iot_core_certificates_v3-0.1.5.tar.gz:

Publisher: release.yml on badmintoncryer/cdk-iot-core-certificates-v3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cdk_iot_core_certificates_v3-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for cdk_iot_core_certificates_v3-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 95cc7417f6d6612318895ceb8a48cfcedbdd92383c245d23c943a572f26ac328
MD5 501532d25617177be9d0eae5b96ab274
BLAKE2b-256 f8af2962f1bc0188c64ac902e93cf1e1924b0c654affd63cc24dfdf728225356

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdk_iot_core_certificates_v3-0.1.5-py3-none-any.whl:

Publisher: release.yml on badmintoncryer/cdk-iot-core-certificates-v3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page