title: AWS IoT DynamoDB rule not able to read value SELECTed from topic() function
body: <p>I'm trying to get data from an AWS IoT MQTT topic into DynamoDB using a rule. 
  An example topic is <code>cooler/cooler42/sensors</code> and example message</p>
  
  <p><code>{
    "waterTemp": 10,
    "timestamp": 1580370731383
  }</code></p>
  
  <p>I've defined the query like so, to extract the <code>deviceName</code> (e.g. <code>cooler42</code>) from the topic and insert it into the JSON:</p>
  
  <p><code>SELECT *, topic(2) AS deviceName  FROM 'cooler/+/sensors'</code></p>
  
  <p>This does indeed seem to work, as if I republish the message to another topic I now see the same JSON with <code>deviceName</code> added:</p>
  
  <p><code>{
    "waterTemp": 10,
    "timestamp": 1580370731383,
    "deviceName": "cooler42"
  }</code></p>
  
  <p>My understanding is that all 3 fields should now be available for use within my DynamoDB rule like so:</p>
  
  <p><a href="https://i.stack.imgur.com/gO9SG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gO9SG.png" alt="screenshot of create rule page"></a></p>
  
  <p>However I can see from CloudWatch that the rule is failing with error 
  <code>One or more parameter values were invalid: An AttributeValue may not contain an empty string (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException</code> and the partition key (aka hash key) is coming through as empty:</p>
  
  <p><code>{ 
     "ItemRangeKeyValue":"1580370731383",
     "IsPayloadJSON":"true",
     "ItemHashKeyField":"deviceName",
     "Operation":"Insert",
     "ItemRangeKeyField":"timestamp",
     "Table":"SensorDataTest2",
     "ItemHashKeyValue":""        &lt;--- Empty
  }</code></p>
  
  <p>Am I not able to use the <code>deviceName</code> I've just SELECTed from the topic name in the rule? If not is there another way to extract it?</p>
  
  <p>NB If I manually publish a message onto the topic already including the <code>deviceName</code> then it does work fine, but I'm working in a constrained environment and don't want the extra payload size.</p>