我正在尝试使用 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/