hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

importing resource failure due to capitalization on azurerm_web_application_firewall_policy #16072

Open Aeternax opened 2 years ago

Aeternax commented 2 years ago

TF version: 1.1.7 azurerm version: 3.0.1 (also at least 2.99 and 2.85)

Command run:

terraform import azurerm_web_application_firewall_policy.firewall /subscriptions/....................../resourceGroups/XXXXXXXXXXXXXXXXXXXXX-RSG/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/yyyyyyyyyyyyyyy

Problem encountered:

Error: ID was missing the ApplicationGatewayWebApplicationFirewallPolicies element │ │ with azurerm_web_application_firewall_policy.firewall, │ on firewall.tf line 1, in resource "azurerm_web_application_firewall_policy" "firewall": │ 1: resource "azurerm_web_application_firewall_policy" "firewall" {

Workaround:

Making capital A on ApplicationGatewayWebApplicationFirewallPolicies. The azure portal returns the ID with a lowercase a.

On at least azurerm version 2.67 the import "succeeded" but will largely be empty.

neil-yechenwei commented 2 years ago

thanks for raising this issue. Per the doc descirption, seems the section ApplicationGatewayWebApplicationFirewallPolicies is expected.

wvannuffele4 commented 1 year ago

This is a bug in the Azure portal, not the AzureRM provider. The resource JSON correctly lists the resource id with a capitalized A.

NoppadolXOM commented 1 week ago

The Azure portal has already corrected the bug. "A" on ApplicationGatewayWebApplicationFirewallPolicies is capital now. Please change AzureRM provider back to use capital "A".

![image](Screenshot 2024-11-13 221857)

MichaelChristopherson commented 5 days ago

Confirming the same as @NoppadolXOM that when using terraform to import an existing web application firewall policy it is expecting a lowercase 'a' in the ApplicationGatewayWebApplicationFirewallPolicies but the json output from the resource id is a capital A.

I encountered this with terraform provider version 3.116.0.

MichaelChristopherson commented 5 days ago

@rcskosir - tagging you as I see you have commented on this issue and https://github.com/hashicorp/terraform-provider-azurerm/issues/24634.

According to the upstream hashicorp/go-azure-sdk dev @tombuildsstuff the API treating this as lower case is expected. https://github.com/hashicorp/go-azure-sdk/issues/538 but the resource JSON in Azure shows it as upper case. I was able to import an already created Application Gateway WAF policy today using the lower case applicationGatewayWebApplicationFirewallPolicies and have not had issues managing it with provider version 4.10.0 after the fact, but am wondering how this issue could be resolved between the JSON supposedly being correct showing upper case but the hashicorp/go-azure-sdk devs stating it should in fact be camelCased.