Terraform,日志中的奇怪模式 [32m+ [0m

Terraform, weird patterns in the log [32m+ [0m

我正在关注官方 GCP 存储库中的 this tutorial 如何从云构建部署 Terraform:

cloudbuils.yaml

steps:
- id: 'branch name'
  name: 'alpine'
  entrypoint: 'sh'  
  args: 
  - '-c'
  - | 
      echo "***********************"
      echo "$BRANCH_NAME"
      echo "***********************"
- id: 'tf init'
  name: 'hashicorp/terraform:1.0.0'
  entrypoint: 'sh'
  args: 
  - '-c'
  - |
      if [ -d "environments/$BRANCH_NAME/" ]; then
        cd environments/$BRANCH_NAME
        terraform init
      else
        for dir in environments/*/
        do 
          cd ${dir}   
          env=${dir%*/}
          env=${env#*/}
          echo ""
          echo "*************** TERRAFORM INIT ******************"
          echo "******* At environment: ${env} ********"
          echo "*************************************************"
          terraform init || exit 1
          cd ../../
        done
      fi 

我在日志中有以下模式:

2022-02-21 07:13:13.094 CETStep #3 - "tf apply": [32m+[0m [0m[1m[0munique_id[0m[0m = (known after apply)
2022-02-21 07:13:13.094 CETStep #3 - "tf apply": }
2022-02-21 07:13:13.094 CETStep #3 - "tf apply":
2022-02-21 07:13:13.094 CETStep #3 - "tf apply": [0m[1mPlan:[0m 7 to add, 0 to change, 0 to destroy.

这让调试变得更加痛苦,我确信这是一个简单的格式问题,但我找不到它的来源。

link1, link2 and link3 中也出现了类似的问题,其中提到:

Apparently Terraform attempts to format the output using color. However, Jenkins does not output this formatting correctly and thus you see those unusual characters in the output. was able to make Terraform omit those characters in the output by using the -no-color flag. This option is available for at least three of the major Terraform functions: show, plan, and apply. It resolved by using terraform show -no-color

有关如何使用 terraform、cloud build 和 gitops 将基础架构作为代码管理的更多信息,您可以参考此 documentation