https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot1click-placement.html#cfn-iot1click-placement-associateddevices
states that the property AssociatedDevices
is a type JSON, but when I am writing the template in YAML
I have read a few responses here and have tried the following:
AssociatedDevices: "--arguments": '{"SecuityButtonTemplate": !Ref TestITPA.DeviceId}'
PlacementName: "TestITPAPlacement"
Attributes: "--arguments": '{"--Location": TestITPALoc}'
(this fails to build)
and this:
AssociatedDevices: '{"SecuityButtonTemplate": !Ref TestITPA.DeviceId}'
PlacementName: "TestITPAPlacement"
Attributes: '{"Location":"TestingLoc"}'
(this also fails to build)
I have even search github for YAML code referencing AssociatedDevices but not finding how people are actually doing this - can anyone help me shed some light ?
I lastly have tried this:
AssociatedDevices: !Sub |
{
SecuityButtonTemplate: !Ref TestITPA.DeviceId
}
PlacementName: "TestITPAPlacement"
Attributes: !Sub |
{
Location: "testingLoc"
}
(this throws what seems to be an IDE error - the middle variable of PlacementName is not longer red like the others)
You can try the following:
AssociatedDevices: !Sub '{"SecuityButtonTemplate": "${TestITPA.DeviceId}"}'
PlacementName: "TestITPAPlacement"
Attributes: '{"Location":"TestingLoc"}'
ToJsonString
intrinsic functionYou can use Fn::ToJsonString
intrinsic function to transform YAML to JSON.
Example:
AssociatedDevices: !ToJsonString
SecuityButtonTemplate: !GetAtt TestITPA.DeviceId
PlacementName: TestITPAPlacement
Attributes: !ToJsonString
Location: TestingLoc
It works with other intrinsic functions (such as Ref
, Sub
, etc) so you code can be written in full YAML with top readability.
Make sure to add the AWS::LanguageExtensions
transform in your template:
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::LanguageExtensions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With