title: Getting error "One or more Fn::Sub intrinsic functions don't specify expected arguments" when trying to use variables in UserData in CloudFormation
body: <p>I am getting this error when trying to use !Sub with variables in UserData in CloudFormation:</p>
  <blockquote>
  <p>Template error: One or more Fn::Sub intrinsic functions don't specify expected arguments. Specify a string as first argument, and an optional second argument to specify a mapping of values to replace in the string</p>
  </blockquote>
  <p>Why do I get this error?</p>
  <p>This is my code:</p>
  <pre><code>LinuxEC2Instance:
  Type: AWS::EC2::Instance
  Properties:
    UserData:
      Fn::Base64: !Sub
        - arn_id: !If [TestEnvironment, 'id1', 'id2']
        - key: !If [TestEnvironment, 'key1', 'key2']
        - |
          ARN_ID=${arn_id}
          KEY=${key}
          
          echo $ARN_ID 
          echo $KEY
  </code></pre>