Hello Team,
I would like to enable an azure preview feature via terraform. I have configured skip provider registration but when I tried to apply still get provider already exists error. I have to import manually as a workaround.
My ask:
do we must import manually to avoid provider exist error when register preview feature?
as I already define skip registration but seems it didn’t work.
======== configuration ========
Configure the Azure provider
terraform {
required_providers {
azurerm = {
source = “hashicorp/azurerm”
version = “~> 3.0.2”
}
}
required_version = “>= 1.1.0”
}
provider “azurerm” {
features {}
skip_provider_registration = true
}
resource “azurerm_resource_provider_registration” “example” {
name = “Microsoft.Network”
feature {
name = “AFWEnableNetworkRuleNameLogging”
registered = true
}
}
========= configuration =======
I have configured to skip provider registration but when I tried to apply still get provider already exists.
======== error log ======
PS C:\Users\lbi\Downloads\enablefeature> terraform apply main.tfplan
azurerm_resource_provider_registration.example: Creating…
╷
│ Error: A resource with the ID “/subscriptions/xxxx-xxxx/providers/Microsoft.Network” already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for “azurerm_resource_provider_registration” for more information.
│
│ with azurerm_resource_provider_registration.example,
│ on main.tf line 19, in resource “azurerm_resource_provider_registration” “example”:
│ 19: resource “azurerm_resource_provider_registration” “example” {
│
│ A resource with the ID “/subscriptions/xxxx-xxxx/providers/Microsoft.Network” already
│ exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource
│ documentation for “azurerm_resource_provider_registration” for more information.
======== error log ========
I have to import manually as a workaround.
======= import log =======
PS C:\Users\lbi\Downloads\enablefeature> terraform import azurerm_resource_provider_registration.example /subscriptions/xxxx-xxxx/providers/Microsoft.Network
azurerm_resource_provider_registration.example: Importing from ID “/subscriptions/xxxx-xxxx/providers/Microsoft.Network”…
azurerm_resource_provider_registration.example: Import prepared!
Prepared azurerm_resource_provider_registration for import
azurerm_resource_provider_registration.example: Refreshing state… [id=/subscriptions/xxxx-xxxx/providers/Microsoft.Network]
======= import log =======