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

posta 4 anni fa419 visualizzazioni
1 Risposta

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande