【问题标题】:How to apply terraform.tfvars in azure devops pipeline如何在 azure devops 管道中应用 terraform.tfvars
【发布时间】:2021-11-25 13:22:00
【问题描述】:

尝试使用 azure devops 管道使用 terraform 构建 AKS,我希望我可以从 prod_terraform.tfvars 文件中传递变量值 我想运行“terraform plan -var-file = prod_terraform.tfvars”

这里是yaml代码

      - task: TerraformCLI@0
        displayName: Terraform Plan
        inputs:
          command: 'plan'
          workingDirectory: '$(System.DefaultWorkingDirectory)/terraform-manifests'
          commandOptions: '-out aks_cluster.tfplan'
          allowTelemetryCollection: false

下面是错误


/opt/hostedtoolcache/terraform/1.0.8/x64/terraform plan -out aks_cluster.tfplan
Acquiring state lock. This may take a few moments...
var.acr_demo
  Enter a value: 
##[error]The operation was canceled.
Finishing: Terraform Plan

【问题讨论】:

    标签: azure-devops terraform azure-pipelines terraform-provider-azure


    【解决方案1】:

    如果变量定义文件名为 terraform.tfvars 或以 .auto.tvfars 结尾并与其他配置文件位于同一目录中,则 Terraform 将自动从变量定义文件中加载变量值,如下所示:

    development
    └── server
        └── main.tf
        └── variables.tf
        └── terraform.tfvars
    

    我重命名了文件并且它工作了

    【讨论】:

      猜你喜欢
      • 2022-08-17
      • 2020-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-18
      • 2019-11-23
      相关资源
      最近更新 更多