0

I want to use an AWS IoT Rule to trigger a specific lambda based on the value of a attribute of the incoming messages. It seems like the problem is because of a hyphen that is contained in the attribute name.

My message looks like this:

{
  "testdata": "abc",
  "test-data": "abc"
}

If I trigger a lambda by the following AWS IoT SQL it works:

select * from 'my/test' Where startswith(testdata, 'abc')

But it doesn't work if I use this SQL:

select * from 'my/test' Where startswith(test-data, 'abc')

Is it possible to escape the hyphen or is there another way to use attribute names with a hyphen?

Johnny90
  • 465
  • 1
  • 4
  • 14

1 Answers1

0

In the AWS iot SQL reference, a hyphen is a subtraction operator when used in the WHERE clause, so no you can't use it as a hyphen like you are trying to do.

Excel r 8
  • 105
  • 6
  • Have you tried the solution in this Stack overflow answer: https://stackoverflow.com/questions/13869627/unable-to-access-json-property-with-dash – Excel r 8 Jun 10 '19 at 13:46
  • Is there any way to escape this character? Or what other possibilities are there if I cannot just change the content of the incoming json? – Johnny90 Jun 17 '19 at 07:04
  • The solution Excel r 8 mentioned is not working. I cannot even save the IoT Sql statement in the AWS console – Johnny90 Jun 17 '19 at 07:06