I not not sure how to define the IoT topic definition in the Lambda function for an Alexa controlled IoT device across multiple AWS accounts.
Let's say my company is called CoolCompany and I want to develop an Alexa controlled simple light switch to sell.
- It has a microcontroller, and I need to install the TLS certificates and the IoT topic definition for MQTT subscription prior to shipping.
- I create a Thing device in AWS IoT for customer #1 called cust1_thing,
- I create another Thing device is AWS IoT for customer #2 called cust2_thing.
- I define the topic for device #1 microcontroller as cust1_thing/topic.
- I define the topic for device #2 microcontroller as cust2_thing/topic.
- Each customer installs the switch and loads the CoolCompany Alexa skill.
- That skill is linked to my account and triggers a common Lambda function.
- At this point, customer #1device is connected to AWS and connected to my backend MQTT broker and subscribed to cust1_thing/topic. Customer #2 device is connected to AWS and connected to my backend MQTT broker and subscribed to cust2_thing/topic
How do I define the IoT topic definition in a common Lambda function such that it it writes to cust1_thing/topic for customer #1 and cust2_thing/topic for customer #2?