jason-johnson / azure-pipelines-tasks-terraform

Azure Pipelines extension for Terraform
MIT License
121 stars 52 forks source link

TerraformCLI@1 Task doesn't work Certificate Based Service Connection in Azure DevOps #382

Closed navyainturi closed 9 months ago

navyainturi commented 9 months ago

Describe the bug In Azure DevOps, TerraformCLI@1 Task works as expected with Secret based Service Connection but doesn't work with Certificate based Service Connection. Below is the YAML file snippet

trigger:
- main
pool:
  vmImage: ubuntu-latest

steps:  
- task: TerraformCLI@1
  inputs:
    command: 'init'
    backendType: 'azurerm'
    backendServiceArm: <Azure_DevOps_Service_Connection_Name>
    backendAzureRmSubscriptionId: <Azure_Subscription_ID>
    backendAzureRmResourceGroupName: <Azure Resource Group Name>
    backendAzureRmStorageAccountName: <Azure Storage Account Name>
    backendAzureRmContainerName: <Azure Storage Account Container Name>
    backendAzureRmKey: <Azure Storage Account Key>
    allowTelemetryCollection: false

To Reproduce Steps to reproduce the behavior:

  1. Setup pipeline with above YAML file (TerraformCLI@1 Task)
  2. Execute pipeline with Secret Based Service Connection in backendServiceArm
  3. Pipeline succeeds and Works as expected
  4. Update and Execute pipeline with Certificate Based Service Connection in backendServiceArm
  5. Pipeline fails with following error - Error: Error building ARM Config: obtain subscription() from Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.

Expected behavior Terraform CLI tasks should be able to authenticate to Azure even with Certificate based Service Connections

Agent Configuration

jason-johnson commented 9 months ago

Duplicate of #270