Surya Pratap
Surya Pratap

Reputation: 153

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

I'm trying to create Azure virtual machine with Terraform and Azure Devops. I'm getting below error.
"The directory /home/vsts/work/1/s contains no Terraform configuration files." Below is my .yml file.

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 ()'

Upvotes: 2

Views: 7106

Answers (1)

Leo Liu
Leo Liu

Reputation: 76700

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

According to the error:

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

It seems you have run the command in the wrong folder. You have to be in the directory that contains your configuration files before running init.

So, you could add the arguments like workingDirectory in the first task TerraformTaskV1, like:

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

Hope this helps.

Upvotes: 3

Related Questions