title: Trying to apply regex to a list in terraform and perform a conditional operation
body: <p>I have a list of various instance types. I am trying to filter the list based on regex and deploy a script based on the instance type.
  Example:</p>
  <pre><code>instances = [c5.4xlarge,c5a.8xlarge,m5ad.large,m5ad.4xlarge,c5ad.4xlarge]** 
  </code></pre>
  <p>I am trying to apply this regex to this list</p>
  <pre><code>&quot;regex(&quot;^[[:alnum:]][d]?.[[:alnum:]]&quot;, &quot;r5d.4xlarge&quot;)&quot;
  </code></pre>
  <p>which filters out the new instance types from the list.
  Also, I need to use the above to perform a conditional operation based on instance type it should deploy the appropriate script with set configs.
  <code>condition ? script 1 : script 2</code>
  previously I was using something like
  <code>contains(list,&quot;instance type&quot;) || contains ( list, &quot;instance type&quot;) ? script 1 : script 2</code>
  the problem with this approach I was facing was I need to put <code>or</code> conditions for multiple instance types so it wasn't feasible.</p>