Skip to content

Stack Source Layout

The Terraform stack
Terraform modules in `terraform/` of the demo repo — provisions the full serverless ingest and query stack.
lives in the demo repository
esp32-aws-iot-demo — source repository for firmware, provisioning scripts, Terraform, and dashboard code. Commands run from its root unless stated otherwise.
under terraform/. Browse on GitHub: esp32-aws-iot-demo/terraform.

For apply commands and outputs, see Terraform Provisioning. For ingest behavior, see Ingest Pipeline.

terraform/
├── main.tf # module composition entry point
├── variables.tf
├── outputs.tf
├── providers.tf
├── backend.tf
├── versions.tf
├── terraform.tfvars.example
└── modules/
├── dynamodb/
├── lambda_processor/
├── iot_rule_fanout/
├── lambda_query_api/
├── api_gateway/
└── amplify_hosting/

terraform/main.tf wires modules in dependency order:

  1. CloudWatch log groups (/aws/iot/esp32-demo/*)
  2. dynamodb — telemetry and events tables
  3. lambda_processor — ingest handler
  4. iot_rule_fanout — rules fan-out to CloudWatch + processor Lambda
  5. lambda_query_api — read-only query handler
  6. api_gateway — HTTP routes to query Lambda
  7. amplify_hosting — dashboard app + optional deploy on apply
ModulePurposeKey outputs
modules/dynamodb

Dual tables with GSI device_ts_idx for per-device time-ordered reads

telemetry_table_name, events_table_name

modules/lambda_processor

Ingest LAMBDA
AWS Lambda — processes IoT rule payloads and serves query API logic behind API Gateway.
— validates MQTT payload, writes

DYNAMODB
Amazon DynamoDB — persists telemetry and event records after Lambda ingest in Phase 2.
function_arn
modules/iot_rule_fanout

IoT rules
AWS IoT Rules — route incoming MQTT messages to Lambda and CloudWatch Logs for ingest and verification.
with CloudWatch + Lambda actions

telemetry_rule_arn, events_rule_arn

modules/lambda_query_api

Query LAMBDA
AWS Lambda — processes IoT rule payloads and serves query API logic behind API Gateway.
— latest telemetry and recent events

function_arn
modules/api_gatewayHTTP API routes + CORS for the dashboard browserinvoke_url
modules/amplify_hosting

AMPLIFY
AWS Amplify — hosts the walkthrough dashboard frontend and connects it to the query API URL.
app; builds web/ when deploy_amplify_on_apply is true

amplify_app_url
LambdaHandler source
Processor (ingest)terraform/modules/lambda_processor/src/handler.py
Query APIterraform/modules/lambda_query_api/src/handler.py

Each module packages src/ into a zip at apply time. Unit tests live under src/tests/ in each module.