如何将 JSON 类型传入 YAML CloudFormation 模板

问题描述 投票:0回答:1

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot1click-placement.html#cfn-iot1click-placement-linkeddevices

声明属性

AssociatedDevices
是JSON类型,但是当我在YAML中编写模板时

我在这里阅读了一些回复并尝试了以下方法:

AssociatedDevices: "--arguments": '{"SecuityButtonTemplate": !Ref TestITPA.DeviceId}'   
PlacementName: "TestITPAPlacement"      
Attributes:  "--arguments": '{"--Location": TestITPALoc}'

(构建失败)

还有这个:

  AssociatedDevices: '{"SecuityButtonTemplate": !Ref TestITPA.DeviceId}'   
  PlacementName: "TestITPAPlacement"
  Attributes:  '{"Location":"TestingLoc"}'

(这也无法构建)

我什至在 github 上搜索引用 AssociatedDevices 的 YAML 代码,但没有找到人们实际上是如何做到这一点的 - 谁能帮我解释一下?

我终于尝试了这个:

     AssociatedDevices: !Sub |
{
    SecuityButtonTemplate: !Ref TestITPA.DeviceId
}   
  PlacementName: "TestITPAPlacement"
  Attributes:  !Sub |
{
    Location: "testingLoc"
}

(这会引发 IDE 错误 - PlacementName 的中间变量不再像其他变量那样呈红色)

amazon-web-services yaml aws-cloudformation
1个回答
2
投票

您可以尝试以下方法:

AssociatedDevices: !Sub '{"SecuityButtonTemplate": "${TestITPA.DeviceId}"}'  
PlacementName: "TestITPAPlacement"
Attributes: '{"Location":"TestingLoc"}'
© www.soinside.com 2019 - 2024. All rights reserved.