In the dynamic world of IoT, agility and security are paramount. Building on my previous articles about Smart IoT Solutions, AWS Serverless APIs, and High Availability, I engineered a solution that is robust, scalable, and secure. In this post, I walk you through how wildcards in MQTT topics simplify device management while ensuring a seamless data flow—from AWS IoT Core, through Lambda and DynamoDB, to a public API endpoint.
Using a wildcard in a topic like bestsense/poc/*/lab allows you to group devices effortlessly. The asterisk substitutes for any single-level value, enabling dynamic device identification and data aggregation without hardcoding individual IDs. This approach simplifies management, enhances scalability, and reduces configuration overhead.
I designed this solution using several key AWS services:
1. Creating the IoT Policy
The IoT policy ensures devices can connect, publish, subscribe, and receive on the necessary topics. For example:
2. Setting Up the IoT Rule
This rule listens to topics like bestsense/poc/+/lab and triggers the Lambda function:
3. Creating the Lambda Function for IoT Data Processing
Before creating the DynamoDB table, set up a Lambda function that processes IoT data and writes it to the table:
4. Creating the DynamoDB Table
A simple, on-demand DynamoDB table to store the processed data:
5. Creating the Lambda Function for API Access
Finally, create a Lambda function to expose the data via API Gateway. Sensitive details have been masked:
Ready to implement this in your lab environment, download the resources below.
Get all the resources you need to build this in your AWS lab!
Download from My GithubIn my simulation, data is generated via a Python script, so I did not implement a reverse proxy. However, in a production environment where real data is exposed publicly, setting up a reverse proxy using Nginx or Apache—with SSL/TLS, a Web Application Firewall (WAF), rate limiting, and IP whitelisting—is highly recommended to safeguard your API.
Very fine particles
Fine particles, like bacteria and smoke
Slightly larger particles
Larger particles, like dust and pollen
This solution demonstrates how AWS services can be orchestrated to build an efficient, secure IoT-to-API pipeline. The wildcard mechanism simplifies handling diverse device data, while the comprehensive setup—including IoT policies, rules, Lambda functions, and DynamoDB—ensures your data is processed and stored seamlessly. Although my simulation does not include a reverse proxy, I strongly recommend one for any production environment to secure your public endpoints.
Embrace the power of wildcards. Embrace the future. With this approach, your IoT journey becomes both streamlined and secure.
Blog | LinkedIn | GitHub | Disclaimer
Created: February 2025
🚀 From Legacy Systems to AI-Powered Innovation: A 20-Year Journey in IT Mastery 🚀
With over 20 years of hands-on IT expertise, he has lived through every major transformation in technology—from on-premise servers to virtualization, cloud computing, and now AI-driven automation. He doesn't just adapt to change—he anticipates it, engineers it, and drives it forward.
An AWS, IoT, and AI enthusiast, he has built solutions that optimize performance, cut costs, and future-proof businesses. Armed with Microsoft, CCNA, VMware, and Citrix certifications, his knowledge spans the entire IT spectrum, allowing him to bridge the gap between legacy infrastructure and modern cloud architectures.
His mission? To empower businesses with high-impact, scalable cloud solutions that don't just keep up—they dominate.
Copyright 2025 | Cloud Hermit Pty Ltd ACN 684 777 562 | Privacy Policy | Contact Us | Sign Up Newsletter