How does Terraform authenticate to Azure in CI?
IntermediateConceptAzure DevOps, Bicep and Terraform
Answer
With OIDC, set environment variables (the azurerm provider and backend both read them):
ARM_CLIENT_ID=<app or UAMI client id>
ARM_TENANT_ID=<tenant id>
ARM_SUBSCRIPTION_ID=<subscription id>
ARM_USE_OIDC=true
In GitHub Actions the provider requests the OIDC token itself (needs permissions: id-token: write); in Azure DevOps, use ARM_OIDC_AZURE_SERVICE_CONNECTION_ID with SYSTEM_ACCESSTOKEN, or run inside AzureCLI@2 with ARM_USE_CLI=true. On a VM or agent with managed identity: ARM_USE_MSI=true. Never commit client_secret.
More on Azure DevOps, Bicep and Terraform
What services make up Azure DevOps?BeginnerWhat are branch policies in Azure Repos?BeginnerExplain the YAML pipeline structure in Azure Pipelines.BeginnerWhat are service connections and how should they authenticate?IntermediateWhat are environments in Azure Pipelines?IntermediateWhat deployment strategies do deployment jobs support?Intermediate