Hey,
I know it’s not the Azure RM specific space, but unfortunately, I’m not able to find what’s going on with my issue.
I’m using terraform to deploy virtual machine in 5 or 6 differents Azure Subscription.
I can deploy in all of them, instead one particular subscription, and I couldn’t find why.
Terraform version: v1.4.6
Azure rm version: 3.54.0 and 3.58.0
Here is the version.tf
##################################################################################
# VERSIONS
##################################################################################
terraform {
backend "azurerm" {
}
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.54.0"
}
/*
netbox = {
source = "e-breuninger/netbox"
version = "1.5.1"
}*/
awx = {
source = "nolte/awx"
version = "0.2.2"
}
}
}
and here is the main.tf
provider "azurerm" {
features {}
}
provider "azurerm" {
skip_provider_registration = "true"
features {}
alias = "common-services"
subscription_id = var.common_services_id
}
resource "random_password" "admin_pwd" {
length = 16
special = true
override_special = "!#$%&*()-_=+[]{}<>:?"
}
data "azurerm_resource_group" "XXXX" {
name = var.resource_group
}
## Import Key vault informations ##
data "azurerm_key_vault" "compute_lab" {
provider = azurerm.common-services
name = var.key_vault_name
resource_group_name = var.resource_group_keyvault
}
Here is the error code
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ Terraform Apply ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
Acquiring state lock. This may take a few moments...
data.azurerm_key_vault.compute_lab: Reading...
data.azurerm_resource_group.image: Reading...
data.azurerm_shared_image.image: Reading...
data.azurerm_resource_group.image: Read complete after 0s [id=/subscriptions/((redacted))/resourceGroups/Packer]
data.azurerm_shared_image.image: Read complete after 1s [id=/subscriptions/((redacted))/resourceGroups/Packer/providers/Microsoft.Compute/galleries/cycloid/images/Windows-server-2019]
data.azurerm_key_vault.compute_lab: Read complete after 1s [id=/subscriptions/((redacted))/resourceGroups/COMPUTE-LAB-COM/providers/Microsoft.KeyVault/vaults/COMPUTE-LAB]
╷
│ Warning: Invalid index:The given key does not identify an element in this collection value.
│
│
╵
╷
│ Error: Unable to list provider registration status, it is possible that this is due to invalid credentials or the service principal does not have permission to use the Resource Manager API, Azure error: resources.ProvidersClient#List: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: error response cannot be parsed: {"\r\n\r\n\r\n
Bad Request - Invalid URL
\r\n
HTTP Error 400. The request URL is invalid.
\r\n\r\n" '\x00' '\x00'} error: invalid character '<' looking for beginning of value
│
│ with provider["registry.terraform.io/hashicorp/azurerm"],
│ on main.tf line 1, in provider "azurerm":
│ 1: provider "azurerm" {
│
╵
Releasing state lock. This may take a few moments...
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ Terraform Apply ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
Failed To Run Terraform Apply!
2023/05/31 08:28:43 Apply Error: Failed to run Terraform command: exit status 1
I’m using a service principal. The permission are well setup on the subscription and the same as the others.
The code is working in all the other subscription.
The resource providers on the problematic subscription are the same as the others as well.
Thank you for your help