mehran
mehran

Reputation: 1466

How to use AWS IoT message payload in Rule Engine expression to generate PartitionKey

Problem context: AWS IoT connected to Kinesis Data Stream (KDS) usin AWS Rule Engine, there is an option for PartitionKey in Rule Engine rule definition. PartionKey could be popluated using an expression such as "${topic()}". Example message payload is

{
    Id:"123"
    GS:"123"
}

Question: How an expression could be defined which uses payload, something like "part${payload().GS}"

Upvotes: 0

Views: 530

Answers (1)

thomasmichaelwallace
thomasmichaelwallace

Reputation: 8474

You can do this using a substitution template.

e.g.:

{
    "rule": {
        "sql": "SELECT * FROM 'some/topic'", 
        "ruleDisabled": false, 
        "actions": [{
            "kinesis": {
                "roleArn": "arn:aws:iam::123456789012:role/aws_iot_kinesis", 
                "streamName": "my_kinesis_stream", 
                "partitionKey": "${GS}"
            }
        }], 
    }
}

Upvotes: 1

Related Questions