Interview Prep/Azure/Azure DevOps, Bicep and Terraform

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.

Azure All Azure questions Roadmap: AKS & Azure DevOps

More on Azure DevOps, Bicep and Terraform