'Conditional KinesisStreamSpecification in CloudFormation script

I am new to CloudFoundation scripts and trying to set the conditional attribute for AWS DDB table using the yaml files.

Tried with below but getting error during the stack formation - Property StreamArn cannot be empty.

Seems its not allowing AWS::NoValue in this case.

Can we set the 'KinesisStreamSpecification' property itself on the condition?

      KinesisStreamSpecification:
          StreamArn: !If
          - ShouldAttachKinesis
          - !Sub "arn:aws:kinesis:SomeValue"
          - !Ref "AWS::NoValue"


Solution 1:[1]

Your If should be one level up:

      KinesisStreamSpecification:
        !If
          - ShouldAttachKinesis
          - StreamArn: !Sub "arn:aws:kinesis:SomeValue"
          - !Ref "AWS::NoValue"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcin