Open cyrtified opened 4 months ago
My current "fix":
resource "azurerm_cdn_frontdoor_endpoint" "endpoint" {
name = "example-endpoint"
cdn_frontdoor_profile_id = replace(azurerm_cdn_frontdoor_profile.profile.id, "//resourcegroups//", "/resourceGroups/") # fix
}
I also tried with the same version of Terraform/AzureRM Provider, but the ID of azurerm_cdn_frontdoor_profile
was created with 'resourceGroups' still in camel case.
Is there any difference between the Terraform configuration I used and your environment?
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.108.0"
}
}
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "rg" {
name = "rg-example"
location = "eastus"
}
resource "azurerm_cdn_frontdoor_profile" "profile" {
name = "example-profile"
resource_group_name = azurerm_resource_group.rg.name
sku_name = "Standard_AzureFrontDoor"
}
resource "azurerm_cdn_frontdoor_endpoint" "endpoint" {
name = "example-endpoint"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.profile.id
}
Underscores _
couldn't be used in the name parameter of azurerm_cdn_frontdoor_profile
and azurerm_cdn_frontdoor_endpoint
, so I replaced them with hyphens -
.
I also tried with the same version of Terraform/AzureRM Provider, but the ID of
azurerm_cdn_frontdoor_profile
was created with 'resourceGroups' still in camel case. Is there any difference between the Terraform configuration I used and your environment?terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = "~>3.108.0" } } } provider "azurerm" { features {} } resource "azurerm_resource_group" "rg" { name = "rg-example" location = "eastus" } resource "azurerm_cdn_frontdoor_profile" "profile" { name = "example-profile" resource_group_name = azurerm_resource_group.rg.name sku_name = "Standard_AzureFrontDoor" } resource "azurerm_cdn_frontdoor_endpoint" "endpoint" { name = "example-endpoint" cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.profile.id }
Underscores
_
couldn't be used in the name parameter ofazurerm_cdn_frontdoor_profile
andazurerm_cdn_frontdoor_endpoint
, so I replaced them with hyphens-
.
Thanks for the reply.
Apologies about the names. I redacted the original script for security purposes.
It looks like the issue occurs when you import the state, instead of creating it from scratch.
Thank you for your response! I created a Front Door (Standard) in the Azure Portal, imported it, and ran terraform plan, but unfortunately, I couldn't reproduce the issue. I imported it as shown below, but do you think there might be any differences with your environment? For example, are you migrating Front Door from classic?
$ terraform import azurerm_resource_group.rg /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-example
$ terraform import azurerm_cdn_frontdoor_profile.profile /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-example/providers/Microsoft.Cdn/profiles/example-profile
$ terraform import azurerm_cdn_frontdoor_endpoint.endpoint /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-example/providers/Microsoft.Cdn/profiles/example-profile/afdEndpoints/example-endpoint
No, I created a new Front Door (Standard) in the Azure Portal.
I destroyed all the resources and recreated them via Terraform and it seems to be working fine now.
I wonder if the "resourceGroups" was created as "resourcegroups" when Front Door was created. It seems difficult for me to investigate this further... I'm sorry.
Probably a Microsoft bug.
Thanks for checking anyway.
@cyrtified in this instance it looks like the Resource ID for azurerm_cdn_frontdoor_profile.profile
contains resourcegroups
rather than resourceGroups
, so you should be able to fix this by removing that resource from your state and re-importing it - which should remove this diff:
terraform state rm azurerm_cdn_frontdoor_profile.profile terraform import azurerm_cdn_frontdoor_profile.profile /subscriptions/xxx/resourceGroups/rg-example/providers/Microsoft.Cdn/profiles/example-profile
Would you be able to take a look and see if that works for you?
Is there an existing issue for this?
Community Note
Terraform Version
1.7.4
AzureRM Provider Version
3.108.0
Affected Resource(s)/Data Source(s)
azurerm_cdn_frontdoor_profile
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
No changes.
Actual Behaviour
azurerm_cdn_frontdoor_profile ID contains lower case "resourcegroups" instead of camel case "resourceGroups" and forces replacement of associated resources, including:
Steps to Reproduce
No response
Important Factoids
No response
References
No response