title: How to make a list item conditional in Cloud Formation template?
body: <p>I have the following cloud formation template that creates a code pipeline. The pipeline has three stages:</p>
  
  <pre><code>  Stages:
      -
        Name: "Source"
        Actions:
          -
            Name: "Source"
            ActionTypeId:
              Category: "Source"
              Owner: "ThirdParty"
              Version: "1"
              Provider: "GitHub"
            OutputArtifacts:
              - Name: "MyApp"
            Configuration:
              Owner: !Ref GithubOwner
              Repo: !Ref GithubRepo
              PollForSourceChanges: "true"
              Branch: !Ref GithubBranch
              OAuthToken: !Ref GithubTokenParameter
            RunOrder: 1
      -
        Name: "Run-Unit-Tests"
        Actions:
          -
            InputArtifacts:
              - Name: "MyApp"
            Name: "UnitTests"
            ActionTypeId:
              Category: "Test"
              Owner: "AWS"
              Version: "1"
              Provider: "CodeBuild"
            OutputArtifacts:
              - Name: "MyTests"
            Configuration:
            ProjectName: !Ref CodeBuildName
            RunOrder: 1
      -
        Name: "Deploy-Staging"
        Actions:
          -
            InputArtifacts:
              - Name: "MyApp"
            Name: "Deploy-Staging"
            ActionTypeId:
              Category: "Deploy"
              Owner: "AWS"
              Version: "1"
              Provider: "ElasticBeanstalk"
            Configuration:
              ApplicationName: !Ref BeanstalkApplicationName
              EnvironmentName: !Ref BeanstalkEnvironmentStaging
            RunOrder: 1
  </code></pre>
  
  <p>I also have a condition:</p>
  
  <pre><code>IncludeStagingEnv: !Equals [Staging, !Ref CodePipelineEnvironment]
  </code></pre>
  
  <p>When the condition is false, I would like to omit the 3rd item in the Code Pipeline stages list.</p>
  
  <p>I tried using !If with AWS::NoValue, but NoValue is not a valid list item:</p>
  
  <pre><code>Stages:
    - !IF
      - IncludeStagingEnv
      - Name: "Deploy-Staging"
        Actions:
          -
            InputArtifacts:
              - Name: "MyApp"
            Name: "Deploy-Staging"
            ActionTypeId:
              Category: "Deploy"
              Owner: "AWS"
              Version: "1"
              Provider: "ElasticBeanstalk"
            Configuration:
              ApplicationName: !Ref BeanstalkApplicationName
              EnvironmentName: !Ref BeanstalkEnvironmentStaging
              RunOrder: 1
      - AWS::NoValue
  </code></pre>
  
  <p>How can I omit the last item when <code>IncludeStagingEnv==false</code>?</p>