title: bitbucket pipeline calling YAML anchors from within a for loop
body: <p>I have a YAML anchor that deploys logic-apps. I want the pipeline to look for logic apps in subdirectory and loop through each one and deploy it. Here's my deploy-logicapp anchor</p>
  <pre><code>  - step: &amp;deploy-logicapp
        name: Deploy logic app
        script:
          - source environment.sh
          - pipe: microsoft/azure-arm-deploy:1.0.2
            variables:
                AZURE_APP_ID: $AZURE_CLIENT_ID
                AZURE_PASSWORD: $AZURE_SECRET
                AZURE_TENANT_ID: $AZURE_TENANT
                AZURE_LOCATION: $AZURE_LOCATION
                AZURE_RESOURCE_GROUP: $AZURE_RESOURCE_GROUP
                AZURE_DEPLOYMENT_TEMPLATE_FILE: 'logic-apps/$DIR/template.$DEPLOYMENT_SLOT.json'
  
  </code></pre>
  <p>so in my pipeline, I loop through all the subdirectories and this works, it echoes each $DIR</p>
  <pre><code>      - step:
            script:
              - cd logic-apps
              - for DIR in $(ls -l | grep '^d' | awk '{print $9}'); do echo $DIR ; done
  </code></pre>
  <p>What I want to do is inside this loop I want to call my YAML anchor with the $DIR environment variable. I have tried a number of ways. The problem is the for loop is inside bash and not YAML so I can not call it.</p>
  <p>Any guidance will be much appreciated.</p>