I create AWS IoT Rules using Ansible playbook for cloud formation. Below is snippet where I want to create a simple rule to write everything from updated device shadow to S3. Name of Key should have YYYY/MM/DD.
- Code snippet for IoT Rule SQL:
my_iot_rule:
region: "{{ region }}"
state: present
name: "{{ envType }}_deviceshadow_rule_v1"
description: Forward device shadow status to S3
sql: SELECT * FROM "${aws}/things/#/shadow/get/accepted" WHERE schemaVersion='mySchemaVersion1.0'
sqlVersion: "2016-03-23"
actions:
- s3:
roleArn: arn:aws:iam::{{ awsAccount.accountId }}:role/iot-rule-engine
bucketName: "{{ s3.someBucketName}}"
"key": "deviceshadow/${device.deviceId}**/YYYY/MM/DD/somename.someextention**"
- Assume I have a field with epoch time as "time": 1471618669000 which will be in output of SELECT *,time.
How do I convert "time": 1471618669000 to get YYYY, MM and DD in "key"'s value in above. Is there any function in IoT SQL ?
Or How can I get Sysdate in IoT Rule SQL ? Thanks in advance.