azure-pipelines-terraform: Terraform plan shows error with extra command
Upon the error condition below, the task did not fail the task nor the pipeline, and produced a jsonPlanFilePath of size 0. It seems an extra “terraform show -json” command is being run, but the command line is not output to the logs. This command does not take into account my -var parameters so ends up failing when using the var to access a key vault entry.

- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV1@0
name: 'terraform_plan'
displayName: 'Terraform plan'
inputs:
command: plan
workingDirectory: '$(System.DefaultWorkingDirectory)/infrastructure/terraform'
commandOptions: -out tfplan -var environment=${{ parameters.environment}} ${{ parameters.TerraformVariables }}
environmentServiceNameAzureRM: '${{ parameters.TerraformEnvironmentServiceConnection }}'
backendServiceArm: '${{ parameters.TerraformBackendServiceConnection }}'
2019-12-12T06:28:43.8040581Z ##[section]Starting: Terraform plan
2019-12-12T06:28:43.8045948Z ==============================================================================
2019-12-12T06:28:43.8046383Z Task : Terraform
2019-12-12T06:28:43.8046621Z Description : Execute terraform commands to manage resources on AzureRM, Amazon Web Services(AWS) and Google Cloud Platform(GCP)
2019-12-12T06:28:43.8046841Z Version : 0.0.137
2019-12-12T06:28:43.8047032Z Author : Microsoft Corporation
2019-12-12T06:28:43.8047286Z Help : [Learn more about this task](https://aka.ms/AA5j5pf)
2019-12-12T06:28:43.8047561Z ==============================================================================
2019-12-12T06:28:43.9546191Z [command]/opt/hostedtoolcache/terraform/0.12.18/x64/terraform providers
2019-12-12T06:28:44.2264902Z .
2019-12-12T06:28:44.2266821Z ├── provider.azurerm =1.38.0
2019-12-12T06:28:44.2267798Z └── module.sqlserver
2019-12-12T06:28:44.2268733Z └── provider.azurerm (inherited)
2019-12-12T06:28:44.2269282Z
2019-12-12T06:28:44.2328246Z ##[warning]Multiple provider blocks specified in the .tf files in the current working drectory.
2019-12-12T06:28:44.2342819Z [command]/opt/hostedtoolcache/terraform/0.12.18/x64/terraform plan -out tfplan -var environment=stage -var department=Engineering
2019-12-12T06:28:45.5400834Z [0m[1mRefreshing Terraform state in-memory prior to plan...[0m
2019-12-12T06:28:45.5402427Z The refreshed state will be used to calculate this plan, but will not be
2019-12-12T06:28:45.5403137Z persisted to local or remote state storage.
2019-12-12T06:28:45.5405546Z [0m
2019-12-12T06:28:47.7062647Z [0m[1mazurerm_resource_group.main: Refreshing state... [id=/subscriptions/a4ed7b9a-b128-49b4-a6ee-fd07ff6e296d/resourceGroups/rg-starterterraform-stage-main][0m
2019-12-12T06:28:47.7063754Z [0m[1mdata.azurerm_client_config.current: Refreshing state...[0m
2019-12-12T06:28:47.7072014Z [0m[1mdata.azurerm_key_vault.keyvault: Refreshing state...[0m
2019-12-12T06:28:47.7594208Z [0m[1mmodule.sqlserver.data.azurerm_key_vault_secret.sql_password: Refreshing state...[0m
2019-12-12T06:28:47.9504198Z [0m[1mmodule.sqlserver.azurerm_sql_server.example: Refreshing state... [id=/subscriptions/a4ed7b9a-b128-49b4-a6ee-fd07ff6e296d/resourceGroups/rg-starterterraform-stage-main/providers/Microsoft.Sql/servers/algattik01sqlserver][0m
2019-12-12T06:28:48.0025319Z
2019-12-12T06:28:48.0027927Z ------------------------------------------------------------------------
2019-12-12T06:28:50.2890823Z
2019-12-12T06:28:50.2892856Z [0m[1m[32mNo changes. Infrastructure is up-to-date.[0m[32m
2019-12-12T06:28:50.2893194Z
2019-12-12T06:28:50.2893376Z This means that Terraform did not detect any differences between your
2019-12-12T06:28:50.2893635Z configuration and real physical resources that exist. As a result, no
2019-12-12T06:28:50.2895874Z actions need to be performed.[0m
2019-12-12T06:28:50.3229687Z [command]/opt/hostedtoolcache/terraform/0.12.18/x64/terraform version
2019-12-12T06:28:50.8207298Z Terraform v0.12.18
2019-12-12T06:28:50.8209431Z + provider.azurerm v1.38.0
2019-12-12T06:28:54.7166180Z [31m
2019-12-12T06:28:54.7168517Z [1m[31mError: [0m[0m[1mKeyVault Secret "dev-sql-password" (KeyVault URI "https://terraformstarter.vault.azure.net/") does not exist[0m
2019-12-12T06:28:54.7170425Z
2019-12-12T06:28:54.7172146Z [0m on sqlserver/main.tf line 1, in data "azurerm_key_vault_secret" "sql_password":
2019-12-12T06:28:54.7173621Z 1: data "azurerm_key_vault_secret" "sql_password" [4m{[0m
2019-12-12T06:28:54.7177543Z [0m
2019-12-12T06:28:54.7179193Z [0m[0m
2019-12-12T06:28:55.7041120Z [31mTerraform couldn't read the given file as a state or plan file.
2019-12-12T06:28:55.7042289Z The errors while attempting to read the file as each format are
2019-12-12T06:28:55.7042705Z shown below.
2019-12-12T06:28:55.7042933Z
2019-12-12T06:28:55.7043727Z State read error: Error loading statefile: open /home/vsts/work/1/s/plan-binary-54b477c5-fc04-4727-9cab-f98aa11a7d87.tfplan: no such file or directory
2019-12-12T06:28:55.7044407Z
2019-12-12T06:28:55.7045166Z Plan read error: open /home/vsts/work/1/s/plan-binary-54b477c5-fc04-4727-9cab-f98aa11a7d87.tfplan: no such file or directory[0m[0m
2019-12-12T06:28:55.7109502Z ##[section]Finishing: Terraform plan
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 20
Facing the same issue. Init and Validate work without any problems, Plan and Apply is unable to read remote state file.
I’m having the same problem. I’m running the
planaction, however there’s some unexpected additional command being run, as can be seen in the logs.So… what is the extension doing, and why is it failing, and why is the failure not causing the task to fail?
Hi folks,
Any news on this @Roshan-Kumar-Microsoft ? This seems to be happening with everyone. I have a very dummy pipeline and I’m also getting this error.
Thank you