【问题标题】:AWS IoT JITPovisioning template with Fn::Join带有 Fn::Join 的 AWS IoT JITPovisioning 模板
【发布时间】:2020-03-02 09:16:24
【问题描述】:

我正在尝试在 AWS IoT 中为我的 CA 证书添加registrationConfig。我想对事物属性的数据进行一些操作。但是,如果模板正文中包含 Fn::Join,我似乎无法让该 JITP 工作。

以下是模板正文的摘录(为了阅读目的,字符串未转义)

不工作:

"Resources": {
  "thing": {
    "Type": "AWS::IoT::Thing",
    "Properties": {
      "ThingName": {
        "Ref": "AWS::IoT::Certificate::CommonName"
      },
      "ThingTypeName" :  "w2-device",
      "ThingGroups" : ["w2-devices"],
      "AttributePayload": {
        "location": {
          "Fn::Join":["",["ThingPrefix_",{"Ref":"SerialNumber"}]]
        },
        "organization": {
          "Ref": "AWS::IoT::Certificate::Organization"
        },
        "version": "w2",
        "country": {
          "Ref": "AWS::IoT::Certificate::Country"
        }
      }
    }
  },

在上面,当我在 AttributePayload/location 中有 Fn::Join 时,它无法在 JITP 期间创建事物。我也没有在 CloudWatch 中看到任何错误。

工作:

"Resources": {
  "thing": {
    "Type": "AWS::IoT::Thing",
    "Properties": {
      "ThingName": {
        "Ref": "AWS::IoT::Certificate::CommonName"
      },
      "ThingTypeName" :  "w2-device",
      "ThingGroups" : ["w2-devices"],
      "AttributePayload": {
        "location": {
          "Ref": "AWS::IoT::Certificate::StateName"
        },
        "organization": {
          "Ref": "AWS::IoT::Certificate::Organization"
        },
        "version": "w2",
        "country": {
          "Ref": "AWS::IoT::Certificate::Country"
        }
      }
    }
},

注意:我也在aws forum 中问过这个问题,但还没有任何答案。

【问题讨论】:

  • 如果参数中有SerialNumber 和/或使用完整参考AWS::IoT::Certificate::SerialNumber 会怎样?您的模板与docs.aws.amazon.com/iot/latest/developerguide/… 的示例有多接近?
  • 与该页面中的示例非常相似。参考 AWS::IoT::Certificate::SerialNumber 有效。
  • 我添加了一个答案,描述了 AWS::IoT::Certificate::SerialNumber 工作的原因

标签: aws-iot


【解决方案1】:

JITP 的配置模板定义了一组以AWS::IoT::Certificate 开头的参数。

应该在属性有效负载中使用AWS::IoT::Certificate::SerialNumber 参数而不是仅使用SerialNumber。例如

"AttributePayload": {
    "location": {
      "Fn::Join":["",["ThingPrefix_",{"Ref":"AWS::IoT::Certificate::SerialNumber"}]]
    },

https://docs.aws.amazon.com/iot/latest/developerguide/jit-provisioning.html 列出为 JITP 定义的参数:

  • AWS::IoT::Certificate::Country
  • AWS::IoT::Certificate::Organization
  • AWS::IoT::Certificate::OrganizationalUnit
  • AWS::IoT::Certificate::DistinguishedNameQualifier
  • AWS::IoT::Certificate::StateName
  • AWS::IoT::Certificate::CommonName
  • AWS::IoT::Certificate::SerialNumber
  • AWS::IoT::Certificate::Id

AWS 文档中的SerialNumber 示例(没有AWS::IoT::Certificate 前缀用于Bulk Registration 进程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-01
    相关资源
    最近更新 更多