CodexBloom - Programming Q&A Platform

Terraform Not Creating Azure Resource Group with Managed Identity due to Invalid Provider Configuration

👀 Views: 0 đŸ’Ŧ Answers: 1 📅 Created: 2025-07-23
terraform azure resource-group managed-identity HCL

After trying multiple solutions online, I still can't figure this out. I've been struggling with this for a few days now and could really use some help... I'm reviewing some code and I'm trying to create an Azure Resource Group using Terraform with a managed identity, but I'm running into issues with the provider configuration. When I run `terraform apply`, I receive the following behavior message: ``` behavior: behavior creating Resource Group "my-resource-group": authorization failed on main.tf line 10, in resource "azurerm_resource_group" "example": 10: resource "azurerm_resource_group" "example" { ``` Here's a snippet of my Terraform configuration: ```hcl provider "azurerm" { features {} subscription_id = var.subscription_id tenant_id = var.tenant_id client_id = var.client_id client_secret = var.client_secret } resource "azurerm_resource_group" "example" { name = "my-resource-group" location = "East US" } ``` I've checked that the credentials in `client_id` and `client_secret` have the right permissions and belong to a service principal that has the Contributor role on the subscription level. I also verified that the `azurerm` provider version is 2.69.0, which should support managed identities. I tried running `terraform init` and `terraform plan` again, but the behavior continues. Is there something missing in my provider setup or configuration that could cause this authorization failure? Any insights or suggestions would be greatly appreciated! How would you solve this? Any examples would be super helpful.