I try to create iot rule like this using terraform module https://github.com/QuiNovas/terraform-aws-iot-topic-rule
module "iot_rule_2" {
name = "xxx"
sql_query = "xxx"
source = "QuiNovas/iot-topic-rule/aws"
version = "1.0.4"
republish = [{topic = "$$aws/things/${topic(3)}/shadow/name/datamodel/update"}]
}
and I get the error
Error: Call to unknown function
│
│ on main.tf line 52, in module "iot_rule_2":
│ 52: republish = [{topic = "$$aws/things/${topic(3)}/shadow/name/datamodel/update"}]
│
│ There is no function named "topic".
The topic function exists in AWS https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-functions.html
Ok, I found the solution - we should prefix with additional $.
module "iot_rule_2" {
name = "xxx"
sql_query = "xxx"
source = "QuiNovas/iot-topic-rule/aws"
version = "1.0.4"
republish = [{topic = "$$aws/things/$${topic(3)}/shadow/name/datamodel/update"}]
}