i need an help. So i need to get from AWS Lambda the topic name subscribed (triggered) from AWS IOT CORE. So this is my code of lambda:
public string FunctionHandler(Gps message, ILambdaContext context)
{
LambdaLogger.Log("STRING MESSAGE DT: " + message.dt);
LambdaLogger.Log("STRING MESSAGE LN: " + message.ln);
LambdaLogger.Log("STRING MESSAGE LT: " + message.lt);
LambdaLogger.Log("input context: " + context.FunctionName);
LambdaLogger.Log("input context: " + context.Identity);
LambdaLogger.Log("input context: " + context.InvokedFunctionArn);
LambdaLogger.Log("input context: " + context.FunctionName);
LambdaLogger.Log("input context: " + context.AwsRequestId);
LambdaLogger.Log("input context: " + context.ClientContext);
LambdaLogger.Log("input context: " + context.Logger);
LambdaLogger.Log("input context: " + context.LogStreamName);
return JsonConvert.SerializeObject(gpsList);
}
i saw in cloud watch, i received correctly the payload data from MQTT and triggered correctrly. So this is my topic:
AWS/#
this is my payload (geolocations object json) publish on AWS/Test
{
"dt": "2020-02-26 18:03:30",
"lt": "xxx.xxx",
"ln": "yyy.yyy"
}
My aws iot core rule:
SELECT *, topic() as Topic FROM 'AWS/#'
this is my logs from AWS CloudWatch
2021-04-20T09:26:48.457+02:00 STRING MESSAGE DT: 2020-02-26 18:03:30
2021-04-20T09:26:48.473+02:00 STRING MESSAGE LN: xxx.xxx
2021-04-20T09:26:48.473+02:00 STRING MESSAGE LT: yyy.yyy
As you can see i received correctly all data but, i need to read the name of topic.
I need to read in this case AWS/Test
I need because the topic will contain basic info like serials of machines, for example 'AWS/xyz'. How can i read the topic name and read 'xyz' from publish MQTT? i need to get Topic name in AWS Lambda. I can't insert the serial machine into payload, but only on the naming of publish topic.