Sometimes in CloudFormation a Parameter requires an array, and often an array of variable size is required, determined for example by input parameters. For instance AWS::AmazonMQ::Broker were you need to define an array of SubnetIds. In which either if SINGLE_INSTANCE is selected or if ACTIVE_STANDBY_MULTI_AZ is selected, several ids must be specified.
Using the notation proposed in the documentation this cannot be achieved:
SubnetIds: - !Ref PrivSubnetA - !If [ DeployAmqMultiAzCondition, !Ref PrivSubnetB, ]
But the problem can be solved as follows:
SubnetIds: !If [ DeployAmqMultiAzCondition, [ !Ref PrivSubnetA, !Ref PrivSubnetB ], [ !Ref PrivSubnetA ]]