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개 답변

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠