danielscholl / iot-resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iot-resources

The purpose of this solution is to deploy resources necessary for an IoT Solution

PreRequisites

Requires the use of direnv.

Requires the use of Azure CLI.

Requires the use of OpenSSL.

Related Repositories

Provision the Azure Resources

This script will generate the following resources in Azure.

  1. Key Vault

  2. Storage Account

  3. IoT Hub

  4. Device Provisioning Service

  5. Log Analytics

  6. Application Insights

  7. Stream Analytics

  8. Time Series Insights

# Provision the ARM Resources
./provision.sh

The script creates an .envrc file to set environment variables used in creating the x509 certs.

# Azure Resources
export VAULT="<key_vault>"
export HUB="<iot_hub>"
export DPS="<iot_dps>"
export DPS_GROUP="<resource_group>"

# Certificate Authority
export ORGANIZATION="<organization>"
export ROOT_CA_PASSWORD="<password>"
export INT_CA_PASSWORD="<password>"

The default ORGANIZATION name is testonly. These files have the reference to the organization.

  • .envrc
  • root_ca.dnf
  • intermediate_ca.dnf

Create and Upload the Root CA and Intermediate Certificates

This script initializes a Root and Intermediate CA for use.

  1. Creates x509 Certificates and Authorities in ./src/pki

  2. Upload the Certificates, Keys, and Passwords used to the KeyVault.

  3. Uploads and Validates the Root and Intermediate CA certificates to the IoT Hub.

  4. Uploads and Validates the Root and Intermediate CA certificates to the IoT DPS.

# Initializes a Root and Intermediate CA for use.
./init-ca.sh

Creating and Storing Device Certificates

This script creates device certificates for use.

  1. Creates an iot hub identity using a self signed certificate.

  2. Creates device certificates signed by the Intermediate CA

  3. Creates edge certificates signed by the Intermediate CA

  4. Creates leaf certificates signed by the Intermediate CA

# Usage            <type>  <name>
./device-cert.sh   self    self-signed-device
./device-cert.sh   device  device  deploy (optional)
./device-cert.sh   edge    edge
EDGE_GATEWAY="edge" ./device-cert.sh   leaf    leaf

Spin up Multiple Containers

Devices

COUNT=1
until [ $COUNT -gt 10 ]; do
./device-cert.sh device device$COUNT deploy
let COUNT+=1
done

Downstream Devices

COUNT=1
until [ $COUNT -gt 10 ]; do
EDGE_GATEWAY="edge" ./device-cert.sh leaf leaf$COUNT deploy
let COUNT+=1
done

About

License:MIT License


Languages

Language:Shell 100.0%