'gitlab yaml anchor reference in an if clause

Is it possible, or is there a way, to use a yaml anchor reference in a BASH if clause. If so, how? This is what I'm attempting so far.

create-cluster:
  needs: 
    - terra-bootstrap
  script:
    - export TF_VAR_state_bucket_prefix="${TF_VAR_vsad}/${TF_VAR_cluster_name}"
    - pushd terra-cluster
    - *init_with_gcs_state
    - |
      if [[ "${CLUSTER_EXISTS}" == 'false' ]]; then
       terraform apply -auto-approve
       *does_cluster_exist
      fi
    - popd
  stage: create-cluster
  tags:
    - gke


Solution 1:[1]

No, the YAML spec does not allow you to do this. YAML anchors cannot be used within a string (or any other scalar).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sytech