Introduction
When using GitHub Actions to run terraform test for modules that authenticate to Azure, the pipeline may fail intermittently with the following error:
[ERROR] provider.terraform-provider-azurerm_v4.29.0_x5: Response contains error diagnostic: diagnostic_detail="" diagnostic_summary="unable to build authorizer for Resource Manager API: could not configure AzureCli Authorizer: tenant ID was not specified and the default tenant ID could not be determined: obtaining tenant ID: obtaining account details: running Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account."
This article provides a workaround to ensure pipeline stability.
Expected Outcome
After applying this workaround, the GitHub Actions pipeline should complete successfully on every run.
Prerequisites
- GitHub Actions
- Terraform
azurermprovider
Use Case
This issue can occur in pipelines that use static credentials stored as GitHub environment secrets to authenticate to Azure, with the subscription ID and tenant ID assigned during the workflow.
Procedure
To prevent the intermittent authentication failures, configure the test job in your GitHub Actions workflow file to run with max-parallel: 1. This ensures that terraform test processes the test files sequentially.
Update your workflow .yaml file with the following configuration.
jobs:
example_matrix:
strategy:
max-parallel: 1 ## Ensures tests run one by oneThis configuration prevents the unable to build authorizer for Resource Manager API error from occurring.