CDK Construct for AWS IoT Core certificates and things
Project description
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.
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.
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,
});
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cdk_iot_core_certificates_v3-0.1.2.tar.gz.
File metadata
- Download URL: cdk_iot_core_certificates_v3-0.1.2.tar.gz
- Upload date:
- Size: 34.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aedfa6959832e2d1d0472f4e53633782c1947df96aa4fdaa1affde5fc7776e8
|
|
| MD5 |
98c22a80ccbff0aec5b2e69c43e2b6c9
|
|
| BLAKE2b-256 |
1b4c0e9c1385cac41b917702f436de1f0ff00937bb7d4d7c303efa975789583b
|
Provenance
The following attestation bundles were made for cdk_iot_core_certificates_v3-0.1.2.tar.gz:
Publisher:
release.yml on badmintoncryer/cdk-iot-core-certificates-v3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cdk_iot_core_certificates_v3-0.1.2.tar.gz -
Subject digest:
7aedfa6959832e2d1d0472f4e53633782c1947df96aa4fdaa1affde5fc7776e8 - Sigstore transparency entry: 1107157800
- Sigstore integration time:
-
Permalink:
badmintoncryer/cdk-iot-core-certificates-v3@b150187a88586e815d440549788eaf4d3556c693 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/badmintoncryer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b150187a88586e815d440549788eaf4d3556c693 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cdk_iot_core_certificates_v3-0.1.2-py3-none-any.whl.
File metadata
- Download URL: cdk_iot_core_certificates_v3-0.1.2-py3-none-any.whl
- Upload date:
- Size: 34.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
812678de0dc6ab00b7bc2375a15fd53a83643d35ab96b970b9773635e4a4ea5a
|
|
| MD5 |
84f8efe515ee9aec7218ae3f18bc0bd1
|
|
| BLAKE2b-256 |
3a5f078c473cec84563791d2ba2cc9ebcdcf85c306050447419afdf9211505f8
|
Provenance
The following attestation bundles were made for cdk_iot_core_certificates_v3-0.1.2-py3-none-any.whl:
Publisher:
release.yml on badmintoncryer/cdk-iot-core-certificates-v3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cdk_iot_core_certificates_v3-0.1.2-py3-none-any.whl -
Subject digest:
812678de0dc6ab00b7bc2375a15fd53a83643d35ab96b970b9773635e4a4ea5a - Sigstore transparency entry: 1107157791
- Sigstore integration time:
-
Permalink:
badmintoncryer/cdk-iot-core-certificates-v3@b150187a88586e815d440549788eaf4d3556c693 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/badmintoncryer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b150187a88586e815d440549788eaf4d3556c693 -
Trigger Event:
push
-
Statement type: