微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在从 terraform 重新发布主题 aws iot 核心中使用主题函数

如何解决在从 terraform 重新发布主题 aws iot 核心中使用主题函数

我尝试使用 terraform 模块 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"}]
}

然后我收到错误

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".

主题函数存在于 AWS https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-functions.html

解决方法

好的,我找到了解决方案 - 我们应该添加额外的 $ 前缀。

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"}]
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。