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

标签 azure-devops terraform-provider-azure

我正在尝试使用 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 ()'

最佳答案

The directory /home/vsts/work/1/s contains no Terraform configuration files. In Azure Devops trying to create Azure resource

根据错误:

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

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

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

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

希望这有帮助。

关于azure-devops - 目录/home/vsts/work/1/s 不包含 Terraform 配置文件。在 Azure Devops 中尝试创建 Azure 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60242431/

相关文章:

git - Azure Devops 指定的登录 session 不存在

azure - 如何在 PR 完成之前测试发布是否成功?

azure - 使用 azurerm_virtual_machine_extension 时,PowerShell 脚本不执行

azure - Terraform 输出多个子网 ID

azure-devops - 使用来自多个存储库的 YAML 模板

azure - VSTS 发布管理 : How to use Azure Blob as Artifact?

azure - 使用 Azure Terraform AzApi 提供程序为容器应用程序环境启用内部负载平衡模式

azure - 地形 : How do I set the value of accessTokenAcceptedVersion to 2 for a Azure Service Principal?

api - 无法使用 Az DevOps Pipelines API 6.0-preview.1 创建新管道

azure - 尝试使用 Terraform Azure AD Provider 2.0 进行应用程序注册时出错