jason-johnson / azure-pipelines-tasks-terraform

Azure Pipelines extension for Terraform
MIT License
122 stars 51 forks source link

Terraform only supports service principal authorization for azure #393

Closed rhysduck closed 8 months ago

rhysduck commented 8 months ago

Describe the bug Issue when deploying infrastructure after latest update to DevOps extension

[error]Terraform only supports service principal authorization for azure

To Reproduce Steps to reproduce the behavior:

  1. Setup pipeline as (include yaml configuration or screenshots of classic ui editor)

image

  1. Execute pipeline

image

  1. See error

Expected behavior I expect the pipeline to run the plan as it did prior to the extension update.

Screenshots Pipeline that ran an hour before the update:

image

Pipeline running yesterday with same code:

image

Pipeline Logs 2023-11-07T13:54:46.8443837Z ##[section]Starting: Terraform Plan 2023-11-07T13:54:46.8601370Z ============================================================================== 2023-11-07T13:54:46.8601801Z Task : Terraform CLI 2023-11-07T13:54:46.8601992Z Description : Execute terraform cli commands 2023-11-07T13:54:46.8602288Z Version : 1.0.6 2023-11-07T13:54:46.8602415Z Author : Charles Zipp 2023-11-07T13:54:46.8603728Z Help : 2023-11-07T13:54:46.8603846Z ============================================================================== 2023-11-07T13:54:52.6570851Z [command]C:\terraform\terraform_1.6.2_windows_amd64\terraform.exe version 2023-11-07T13:54:52.7887701Z Terraform v1.6.2 2023-11-07T13:54:52.7888500Z on windows_amd64 2023-11-07T13:54:52.7889138Z + provider registry.terraform.io/databricks/databricks v1.13.0 2023-11-07T13:54:52.7889960Z + provider registry.terraform.io/hashicorp/azuread v2.6.0 2023-11-07T13:54:52.7890694Z + provider registry.terraform.io/hashicorp/azurerm v3.59.0 2023-11-07T13:54:52.7891538Z + provider registry.terraform.io/hashicorp/null v2.1.2 2023-11-07T13:54:52.7892245Z + provider registry.terraform.io/hashicorp/random v2.3.1 2023-11-07T13:54:52.7893200Z + provider registry.terraform.io/hashicorp/template v2.2.0 2023-11-07T13:54:52.7927106Z + provider registry.terraform.io/hashicorp/tls v2.2.0 2023-11-07T13:54:52.7930475Z 2023-11-07T13:54:52.7931212Z Your version of Terraform is out of date! The latest version 2023-11-07T13:54:52.7932205Z is 1.6.3. You can update by downloading from https://www.terraform.io/downloads.html 2023-11-07T13:54:52.8084607Z ##[error]Terraform only supports service principal authorization for azure 2023-11-07T13:54:52.8241157Z ##[error]Terraform only supports service principal authorization for azure 2023-11-07T13:54:53.0755214Z ##[section]Finishing: Terraform Plan

Agent Configuration

Additional context Add any other context about the problem here.

mroussel commented 8 months ago

Same problem here.

Marquis79 commented 8 months ago

Same problem here.

jason-johnson commented 8 months ago

Duplicate of #388

jason-johnson commented 8 months ago

Oh, sorry. Read it too fast. This is bizarre. All the new update does is add versions to the task. Can you try with TerraformCli@0 and TerraformCli@2?

rhysduck commented 8 months ago

Hey Jason, TerraformCli@2 is working for the moment thanks.

jason-johnson commented 8 months ago

Just keep in mind that TerraformCli@2 is not the stable one. Later releases can break this without warning. On a good note, though, what is in TerraformCli@2 right now should be in TerraformCli@1 on the next release.

jaredfholgate commented 8 months ago

@jason-johnson It looks like an old version has been deployed to 1.0.6 somehow. That error message Terraform only supports service principal authorization for azure only existed in the code prior to me adding WIF and MI support. And same for the init message of Terraform backend initialization for AzureRM only support service principal authorization. Both were removed in that PR: https://github.com/jason-johnson/azure-pipelines-tasks-terraform/pull/359/files

See here:

jaredfholgate commented 8 months ago

@rhysduck Unrelated to the error, but I see you are supplying env vars for azurerm config as well as a service connection. The task will overwrite those env vars if I am not mistaken, so wondering what you are trying to achieve by supplying them? If you need to supply via env vars instead of the recommended service connection method, there is no need to use the task, you can just run the cli directly instead.

lynkz-matt-psaltis commented 8 months ago

Hey Jason, TerraformCli@2 is working for the moment thanks.

Same here, last successful build was Monday, moved to @2 and starts working again.

jason-johnson commented 8 months ago

Ok, this should be fixed by #396 now. Please feel free to reopen if you have any further issues with it.