title: Cloudformation yaml- generate a list of instances in AutoScalingGroup resource
body: <p>I am struggling to figure out how to write overrides section of the yaml template for <code>AutoScalingGroup</code> resource. Currently, what I have only works for a fixed length of the string. In this case string passed into the template is called <code>InstanceTypesOverride</code>.</p>
  <p>Below you can see the snippet of the code:</p>
  <p><code>InstanceTypesOverride = &quot;m5.large,m5d.large,m5a.large&quot;</code></p>
  <pre><code>Type: AWS::AutoScaling::AutoScalingGroup
    Properties:
      AutoScalingGroupName: !Ref NodeGroupName
      DesiredCapacity: !Ref NodeAutoScalingGroupDesiredCapacity
      MixedInstancesPolicy:
        InstancesDistribution:
          OnDemandAllocationStrategy: prioritized
          OnDemandBaseCapacity: !Ref OnDemandBaseCapacity
          OnDemandPercentageAboveBaseCapacity: !Ref OnDemandPercentageAboveBaseCapacity
          SpotAllocationStrategy: !Ref SpotAllocStrategy
        LaunchTemplate:
          LaunchTemplateSpecification:
            LaunchTemplateId: !Ref SpotLaunchTemplate
            Version: !GetAtt SpotLaunchTemplate.LatestVersionNumber
          Overrides:
            - InstanceType: !Select [0, !Split [ &quot;,&quot;, !Ref InstanceTypesOverride ] ]
            - InstanceType: !Select [1, !Split [ &quot;,&quot;, !Ref InstanceTypesOverride ] ]
            - InstanceType: !Select [2, !Split [ &quot;,&quot;, !Ref InstanceTypesOverride ] ]
  </code></pre>
  <p>I would like to find out whether it is possible to write the overrides section of the template so that <code>InstanceTypesOverride</code> can handle more instance types or less. As you know, various regions can handle different instances types, therefore it is essential for me to have the ability for the cloudformation to work with different string lengths. Can someone suggest something that would work?</p>
  <p>Ideally, I would like to have a cfm template which works with both <code>InstanceTypesOverride = &quot;m5.large,m5d.large,m5a.large&quot;</code> and <code>InstanceTypesOverride = &quot;m5.large,m5d.large,m5a.large,m5ad.large,m5n.large,m5dn.large&quot;</code></p>