When you would like to add items to a list in CloudFormation, you can use the !If statement. If the condition is true, the first argument will be added, otherwise the second argument will be added. But what if you don’t have a second argument, you can use !Ref AWS::NoValue to add nothing.
1Bucket:
2 Type: AWS::S3::Bucket
3 Properties:
4 Tags:
5 - !If
6 - IsProduction
7 - Tag: MyTag
8 Value: MyValue
9 - !Ref AWS::NoValue
So in this case, you can add a tag to the bucket if the condition is true, otherwise nothing will be added to the list.

