Terraform Provisioning
For Terraform module layout and Lambda paths, see Stack Source Layout and Ingest Pipeline.
Provision shared infrastructure
Section titled “Provision shared infrastructure”From 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. root:
cp terraform/terraform.tfvars.example terraform/terraform.tfvarsterraform -chdir=terraform initterraform -chdir=terraform planterraform -chdir=terraform applyProvisioned stack
Terraform modules in `terraform/` of the demo repo — provisions the full serverless ingest and query stack. summary:
- IoT rules
AWS IoT Rules — route incoming MQTT messages to Lambda and CloudWatch Logs for ingest and verification. fan-out - LAMBDA
AWS Lambda — processes IoT rule payloads and serves query API logic behind API Gateway. processing - DYNAMODB
Amazon DynamoDB — persists telemetry and event records after Lambda ingest in Phase 2. persistence - Query LAMBDA
AWS Lambda — processes IoT rule payloads and serves query API logic behind API Gateway. - API Gateway
Amazon API Gateway — exposes HTTP routes for latest telemetry and recent events. The browser reads data through API Gateway, not DynamoDB directly. routes - AMPLIFY
AWS Amplify — hosts the walkthrough dashboard frontend and connects it to the query API URL. resources
Capture outputs
Section titled “Capture outputs”terraform -chdir=terraform outputterraform -chdir=terraform output -json > terraform/outputs.dev.jsonRequired outputs:
query_api_invoke_urltelemetry_table_nameevents_table_nameamplify_app_url
Validate persistence in DynamoDB
Section titled “Validate persistence in DynamoDB”TELEMETRY_TABLE="$(terraform -chdir=terraform output -raw telemetry_table_name)"EVENTS_TABLE="$(terraform -chdir=terraform output -raw events_table_name)"aws dynamodb scan --table-name "$TELEMETRY_TABLE" --max-items 5aws dynamodb scan --table-name "$EVENTS_TABLE" --max-items 5Each scan should return at least one item after device publishes have flowed through the ingest path.
Continue with Query API Validation for Phase 3.