How to pass SQS attributes when IOT rule is triggered?

0

Basic flow: Multiple clients are pushing data to the single topic which then pushes the same data to SQS after authentication and there's a backend service which is listening to SQS.

For authentication, I've created a custom authorizer. Following is the dummy response from the custom authorizer.

{
    "isAuthenticated": true,
    "refreshAfterInSeconds": 600,
    "policyDocuments": [
        "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"iot:Publish\",\"Effect\":\"Allow\",\"Resource\":\"arn:aws:iot:ap-south-1:test:topic/customauthtesting\"}]}"
    ],
    "disconnectAfterInSeconds": 3600,
    "principalId": "123",
    "context" ": {
         "userId" : "User1"    
    }
}

And I'm able to pass the body(incl. timestamp) to SQS using Rule query statement like this

SELECT *, timestamp() as timestamp FROM 'topic/test'

Now, I want to push the context.userId either as an attribute or in a body to SQS when the same IOT rule is triggered, but I'm unable to do so. It's mentioned in the https://docs.aws.amazon.com/iot/latest/developerguide/custom-authorizer.html that Information derived after validating the token that is made available in AWS IoT rules engine SQL statements, so I think it's feasible to do so.

Can someone please provide me the example or the correct syntax for passing the userId in Rule SQL query. Let me know if more info is required.

Edited by: ShobhitR on Jul 13, 2020 12:19 AM

已提問 4 年前檢視次數 419 次
1 個回答

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南