【问题标题】:Using topic function in republish topic aws iot core from terraform在从 terraform 重新发布主题 aws iot 核心时使用主题功能
【发布时间】:2021-05-27 21:37:23
【问题描述】:

我尝试使用 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".

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

【问题讨论】:

  • 你认为 ${topic(3)}/shadow/name/datamodel/update"}] } 会做什么?
  • 它应该将消息从 SQL 查询 (xxx) 中定义的主题重新发布到主题“$$aws/things/${topic(3)}/shadow/name/datamodel/update” - 主题(3) 应该是这里描述的事物 id docs.aws.amazon.com/iot/latest/developerguide/… 从 AWS 控制台 (GUI) 创建时它工作正常我只是尝试稍微自动化部署。
  • 或查看docs.aws.amazon.com/iot/latest/developerguide/… 并告诉我是否可以使用 terraform 插件进行此操作

标签: amazon-web-services terraform terraform-provider-aws aws-iot-core


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2021-03-24
    • 1970-01-01
    • 2016-12-22
    • 1970-01-01
    • 2017-02-22
    • 1970-01-01
    • 2019-11-04
    • 2018-12-04
    • 1970-01-01
    相关资源
    最近更新 更多