I have terraform code that authenticates with a Service Principal using ARM_...
env variables.
Now I need to run a piece of configuration using the Managed identity assigned to the build agent VM.
My TF code is:
provider "azurerm" {
features {}
alias = "ss101"
use_msi = true
client_id = "3...5"
subscription_id = "6...2"
skip_provider_registration = true
}
module "vnet-peering" {
for_each = local.app_vnets
source = "./vnet-peering"
app_vnet = module.vnets[each.value.location].vnets[each.value.key]
providers = {
azurerm.ss101 = azurerm.ss101
}
}
I added client_secret = null
in an unsuccessful attempt to resolve the error I get:
│ Error: building account: could not acquire access token to parse claims: clientCredentialsToken: received HTTP status 401 with response: {"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app '3...5'.\r\nTrace ID: b55484dd-8dec-4b6f-89e4-6b22e24a2000\r\nCorrelation ID: 67880b22-e6e8-4382-8378-7b9ea8702cdd\r\nTimestamp: 2023-03-17 19:21:20Z","error_codes":[7000215],"timestamp":"2023-03-17 19:21:20Z","trace_id":"b55484dd-8dec-4b6f-89e4-6b22e24a2000","correlation_id":"67880b22-e6e8-4382-8378-7b9ea8702cdd","error_uri":"https://login.microsoftonline.com/error?code=7000215"}
│
│ with module.bootstrap.provider["registry.terraform.io/hashicorp/azurerm"].ss101,
│ on .terraform/modules/bootstrap/main.tf line 185, in provider "azurerm":
│ 185: provider "azurerm" {
I suspect the credentials I inject through the environment may interfere with the MSI authentication. I tried to pass client_secret = null
, but it has no effect.
How can I troubleshoot it?