This project demonstrates the use of AWS IoT Core as a central message hub to ingest, process, and visualize telemetry from multiple industrial sites.
The platform models a real-world industrial scenario where different factories (Assembly Lines, Warehouses, etc.) send sensor data to the cloud. The system handles real-time data ingestion, automated alerting based on configurable thresholds, and long-term storage for visualization.
- Ingestion: Devices (Dockerized Simulators) send MQTT data to AWS IoT Core via TLS 1.2.
- Processing: A Lambda Multiplexer intercepts messages, identifies the origin site, and evaluates metrics.
- Alerting: If a metric exceeds a threshold, an SNS (Simple Notification Service) alert is triggered (Email).
- Storage & Visualization: Data is persisted into an InfluxDB time-series database and visualized through Grafana (both running in Docker on an AWS EC2 instance).
The following diagram illustrates the end-to-end data pipeline, highlighting the event-driven architecture from MQTT message ingestion to real-time visualization and alerting."
graph TD
subgraph "Industrial Site Simulator (Docker)"
A[Assembly Line Simulator] -- "MQTT/TLS (Port 8883)" --> Hub
B[Metal Stamping Simulator] -- "MQTT/TLS (Port 8883)" --> Hub
C[Warehouse Simulator] -- "MQTT/TLS (Port 8883)" --> Hub
end
subgraph "AWS Cloud Infrastructure"
Hub{AWS IoT Core} -- "SQL Rule: Topic(2) as site_id" --> Lambda[Lambda Multiplexer]
Lambda -- "Alert Trigger" --> SNS[SNS Email Notifications]
end
subgraph "Monitoring & Analytics (EC2 Instance)"
Lambda -- "HTTP Write API" --> Influx[(InfluxDB)]
Grafana[Grafana Dashboard] -- "Query" --> Influx
end
style Hub fill:#FF9900,stroke:#232F3E,stroke-width:2px,color:#fff
style Lambda fill:#FF9900,stroke:#232F3E,stroke-width:2px,color:#fff
style Influx fill:#22AD5C,stroke:#eee,color:#fff
style Grafana fill:#F47A20,stroke:#eee,color:#fff
- Cloud Infrastructure: AWS (IoT Core, Lambda, SNS, IAM, EC2)
- Infrastructure as Code: Terraform
- Containerization: Docker & Docker Compose
- Time-Series Database: InfluxDB
- Visualization: Grafana
- Programming: Python (Lambda/Simulators), HCL (Terraform)
The project is divided into two main repositories/folders to decouple infrastructure management from device simulation:
Contains the Infrastructure as Code (IaC) to deploy the AWS cloud stack.
-
main.tf: Root configuration. Orchestrates the Lambda function, SNS alerts, and IoT Topic Rules. -
variables.tf: Global variables (AWS Region, Factory maps). -
modules/factory_site/: -
main.tf: Creates AWS IoT Things, X.509 Certificates, and IoT Policies. -
outputs.tf: Exports ARNs and certificate details. -
variables.tf: Define input variables for the module. -
package/: The deployment package for the backend logic. -
lambda_function.py: Python multiplexer that processes MQTT data and writes to InfluxDB. -
thresholds.json: Dynamic alerting configuration. -
requirements.txt: List of Python dependencies (e.g.,influxdb-client). -
lib/: (Ignored by Git) Local folder containing installed dependencies. This folder must be populated via pip install -t package/lib -r package/requirements.txt before deployment to ensure the Lambda runtime finds the influxdb-client
Contains the Dockerized environment to simulate industrial hardware.
main.py: Multi-client MQTT simulator that reads device lists from environment variables.docker-compose.yaml: Orchestrates the simulator containers..env: (Ignored by Git) Configuration for AWS Endpoint, Factory ID, and Device lists.certs/: (Ignored by Git) This folder must contain the certificates generated by the Terraform module to allow secure TLS communication.
This platform prioritizes industrial-grade security:
- X.509 Authentication: Every simulated device uses a unique certificate generated by Terraform.
- Topic Isolation: IoT Policies prevent a device in
Factory-Afrom publishing or subscribing to topics belonging toFactory-B. - mTLS Encryption: Full encryption in transit via MQTT over Port 8883.
Navigate to the infrastructure folder and apply the Terraform plan:
cd iot-factories-infrastructure
terraform init
terraform apply
Note: This will generate a certs/ folder at the root of the infrastructure directory.
- Copy the generated certificates from
infrastructure/certs/tosimulator/certs/. - Configure your
.envfile in the simulator folder. - Start the simulation:
cd iot-factories-simulator
docker-compose up -d