I am trying to install a cloud information template that will either launch a clean instance or one of the snapshots. I would like to be able to use an operator like if / else to make it look like
pseudo code: if InputSnapshotId: "SnapshotId" : {"Ref" : "InputSnapshotId"}, else: "Size" : 20,
In cloudformation, I tried several things like:
"WebserverInstanceDataVolume" : { "Type" : "AWS::EC2::Volume", "Properties" : { "Fn::If" : [ {"Ref" : "FromSnapshot"}, {"SnapshotId" : { "Ref" : "InputSnapshotId" }}, {"Size" : "20"} ], "VolumeType" : "standard", "AvailabilityZone" : { "Fn::GetAtt" : [ "WebserverInstance", "AvailabilityZone" ]}, "Tags" : [ {"Key" : "Role", "Value": "data" }, ] }, "DeletionPolicy" : "Delete" },
Or wrap in Fn :: If in {}:
{"Fn::If" : [ {"Ref" : "FromSnapshot"}, {"SnapshotId" : { "Ref" : "InputSnapshotId" }}, {"Size" : "20"} ]}
All of which kick different types or errors. The first gives the "Found unsupported Fn :: If property" in cloudformation, the second, just invalid JSON. I could take a picture of an empty volume and define a size parameter, and then always pass SnapshotId and size, but I feel there should be a way to have an extra line in cloud form.
Any ideas?