【问题标题】:The directory /home/vsts/work/1/s contains no Terraform configuration files. In Azure Devops trying to create Azure resource目录 /home/vsts/work/1/s 不包含 Terraform 配置文件。在 Azure Devops 中尝试创建 Azure 资源
【发布时间】:2020-02-17 18:16:08
【问题描述】:

我正在尝试使用 Terraform 和 Azure Devops 创建 Azure 虚拟机。我遇到了错误。
“目录 /home/vsts/work/1/s 不包含 Terraform 配置文件。” 下面是我的 .yml 文件。

resources:
- repo: self
steps:
- task: TerraformInstaller@0
  inputs:
    terraformVersion: '0.12.3'
- task: TerraformTaskV1@0
  displayName: 'Init terraform'
  inputs:
      provider: 'azurerm'
      command: 'init'
      backendServiceArm: 'Free Trial'
      backendAzureRmResourceGroupName: 'terraformtest-rg'
      backendAzureRmStorageAccountName: 'terraformtestrgdiag'
      backendAzureRmContainerName: 'bootdiagnostics-terraform'
      backendAzureRmKey: 'terraform'
- task: TerraformTaskV1@0
  displayName: 'apply status'
  inputs:
      terraformFile: './terraform/terra/main2.tf'
      provider: 'azurerm'
      command: 'apply'
      environmentServiceNameAzureRM: 'Free Trial ()'

【问题讨论】:

  • 我怀疑您需要在第一个 tf 步骤中添加 terraformFile: './terraform/terra/main2.tf'

标签: azure-devops terraform-provider-azure


【解决方案1】:

目录 /home/vsts/work/1/s 不包含 Terraform 配置文件。在 Azure Devops 中尝试创建 Azure 资源

根据错误:

the directory /home/vsts/work/1/s contains no Terraform configuration files

您似乎在错误的文件夹中运行了该命令。在运行 init 之前,您必须位于包含配置文件的目录中。

因此,您可以在第一个任务TerraformTaskV1 中添加workingDirectory 之类的参数,例如:

workingDirectory: '$(System.DefaultWorkingDirectory)\terraform\terra'

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2020-11-06
    • 2019-09-11
    • 1970-01-01
    • 2022-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-01
    • 2020-11-18
    相关资源
    最近更新 更多