2
SNSTopic
    Type: 'AWS::SNS'......
SNSTopic2  
    Type: 'AWS::SNS'.......
EventRule:
    Type: 'AWS::Events::Rule'
    Properties:
      Name: !Ref EventRuleName
      Description: 
      State: ENABLED
      EventPattern: '
        {
        }'
      Targets:
        - Arn: 
            Ref: !Sub 'SNSTopic${EmailCount}' ## Issue here
          Id: LATEST

EmailCount is input parameter like 2 here

I want to pass dynamic target arn SNSTopic or SNSTopic2 based on input parameter.. if I hardcode either SNSTopic/SNSTopic2 it works.. how can I use !Sub or !Join ?

SadikKhan
  • 21
  • 2

1 Answers1

1

In this case use the full form Fn::Ref:

      Targets:
        - Arn: 
            Fn::Ref: !Sub 'SNSTopic${EmailCount}' # Note Fn::Ref instead of just Ref

That should work.

MLu
  • 24,849
  • 5
  • 59
  • 86