jason-johnson/azure-pipelines-tasks-terraform

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

Closed this issue · 1 comments

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

  • OS: ubuntu-latest
  • Microsoft Hosted
  • Terraform version used (Default for hosted agent is acceptable)
  • AzureCLI version used (Default for hosted agent is acceptable or N/A)

Duplicate of #270